mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #806 from bkane-msft/bkane/ns1_monitor_tcp_timeouts
Bkane/ns1 monitor tcp timeouts
This commit is contained in:
@@ -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
|
||||
```
|
||||
@@ -1053,6 +1053,16 @@ class Ns1Provider(BaseProvider):
|
||||
|
||||
return monitor_id, self._feed_create(monitor)
|
||||
|
||||
def _healthcheck_connect_timeout(self, record):
|
||||
return record._octodns.get('ns1', {}) \
|
||||
.get('healthcheck', {}) \
|
||||
.get('connect_timeout', 2)
|
||||
|
||||
def _healthcheck_response_timeout(self, record):
|
||||
return record._octodns.get('ns1', {}) \
|
||||
.get('healthcheck', {}) \
|
||||
.get('response_timeout', 10)
|
||||
|
||||
def _monitor_gen(self, record, value):
|
||||
host = record.fqdn[:-1]
|
||||
_type = record._type
|
||||
@@ -1064,10 +1074,16 @@ class Ns1Provider(BaseProvider):
|
||||
ret = {
|
||||
'active': True,
|
||||
'config': {
|
||||
'connect_timeout': 2000,
|
||||
'connect_timeout':
|
||||
# TCP monitors use milliseconds, so convert from
|
||||
# seconds to milliseconds
|
||||
self._healthcheck_connect_timeout(record) * 1000,
|
||||
'host': value,
|
||||
'port': record.healthcheck_port,
|
||||
'response_timeout': 10000,
|
||||
'response_timeout':
|
||||
# TCP monitors use milliseconds, so convert from
|
||||
# seconds to milliseconds
|
||||
self._healthcheck_response_timeout(record) * 1000,
|
||||
'ssl': record.healthcheck_protocol == 'HTTPS',
|
||||
},
|
||||
'frequency': 60,
|
||||
|
||||
@@ -599,7 +599,13 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
'path': '/_ping',
|
||||
'port': 80,
|
||||
'protocol': 'HTTP',
|
||||
}
|
||||
},
|
||||
'ns1': {
|
||||
'healthcheck': {
|
||||
'connect_timeout': 5,
|
||||
'response_timeout': 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
'ttl': 32,
|
||||
'type': 'A',
|
||||
@@ -919,6 +925,14 @@ class TestNs1ProviderDynamic(TestCase):
|
||||
# No http response expected
|
||||
self.assertFalse('rules' in monitor)
|
||||
|
||||
record._octodns['ns1']['healthcheck']['connect_timeout'] = 1
|
||||
monitor = provider._monitor_gen(record, value)
|
||||
self.assertEquals(1000, monitor['config']['connect_timeout'])
|
||||
|
||||
record._octodns['ns1']['healthcheck']['response_timeout'] = 2
|
||||
monitor = provider._monitor_gen(record, value)
|
||||
self.assertEquals(2000, monitor['config']['response_timeout'])
|
||||
|
||||
def test_monitor_gen_AAAA(self):
|
||||
provider = Ns1Provider('test', 'api-key')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user