Browse Source

Route53Provider for CNAME style healthchecks

Note that you can't specify a Host header for these which I believe will
complicate the ability to use this. Figuring that out will have to wait
until I or someone else has a use case for these...
pull/333/head
Ross McFarland 7 years ago
parent
commit
af06dbec09
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 45 additions and 3 deletions
  1. +15
    -3
      octodns/provider/route53.py
  2. +30
    -0
      tests/test_octodns_provider_route53.py

+ 15
- 3
octodns/provider/route53.py View File

@ -9,6 +9,7 @@ from boto3 import client
from botocore.config import Config from botocore.config import Config
from collections import defaultdict from collections import defaultdict
from incf.countryutils.transformations import cca_to_ctca2 from incf.countryutils.transformations import cca_to_ctca2
from ipaddress import AddressValueError, ip_address
from uuid import uuid4 from uuid import uuid4
import logging import logging
import re import re
@ -948,7 +949,15 @@ class Route53Provider(BaseProvider):
self.log.debug('get_health_check_id: fqdn=%s, type=%s, value=%s', self.log.debug('get_health_check_id: fqdn=%s, type=%s, value=%s',
fqdn, record._type, value) fqdn, record._type, value)
healthcheck_host = record.healthcheck_host
try:
ip_address(unicode(value))
# We're working with an IP, host is the Host header
healthcheck_host = record.healthcheck_host
except (AddressValueError, ValueError):
# This isn't an IP, host is the value, value should be None
healthcheck_host = value
value = None
healthcheck_path = record.healthcheck_path healthcheck_path = record.healthcheck_path
healthcheck_protocol = record.healthcheck_protocol healthcheck_protocol = record.healthcheck_protocol
healthcheck_port = record.healthcheck_port healthcheck_port = record.healthcheck_port
@ -983,13 +992,15 @@ class Route53Provider(BaseProvider):
'EnableSNI': healthcheck_protocol == 'HTTPS', 'EnableSNI': healthcheck_protocol == 'HTTPS',
'FailureThreshold': 6, 'FailureThreshold': 6,
'FullyQualifiedDomainName': healthcheck_host, 'FullyQualifiedDomainName': healthcheck_host,
'IPAddress': value,
'MeasureLatency': healthcheck_latency, 'MeasureLatency': healthcheck_latency,
'Port': healthcheck_port, 'Port': healthcheck_port,
'RequestInterval': 10, 'RequestInterval': 10,
'ResourcePath': healthcheck_path, 'ResourcePath': healthcheck_path,
'Type': healthcheck_protocol, 'Type': healthcheck_protocol,
} }
if value:
config['IPAddress'] = value
ref = '{}:{}:{}:{}'.format(self.HEALTH_CHECK_VERSION, record._type, ref = '{}:{}:{}:{}'.format(self.HEALTH_CHECK_VERSION, record._type,
record.fqdn, uuid4().hex[:12]) record.fqdn, uuid4().hex[:12])
resp = self._conn.create_health_check(CallerReference=ref, resp = self._conn.create_health_check(CallerReference=ref,
@ -998,7 +1009,8 @@ class Route53Provider(BaseProvider):
id = health_check['Id'] id = health_check['Id']
# Set a Name for the benefit of the UI # Set a Name for the benefit of the UI
name = '{}:{} - {}'.format(record.fqdn, record._type, value)
name = '{}:{} - {}'.format(record.fqdn, record._type,
value or healthcheck_host)
self._conn.change_tags_for_resource(ResourceType='healthcheck', self._conn.change_tags_for_resource(ResourceType='healthcheck',
ResourceId=id, ResourceId=id,
AddTags=[{ AddTags=[{


+ 30
- 0
tests/test_octodns_provider_route53.py View File

@ -1066,6 +1066,36 @@ class TestRoute53Provider(TestCase):
self.assertEquals('42', id) self.assertEquals('42', id)
stubber.assert_no_pending_responses() stubber.assert_no_pending_responses()
# A CNAME style healthcheck, without a value
health_check_config = {
'EnableSNI': False,
'FailureThreshold': 6,
'FullyQualifiedDomainName': 'target-1.unit.tests.',
'MeasureLatency': True,
'Port': 8080,
'RequestInterval': 10,
'ResourcePath': '/_status',
'Type': 'HTTP'
}
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', {})
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): def test_health_check_measure_latency(self):
provider, stubber = self._get_stubbed_provider() provider, stubber = self._get_stubbed_provider()
record_true = Record.new(self.expected, 'a', { record_true = Record.new(self.expected, 'a', {


Loading…
Cancel
Save