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

Add customizable NS1 monitor tcp timout settings

This commit is contained in:
Benjamin Kane
2021-10-27 09:04:50 -07:00
parent 0be6a2b74a
commit dd45f74d30
2 changed files with 29 additions and 3 deletions

View File

@@ -1053,6 +1053,16 @@ class Ns1Provider(BaseProvider):
return monitor_id, self._feed_create(monitor)
def _healthcheck_tcp_connect_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_connect_timeout', 2000)
def _healthcheck_tcp_response_timeout(self, record):
return record._octodns.get('ns1', {}) \
.get('healthcheck', {}) \
.get('tcp_response_timeout', 10000)
def _monitor_gen(self, record, value):
host = record.fqdn[:-1]
_type = record._type
@@ -1064,10 +1074,12 @@ class Ns1Provider(BaseProvider):
ret = {
'active': True,
'config': {
'connect_timeout': 2000,
'connect_timeout':
self._healthcheck_tcp_connect_timeout(record),
'host': value,
'port': record.healthcheck_port,
'response_timeout': 10000,
'response_timeout':
self._healthcheck_tcp_response_timeout(record),
'ssl': record.healthcheck_protocol == 'HTTPS',
},
'frequency': 60,

View File

@@ -599,7 +599,13 @@ class TestNs1ProviderDynamic(TestCase):
'path': '/_ping',
'port': 80,
'protocol': 'HTTP',
}
},
'ns1': {
'healthcheck': {
'tcp_connect_timeout': 5000,
'tcp_response_timeout': 6000,
},
},
},
'ttl': 32,
'type': 'A',
@@ -919,6 +925,14 @@ class TestNs1ProviderDynamic(TestCase):
# No http response expected
self.assertFalse('rules' in monitor)
record._octodns['ns1']['healthcheck']['tcp_connect_timeout'] = 1234
monitor = provider._monitor_gen(record, value)
self.assertEquals(1234, monitor['config']['connect_timeout'])
record._octodns['ns1']['healthcheck']['tcp_response_timeout'] = 5678
monitor = provider._monitor_gen(record, value)
self.assertEquals(5678, monitor['config']['response_timeout'])
def test_monitor_gen_AAAA(self):
provider = Ns1Provider('test', 'api-key')