From b9575ae48439257a187d920790b622829dabd6b3 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Fri, 8 May 2020 08:13:27 -0700 Subject: [PATCH] TCP healthcheck support for Route53 --- octodns/provider/route53.py | 12 +++++++---- tests/test_octodns_provider_route53.py | 29 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/octodns/provider/route53.py b/octodns/provider/route53.py index 3c7b0ed..8e9ee4f 100644 --- a/octodns/provider/route53.py +++ b/octodns/provider/route53.py @@ -1046,8 +1046,11 @@ class Route53Provider(BaseProvider): # No value so give this a None to match value's config_ip_address = None - return host == config['FullyQualifiedDomainName'] and \ - path == config['ResourcePath'] and protocol == config['Type'] \ + fully_qualified_domain_name = config.get('FullyQualifiedDomainName', + None) + resource_path = config.get('ResourcePath', None) + return host == fully_qualified_domain_name and \ + path == resource_path and protocol == config['Type'] \ and port == config['Port'] and \ measure_latency == config['MeasureLatency'] and \ value == config_ip_address @@ -1103,13 +1106,14 @@ class Route53Provider(BaseProvider): config = { 'EnableSNI': healthcheck_protocol == 'HTTPS', 'FailureThreshold': 6, - 'FullyQualifiedDomainName': healthcheck_host, 'MeasureLatency': healthcheck_latency, 'Port': healthcheck_port, 'RequestInterval': 10, - 'ResourcePath': healthcheck_path, 'Type': healthcheck_protocol, } + if healthcheck_protocol != 'TCP': + config['FullyQualifiedDomainName'] = healthcheck_host + config['ResourcePath'] = healthcheck_path if value: config['IPAddress'] = value diff --git a/tests/test_octodns_provider_route53.py b/tests/test_octodns_provider_route53.py index 385b82a..543a506 100644 --- a/tests/test_octodns_provider_route53.py +++ b/tests/test_octodns_provider_route53.py @@ -1213,6 +1213,35 @@ class TestRoute53Provider(TestCase): self.assertEquals('42', id) stubber.assert_no_pending_responses() + # TCP health check + + health_check_config = { + 'EnableSNI': False, + 'FailureThreshold': 6, + 'MeasureLatency': True, + 'Port': 8080, + 'RequestInterval': 10, + 'Type': 'TCP' + } + stubber.add_response('create_health_check', { + 'HealthCheck': { + 'Id': '42', + '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._octodns['healthcheck']['protocol'] = 'TCP' + id = provider.get_health_check_id(record, 'target-1.unit.tests.', True) + self.assertEquals('42', id) + stubber.assert_no_pending_responses() + def test_health_check_measure_latency(self): provider, stubber = self._get_stubbed_provider() record_true = Record.new(self.expected, 'a', {