Browse Source

Add policy and frequency params for NS1 health-checks

pull/807/head
Viranch Mehta 4 years ago
parent
commit
264cd22e60
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
3 changed files with 25 additions and 3 deletions
  1. +5
    -1
      docs/dynamic_records.md
  2. +12
    -2
      octodns/provider/ns1.py
  3. +8
    -0
      tests/test_octodns_provider_ns1.py

+ 5
- 1
docs/dynamic_records.md 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
```

+ 12
- 2
octodns/provider/ns1.py 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,


+ 8
- 0
tests/test_octodns_provider_ns1.py 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'])


Loading…
Cancel
Save