Merge branch 'master' into azuredns-reused-pool

This commit is contained in:
Ross McFarland
2021-06-14 19:19:33 -07:00
committed by GitHub
9 changed files with 65 additions and 19 deletions
+1 -1
View File
@@ -282,7 +282,7 @@ def _get_monitor(record):
port=record.healthcheck_port,
path=record.healthcheck_path,
)
host = record.healthcheck_host
host = record.healthcheck_host()
if host:
monitor.custom_headers = [MonitorConfigCustomHeadersItem(
name='Host', value=host
+4 -4
View File
@@ -705,7 +705,7 @@ class DynProvider(BaseProvider):
label)
extra.append(Update(record, record))
continue
if _monitor_doesnt_match(monitor, record.healthcheck_host,
if _monitor_doesnt_match(monitor, record.healthcheck_host(),
record.healthcheck_path,
record.healthcheck_protocol,
record.healthcheck_port):
@@ -828,13 +828,13 @@ class DynProvider(BaseProvider):
self.traffic_director_monitors[label] = \
self.traffic_director_monitors[fqdn]
del self.traffic_director_monitors[fqdn]
if _monitor_doesnt_match(monitor, record.healthcheck_host,
if _monitor_doesnt_match(monitor, record.healthcheck_host(),
record.healthcheck_path,
record.healthcheck_protocol,
record.healthcheck_port):
self.log.info('_traffic_director_monitor: updating monitor '
'for %s', label)
monitor.update(record.healthcheck_host,
monitor.update(record.healthcheck_host(),
record.healthcheck_path,
record.healthcheck_protocol,
record.healthcheck_port)
@@ -845,7 +845,7 @@ class DynProvider(BaseProvider):
monitor = DSFMonitor(label, protocol=record.healthcheck_protocol,
response_count=2, probe_interval=60,
retries=2, port=record.healthcheck_port,
active='Y', host=record.healthcheck_host,
active='Y', host=record.healthcheck_host(),
timeout=self.MONITOR_TIMEOUT,
header=self.MONITOR_HEADER,
path=record.healthcheck_path)
+1 -1
View File
@@ -929,7 +929,7 @@ class Ns1Provider(BaseProvider):
if record.healthcheck_protocol != 'TCP':
# IF it's HTTP we need to send the request string
path = record.healthcheck_path
host = record.healthcheck_host
host = record.healthcheck_host(value=value)
request = r'GET {path} HTTP/1.0\r\nHost: {host}\r\n' \
r'User-agent: NS1\r\n\r\n'.format(path=path, host=host)
ret['config']['send'] = request
+2 -2
View File
@@ -1084,7 +1084,7 @@ class Route53Provider(BaseProvider):
try:
ip_address(text_type(value))
# We're working with an IP, host is the Host header
healthcheck_host = record.healthcheck_host
healthcheck_host = record.healthcheck_host(value=value)
except (AddressValueError, ValueError):
# This isn't an IP, host is the value, value should be None
healthcheck_host = value
@@ -1257,7 +1257,7 @@ class Route53Provider(BaseProvider):
# For CNAME, healthcheck host by default points to the CNAME value
healthcheck_host = rrset['ResourceRecords'][0]['Value']
else:
healthcheck_host = record.healthcheck_host
healthcheck_host = record.healthcheck_host()
healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol
+2 -6
View File
@@ -183,15 +183,11 @@ class Record(EqualityTupleMixin):
def included(self):
return self._octodns.get('included', [])
@property
def healthcheck_host(self):
def healthcheck_host(self, value=None):
healthcheck = self._octodns.get('healthcheck', {})
if healthcheck.get('protocol', None) == 'TCP':
return None
try:
return healthcheck['host']
except KeyError:
return self.fqdn[:-1]
return healthcheck.get('host', self.fqdn[:-1]) or value
@property
def healthcheck_path(self):
+1 -1
View File
@@ -432,7 +432,7 @@ class Test_GetMonitor(TestCase):
self.assertEquals(len(headers), 1)
headers = headers[0]
self.assertEqual(headers.name, 'Host')
self.assertEqual(headers.value, record.healthcheck_host)
self.assertEqual(headers.value, record.healthcheck_host())
# test TCP monitor
record._octodns['healthcheck']['protocol'] = 'TCP'
+4
View File
@@ -757,6 +757,10 @@ class TestNs1ProviderDynamic(TestCase):
self.assertFalse(monitor['config']['ssl'])
self.assertEquals('host:unit.tests type:A', monitor['notes'])
record._octodns['healthcheck']['host'] = None
monitor = provider._monitor_gen(record, value)
self.assertTrue(r'\nHost: 3.4.5.6\r' in monitor['config']['send'])
record._octodns['healthcheck']['protocol'] = 'HTTPS'
monitor = provider._monitor_gen(record, value)
self.assertTrue(monitor['config']['ssl'])
+30
View File
@@ -1166,6 +1166,31 @@ class TestRoute53Provider(TestCase):
})
stubber.add_response('change_tags_for_resource', {})
health_check_config = {
'EnableSNI': False,
'FailureThreshold': 6,
'FullyQualifiedDomainName': '4.2.3.4',
'IPAddress': '4.2.3.4',
'MeasureLatency': True,
'Port': 8080,
'RequestInterval': 10,
'ResourcePath': '/_status',
'Type': 'HTTP'
}
stubber.add_response('create_health_check', {
'HealthCheck': {
'Id': '43',
'CallerReference': self.caller_ref,
'HealthCheckConfig': health_check_config,
'HealthCheckVersion': 1,
},
'Location': 'http://url',
}, {
'CallerReference': ANY,
'HealthCheckConfig': health_check_config,
})
stubber.add_response('change_tags_for_resource', {})
record = Record.new(self.expected, '', {
'ttl': 61,
'type': 'A',
@@ -1191,6 +1216,11 @@ class TestRoute53Provider(TestCase):
# when allowed to create we do
id = provider.get_health_check_id(record, value, True)
self.assertEquals('42', id)
# when allowed to create and when host is None
record._octodns['healthcheck']['host'] = None
id = provider.get_health_check_id(record, value, True)
self.assertEquals('43', id)
stubber.assert_no_pending_responses()
# A CNAME style healthcheck, without a value
+20 -4
View File
@@ -1015,17 +1015,33 @@ class TestRecord(TestCase):
}
})
self.assertEquals('/_ready', new.healthcheck_path)
self.assertEquals('bleep.bloop', new.healthcheck_host)
self.assertEquals('bleep.bloop', new.healthcheck_host())
self.assertEquals('HTTP', new.healthcheck_protocol)
self.assertEquals(8080, new.healthcheck_port)
# empty host value in healthcheck
new = Record.new(self.zone, 'a', {
'ttl': 44,
'type': 'A',
'value': '1.2.3.4',
'octodns': {
'healthcheck': {
'path': '/_ready',
'host': None,
'protocol': 'HTTP',
'port': 8080,
}
}
})
self.assertEquals('1.2.3.4', new.healthcheck_host(value="1.2.3.4"))
new = Record.new(self.zone, 'a', {
'ttl': 44,
'type': 'A',
'value': '1.2.3.4',
})
self.assertEquals('/_dns', new.healthcheck_path)
self.assertEquals('a.unit.tests', new.healthcheck_host)
self.assertEquals('a.unit.tests', new.healthcheck_host())
self.assertEquals('HTTPS', new.healthcheck_protocol)
self.assertEquals(443, new.healthcheck_port)
@@ -1044,7 +1060,7 @@ class TestRecord(TestCase):
}
})
self.assertIsNone(new.healthcheck_path)
self.assertIsNone(new.healthcheck_host)
self.assertIsNone(new.healthcheck_host())
self.assertEquals('TCP', new.healthcheck_protocol)
self.assertEquals(8080, new.healthcheck_port)
@@ -1059,7 +1075,7 @@ class TestRecord(TestCase):
}
})
self.assertIsNone(new.healthcheck_path)
self.assertIsNone(new.healthcheck_host)
self.assertIsNone(new.healthcheck_host())
self.assertEquals('TCP', new.healthcheck_protocol)
self.assertEquals(443, new.healthcheck_port)