Browse Source

Rename timeouts and make the default seconds. Add docs.

pull/806/head
Benjamin Kane 4 years ago
parent
commit
de76ee0fd6
3 changed files with 33 additions and 12 deletions
  1. +17
    -0
      docs/dynamic_records.md
  2. +10
    -6
      octodns/provider/ns1.py
  3. +6
    -6
      tests/test_octodns_provider_ns1.py

+ 17
- 0
docs/dynamic_records.md View File

@ -198,3 +198,20 @@ Sonar check regions (sonar_regions) possible values:
- EUROPE
sonar_type: TCP
```
#### NS1 Health Check Options
| Key | Description | Default |
|--|--|--|
| 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 |
```yaml
---
octodns:
ns1:
healthcheck:
connect_timeout: 2
response_timeout: 10
```

+ 10
- 6
octodns/provider/ns1.py View File

@ -1053,15 +1053,15 @@ class Ns1Provider(BaseProvider):
return monitor_id, self._feed_create(monitor)
def _healthcheck_tcp_connect_timeout(self, record):
def _healthcheck_connect_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_connect_timeout', 2000)
.get('connect_timeout', 2)
def _healthcheck_tcp_response_timeout(self, record):
def _healthcheck_response_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_response_timeout', 10000)
.get('response_timeout', 10)
def _monitor_gen(self, record, value):
host = record.fqdn[:-1]
@ -1075,11 +1075,15 @@ class Ns1Provider(BaseProvider):
'active': True,
'config': {
'connect_timeout':
self._healthcheck_tcp_connect_timeout(record),
# TCP monitors use milliseconds, so convert from
# seconds to milliseconds
self._healthcheck_connect_timeout(record) * 1000,
'host': value,
'port': record.healthcheck_port,
'response_timeout':
self._healthcheck_tcp_response_timeout(record),
# TCP monitors use milliseconds, so convert from
# seconds to milliseconds
self._healthcheck_response_timeout(record) * 1000,
'ssl': record.healthcheck_protocol == 'HTTPS',
},
'frequency': 60,


+ 6
- 6
tests/test_octodns_provider_ns1.py View File

@ -602,8 +602,8 @@ class TestNs1ProviderDynamic(TestCase):
},
'ns1': {
'healthcheck': {
'tcp_connect_timeout': 5000,
'tcp_response_timeout': 6000,
'connect_timeout': 5,
'response_timeout': 6,
},
},
},
@ -925,13 +925,13 @@ class TestNs1ProviderDynamic(TestCase):
# No http response expected
self.assertFalse('rules' in monitor)
record._octodns['ns1']['healthcheck']['tcp_connect_timeout'] = 1234
record._octodns['ns1']['healthcheck']['connect_timeout'] = 1
monitor = provider._monitor_gen(record, value)
self.assertEquals(1234, monitor['config']['connect_timeout'])
self.assertEquals(1000, monitor['config']['connect_timeout'])
record._octodns['ns1']['healthcheck']['tcp_response_timeout'] = 5678
record._octodns['ns1']['healthcheck']['response_timeout'] = 2
monitor = provider._monitor_gen(record, value)
self.assertEquals(5678, monitor['config']['response_timeout'])
self.assertEquals(2000, monitor['config']['response_timeout'])
def test_monitor_gen_AAAA(self):
provider = Ns1Provider('test', 'api-key')


Loading…
Cancel
Save