mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Go head and support cleaning up v0000 Route53 health check versions
This commit is contained in:
@@ -500,6 +500,10 @@ class Route53Provider(BaseProvider):
|
||||
# use
|
||||
expected_re = re.compile(r'^\d\d\d\d:{}:{}:'
|
||||
.format(record._type, record.name))
|
||||
# Until the v1.0 release we'll clean out the previous version of
|
||||
# Route53 health checks as best as we can.
|
||||
expected_legacy_host = record.fqdn[:-1]
|
||||
expected_legacy = '0000:{}:'.format(record._type)
|
||||
for id, health_check in self.health_checks.items():
|
||||
ref = health_check['CallerReference']
|
||||
if expected_re.match(ref) and id not in in_use:
|
||||
@@ -507,6 +511,12 @@ class Route53Provider(BaseProvider):
|
||||
# planning to use going forward
|
||||
self.log.info('_gc_health_checks: deleting id=%s', id)
|
||||
self._conn.delete_health_check(HealthCheckId=id)
|
||||
elif ref.startswith(expected_legacy):
|
||||
config = health_check['HealthCheckConfig']
|
||||
if expected_legacy_host == config['FullyQualifiedDomainName']:
|
||||
self.log.info('_gc_health_checks: deleting legacy id=%s',
|
||||
id)
|
||||
self._conn.delete_health_check(HealthCheckId=id)
|
||||
|
||||
def _gen_records(self, record, creating=False):
|
||||
'''
|
||||
|
||||
@@ -18,6 +18,12 @@ from octodns.zone import Zone
|
||||
from helpers import GeoProvider
|
||||
|
||||
|
||||
class DummyR53Record(object):
|
||||
|
||||
def __init__(self, health_check_id):
|
||||
self.health_check_id = health_check_id
|
||||
|
||||
|
||||
class TestOctalReplace(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
@@ -807,18 +813,13 @@ class TestRoute53Provider(TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
class DummyRecord(object):
|
||||
|
||||
def __init__(self, health_check_id):
|
||||
self.health_check_id = health_check_id
|
||||
|
||||
# gc no longer in_use records (directly)
|
||||
stubber.add_response('delete_health_check', {}, {
|
||||
'HealthCheckId': '44',
|
||||
})
|
||||
provider._gc_health_checks(record, [
|
||||
DummyRecord('42'),
|
||||
DummyRecord('43'),
|
||||
DummyR53Record('42'),
|
||||
DummyR53Record('43'),
|
||||
])
|
||||
stubber.assert_no_pending_responses()
|
||||
|
||||
@@ -866,6 +867,71 @@ class TestRoute53Provider(TestCase):
|
||||
provider._gc_health_checks(record, [])
|
||||
stubber.assert_no_pending_responses()
|
||||
|
||||
def test_legacy_health_check_gc(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
old_caller_ref = '0000:A:3333'
|
||||
health_checks = [{
|
||||
'Id': '42',
|
||||
'CallerReference': self.caller_ref,
|
||||
'HealthCheckConfig': {
|
||||
'Type': 'HTTPS',
|
||||
'FullyQualifiedDomainName': 'unit.tests',
|
||||
'IPAddress': '4.2.3.4',
|
||||
'ResourcePath': '/_dns',
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
'Id': '43',
|
||||
'CallerReference': old_caller_ref,
|
||||
'HealthCheckConfig': {
|
||||
'Type': 'HTTPS',
|
||||
'FullyQualifiedDomainName': 'unit.tests',
|
||||
'IPAddress': '4.2.3.4',
|
||||
'ResourcePath': '/_dns',
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}, {
|
||||
'Id': '44',
|
||||
'CallerReference': old_caller_ref,
|
||||
'HealthCheckConfig': {
|
||||
'Type': 'HTTPS',
|
||||
'FullyQualifiedDomainName': 'other.unit.tests',
|
||||
'IPAddress': '4.2.3.4',
|
||||
'ResourcePath': '/_dns',
|
||||
},
|
||||
'HealthCheckVersion': 2,
|
||||
}]
|
||||
|
||||
stubber.add_response('list_health_checks', {
|
||||
'HealthChecks': health_checks,
|
||||
'IsTruncated': False,
|
||||
'MaxItems': '100',
|
||||
'Marker': '',
|
||||
})
|
||||
|
||||
# No changes to the record itself
|
||||
record = Record.new(self.expected, '', {
|
||||
'ttl': 61,
|
||||
'type': 'A',
|
||||
'values': ['2.2.3.4', '3.2.3.4'],
|
||||
'geo': {
|
||||
'AF': ['4.2.3.4'],
|
||||
'NA-US': ['5.2.3.4', '6.2.3.4'],
|
||||
'NA-US-CA': ['7.2.3.4']
|
||||
}
|
||||
})
|
||||
|
||||
# Expect to delete the legacy hc for our record, but not touch the new
|
||||
# one or the other legacy record
|
||||
stubber.add_response('delete_health_check', {}, {
|
||||
'HealthCheckId': '43',
|
||||
})
|
||||
|
||||
provider._gc_health_checks(record, [
|
||||
DummyR53Record('42'),
|
||||
])
|
||||
|
||||
def test_no_extra_changes(self):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user