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

Route53 support for healthcheck protocol & port

This commit is contained in:
Ross McFarland
2018-03-31 14:47:22 -07:00
parent e6d8669611
commit b51a9148b8
2 changed files with 59 additions and 13 deletions

View File

@@ -526,11 +526,12 @@ class Route53Provider(BaseProvider):
# We've got a cached version use it
return self._health_checks
def _health_check_equivilent(self, host, path, health_check,
first_value=None):
def _health_check_equivilent(self, host, path, protocol, port,
health_check, first_value=None):
config = health_check['HealthCheckConfig']
return host == config['FullyQualifiedDomainName'] and \
path == config['ResourcePath'] and \
path == config['ResourcePath'] and protocol == config['Type'] \
and port == config['Port'] and \
(first_value is None or first_value == config['IPAddress'])
def get_health_check_id(self, record, ident, geo, create):
@@ -546,6 +547,8 @@ class Route53Provider(BaseProvider):
healthcheck_host = record.healthcheck_host
healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol
healthcheck_port = record.healthcheck_port
# we're looking for a healthcheck with the current version & our record
# type, we'll ignore anything else
@@ -556,7 +559,9 @@ class Route53Provider(BaseProvider):
# not a version & type match, ignore
continue
if self._health_check_equivilent(healthcheck_host,
healthcheck_path, health_check,
healthcheck_path,
healthcheck_protocol,
healthcheck_port, health_check,
first_value=first_value):
# this is the health check we're looking for
return id
@@ -567,15 +572,15 @@ class Route53Provider(BaseProvider):
# no existing matches, we need to create a new health check
config = {
'EnableSNI': True,
'EnableSNI': healthcheck_protocol == 'HTTPS',
'FailureThreshold': 6,
'FullyQualifiedDomainName': healthcheck_host,
'IPAddress': first_value,
'MeasureLatency': True,
'Port': 443,
'Port': healthcheck_port,
'RequestInterval': 10,
'ResourcePath': healthcheck_path,
'Type': 'HTTPS',
'Type': healthcheck_protocol,
}
ref = '{}:{}:{}:{}'.format(self.HEALTH_CHECK_VERSION, record._type,
record.name, uuid4().hex[:16])
@@ -699,6 +704,8 @@ class Route53Provider(BaseProvider):
healthcheck_host = record.healthcheck_host
healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol
healthcheck_port = record.healthcheck_port
fqdn = record.fqdn
# loop through all the r53 rrsets
@@ -718,6 +725,8 @@ class Route53Provider(BaseProvider):
if caller_ref.startswith(self.HEALTH_CHECK_VERSION):
if self._health_check_equivilent(healthcheck_host,
healthcheck_path,
healthcheck_protocol,
healthcheck_port,
health_check):
# it has the right health check
continue

View File

@@ -102,6 +102,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -112,6 +114,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '5.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 42,
}, {
@@ -122,6 +126,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '5.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -132,6 +138,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '7.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -143,6 +151,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '7.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}]
@@ -674,6 +684,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -684,6 +696,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '9.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}]
@@ -704,6 +718,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '8.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}]
@@ -749,6 +765,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -759,6 +777,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}]
@@ -770,16 +790,15 @@ class TestRoute53Provider(TestCase):
})
health_check_config = {
'EnableSNI': True,
'EnableSNI': False,
'FailureThreshold': 6,
'FullyQualifiedDomainName': 'unit.tests',
'FullyQualifiedDomainName': 'foo.bar.com',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'MeasureLatency': True,
'Port': 443,
'Port': 8080,
'RequestInterval': 10,
'ResourcePath': '/_dns',
'Type': 'HTTPS'
'ResourcePath': '/_status',
'Type': 'HTTP'
}
stubber.add_response('create_health_check', {
'HealthCheck': {
@@ -800,6 +819,14 @@ class TestRoute53Provider(TestCase):
'values': ['2.2.3.4', '3.2.3.4'],
'geo': {
'AF': ['4.2.3.4'],
},
'octodns': {
'healthcheck': {
'host': 'foo.bar.com',
'path': '/_status',
'port': 8080,
'protocol': 'HTTP',
},
}
})
@@ -900,6 +927,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -910,6 +939,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}, {
@@ -920,6 +951,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'other.unit.tests',
'IPAddress': '4.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}]
@@ -1094,6 +1127,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'unit.tests',
'IPAddress': '2.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}],
@@ -1195,6 +1230,8 @@ class TestRoute53Provider(TestCase):
'FullyQualifiedDomainName': 'a.unit.tests',
'IPAddress': '2.2.3.4',
'ResourcePath': '/_dns',
'Type': 'HTTPS',
'Port': 443,
},
'HealthCheckVersion': 2,
}],