mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #807 from octodns/ns1-monitor-params
Add policy and frequency params for NS1 health-checks
This commit is contained in:
@@ -203,8 +203,10 @@ Sonar check regions (sonar_regions) possible values:
|
|||||||
|
|
||||||
| Key | Description | Default |
|
| Key | Description | Default |
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|
| policy | One of:<ol><li>`all` - down if every region is down</li><li>`quorum` - down if majority regions are down</li><li>`one` - down if any region is down</ol> | `quorum` |
|
||||||
|
| frequency | Frequency (in seconds) of health-check | 60 |
|
||||||
| connect_timeout | Timeout (in seconds) before we give up trying to connect | 2 |
|
| connect_timeout | Timeout (in seconds) before we give up trying to connect | 2 |
|
||||||
| response_timeout | Timeout (in seconds) after connecting to wait for output. | 10 |
|
| response_timeout | Timeout (in seconds) after connecting to wait for output | 10 |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
||||||
@@ -212,6 +214,8 @@ Sonar check regions (sonar_regions) possible values:
|
|||||||
octodns:
|
octodns:
|
||||||
ns1:
|
ns1:
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
policy: quorum
|
||||||
|
frequency: 60
|
||||||
connect_timeout: 2
|
connect_timeout: 2
|
||||||
response_timeout: 10
|
response_timeout: 10
|
||||||
```
|
```
|
||||||
@@ -1053,6 +1053,16 @@ class Ns1Provider(BaseProvider):
|
|||||||
|
|
||||||
return monitor_id, self._feed_create(monitor)
|
return monitor_id, self._feed_create(monitor)
|
||||||
|
|
||||||
|
def _healthcheck_policy(self, record):
|
||||||
|
return record._octodns.get('ns1', {}) \
|
||||||
|
.get('healthcheck', {}) \
|
||||||
|
.get('policy', 'quorum')
|
||||||
|
|
||||||
|
def _healthcheck_frequency(self, record):
|
||||||
|
return record._octodns.get('ns1', {}) \
|
||||||
|
.get('healthcheck', {}) \
|
||||||
|
.get('frequency', 60)
|
||||||
|
|
||||||
def _healthcheck_connect_timeout(self, record):
|
def _healthcheck_connect_timeout(self, record):
|
||||||
return record._octodns.get('ns1', {}) \
|
return record._octodns.get('ns1', {}) \
|
||||||
.get('healthcheck', {}) \
|
.get('healthcheck', {}) \
|
||||||
@@ -1086,14 +1096,14 @@ class Ns1Provider(BaseProvider):
|
|||||||
self._healthcheck_response_timeout(record) * 1000,
|
self._healthcheck_response_timeout(record) * 1000,
|
||||||
'ssl': record.healthcheck_protocol == 'HTTPS',
|
'ssl': record.healthcheck_protocol == 'HTTPS',
|
||||||
},
|
},
|
||||||
'frequency': 60,
|
'frequency': self._healthcheck_frequency(record),
|
||||||
'job_type': 'tcp',
|
'job_type': 'tcp',
|
||||||
'name': f'{host} - {_type} - {value}',
|
'name': f'{host} - {_type} - {value}',
|
||||||
'notes': self._encode_notes({
|
'notes': self._encode_notes({
|
||||||
'host': host,
|
'host': host,
|
||||||
'type': _type,
|
'type': _type,
|
||||||
}),
|
}),
|
||||||
'policy': 'quorum',
|
'policy': self._healthcheck_policy(record),
|
||||||
'rapid_recheck': False,
|
'rapid_recheck': False,
|
||||||
'region_scope': 'fixed',
|
'region_scope': 'fixed',
|
||||||
'regions': self.monitor_regions,
|
'regions': self.monitor_regions,
|
||||||
|
|||||||
@@ -925,6 +925,14 @@ class TestNs1ProviderDynamic(TestCase):
|
|||||||
# No http response expected
|
# No http response expected
|
||||||
self.assertFalse('rules' in monitor)
|
self.assertFalse('rules' in monitor)
|
||||||
|
|
||||||
|
record._octodns['ns1']['healthcheck']['policy'] = 'all'
|
||||||
|
monitor = provider._monitor_gen(record, value)
|
||||||
|
self.assertEquals('all', monitor['policy'])
|
||||||
|
|
||||||
|
record._octodns['ns1']['healthcheck']['frequency'] = 300
|
||||||
|
monitor = provider._monitor_gen(record, value)
|
||||||
|
self.assertEquals(300, monitor['frequency'])
|
||||||
|
|
||||||
record._octodns['ns1']['healthcheck']['connect_timeout'] = 1
|
record._octodns['ns1']['healthcheck']['connect_timeout'] = 1
|
||||||
monitor = provider._monitor_gen(record, value)
|
monitor = provider._monitor_gen(record, value)
|
||||||
self.assertEquals(1000, monitor['config']['connect_timeout'])
|
self.assertEquals(1000, monitor['config']['connect_timeout'])
|
||||||
|
|||||||
Reference in New Issue
Block a user