1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Add policy and frequency params for NS1 health-checks

This commit is contained in:
Viranch Mehta
2021-11-01 14:48:33 -07:00
parent 61c34cdd3e
commit 264cd22e60
3 changed files with 25 additions and 3 deletions

View File

@@ -203,8 +203,10 @@ Sonar check regions (sonar_regions) possible values:
| 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 |
| 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
@@ -212,6 +214,8 @@ Sonar check regions (sonar_regions) possible values:
octodns:
ns1:
healthcheck:
policy: quorum
frequency: 60
connect_timeout: 2
response_timeout: 10
```

View File

@@ -1053,6 +1053,16 @@ class Ns1Provider(BaseProvider):
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):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
@@ -1086,14 +1096,14 @@ class Ns1Provider(BaseProvider):
self._healthcheck_response_timeout(record) * 1000,
'ssl': record.healthcheck_protocol == 'HTTPS',
},
'frequency': 60,
'frequency': self._healthcheck_frequency(record),
'job_type': 'tcp',
'name': f'{host} - {_type} - {value}',
'notes': self._encode_notes({
'host': host,
'type': _type,
}),
'policy': 'quorum',
'policy': self._healthcheck_policy(record),
'rapid_recheck': False,
'region_scope': 'fixed',
'regions': self.monitor_regions,

View File

@@ -925,6 +925,14 @@ class TestNs1ProviderDynamic(TestCase):
# No http response expected
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
monitor = provider._monitor_gen(record, value)
self.assertEquals(1000, monitor['config']['connect_timeout'])