Browse Source

Rapid recheck for NS1 monitors

pull/817/head
Viranch Mehta 4 years ago
parent
commit
85eeec988c
No known key found for this signature in database GPG Key ID: D83D1392AE9F93B4
3 changed files with 13 additions and 2 deletions
  1. +2
    -0
      docs/dynamic_records.md
  2. +7
    -2
      octodns/provider/ns1.py
  3. +4
    -0
      tests/test_octodns_provider_ns1.py

+ 2
- 0
docs/dynamic_records.md View File

@ -207,6 +207,7 @@ Sonar check regions (sonar_regions) possible values:
| frequency | Frequency (in seconds) of health-check | 60 | | 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 |
| rapid_recheck | Enable or disable a second, automatic verification test before changing the status of a host. Enabling this option can help prevent false positives. | False |
```yaml ```yaml
@ -218,4 +219,5 @@ Sonar check regions (sonar_regions) possible values:
frequency: 60 frequency: 60
connect_timeout: 2 connect_timeout: 2
response_timeout: 10 response_timeout: 10
rapid_recheck: True
``` ```

+ 7
- 2
octodns/provider/ns1.py View File

@ -1068,6 +1068,11 @@ class Ns1Provider(BaseProvider):
.get('healthcheck', {}) \ .get('healthcheck', {}) \
.get('frequency', 60) .get('frequency', 60)
def _healthcheck_rapid_recheck(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('rapid_recheck', False)
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', {}) \
@ -1101,7 +1106,6 @@ 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': 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({
@ -1109,7 +1113,8 @@ class Ns1Provider(BaseProvider):
'type': _type, 'type': _type,
}), }),
'policy': self._healthcheck_policy(record), 'policy': self._healthcheck_policy(record),
'rapid_recheck': False,
'frequency': self._healthcheck_frequency(record),
'rapid_recheck': self._healthcheck_rapid_recheck(record),
'region_scope': 'fixed', 'region_scope': 'fixed',
'regions': self.monitor_regions, 'regions': self.monitor_regions,
} }


+ 4
- 0
tests/test_octodns_provider_ns1.py View File

@ -933,6 +933,10 @@ class TestNs1ProviderDynamic(TestCase):
monitor = provider._monitor_gen(record, value) monitor = provider._monitor_gen(record, value)
self.assertEquals(300, monitor['frequency']) self.assertEquals(300, monitor['frequency'])
record._octodns['ns1']['healthcheck']['rapid_recheck'] = True
monitor = provider._monitor_gen(record, value)
self.assertTrue(monitor['rapid_recheck'])
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'])


Loading…
Cancel
Save