Browse Source

Merge pull request #362 from github/rework-route53-dynamic-extra-hc-verify

Rework route53 dynamic extra hc verify
pull/366/head
Ross McFarland 7 years ago
committed by GitHub
parent
commit
c313ae38ae
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 7 deletions
  1. +16
    -4
      octodns/provider/route53.py
  2. +38
    -3
      tests/test_octodns_provider_route53.py

+ 16
- 4
octodns/provider/route53.py View File

@ -1250,15 +1250,27 @@ class Route53Provider(BaseProvider):
'%s', record.fqdn, record._type) '%s', record.fqdn, record._type)
fqdn = record.fqdn fqdn = record.fqdn
_type = record._type
# loop through all the r53 rrsets # loop through all the r53 rrsets
for rrset in self._load_records(zone_id): for rrset in self._load_records(zone_id):
name = rrset['Name'] name = rrset['Name']
# Break off the first piece of the name, it'll let us figure out if
# this is an rrset we're interested in.
maybe_meta, rest = name.split('.', 1)
if not maybe_meta.startswith('_octodns-') or \
not maybe_meta.endswith('-value') or \
'-default-' in name:
# We're only interested in non-default dynamic value records,
# as that's where healthchecks live
continue
if rest != fqdn or _type != rrset['Type']:
# rrset isn't for the current record
continue
if record._type == rrset['Type'] and name.endswith(fqdn) and \
name.startswith('_octodns-') and '-value.' in name and \
'-default-' not in name and \
self._extra_changes_update_needed(record, rrset):
if self._extra_changes_update_needed(record, rrset):
# no good, doesn't have the right health check, needs an update # no good, doesn't have the right health check, needs an update
self.log.info('_extra_changes_dynamic_needs_update: ' self.log.info('_extra_changes_dynamic_needs_update: '
'health-check caused update of %s:%s', 'health-check caused update of %s:%s',


+ 38
- 3
tests/test_octodns_provider_route53.py View File

@ -1673,7 +1673,7 @@ class TestRoute53Provider(TestCase):
desired.add_record(record) desired.add_record(record)
list_resource_record_sets_resp = { list_resource_record_sets_resp = {
'ResourceRecordSets': [{ 'ResourceRecordSets': [{
# other name
# Not dynamic value and other name
'Name': 'unit.tests.', 'Name': 'unit.tests.',
'Type': 'A', 'Type': 'A',
'GeoLocation': { 'GeoLocation': {
@ -1683,17 +1683,21 @@ class TestRoute53Provider(TestCase):
'Value': '1.2.3.4', 'Value': '1.2.3.4',
}], }],
'TTL': 61, 'TTL': 61,
# All the non-matches have a different Id so we'll fail if they
# match
'HealthCheckId': '33',
}, { }, {
# matching name, other type
# Not dynamic value, matching name, other type
'Name': 'a.unit.tests.', 'Name': 'a.unit.tests.',
'Type': 'AAAA', 'Type': 'AAAA',
'ResourceRecords': [{ 'ResourceRecords': [{
'Value': '2001:0db8:3c4d:0015:0000:0000:1a2f:1a4b' 'Value': '2001:0db8:3c4d:0015:0000:0000:1a2f:1a4b'
}], }],
'TTL': 61, 'TTL': 61,
'HealthCheckId': '33',
}, { }, {
# default value pool # default value pool
'Name': '_octodns-default-pool.a.unit.tests.',
'Name': '_octodns-default-value.a.unit.tests.',
'Type': 'A', 'Type': 'A',
'GeoLocation': { 'GeoLocation': {
'CountryCode': '*', 'CountryCode': '*',
@ -1702,6 +1706,37 @@ class TestRoute53Provider(TestCase):
'Value': '1.2.3.4', 'Value': '1.2.3.4',
}], }],
'TTL': 61, 'TTL': 61,
'HealthCheckId': '33',
}, {
# different record
'Name': '_octodns-two-value.other.unit.tests.',
'Type': 'A',
'GeoLocation': {
'CountryCode': '*',
},
'ResourceRecords': [{
'Value': '1.2.3.4',
}],
'TTL': 61,
'HealthCheckId': '33',
}, {
# same everything, but different type
'Name': '_octodns-one-value.a.unit.tests.',
'Type': 'AAAA',
'ResourceRecords': [{
'Value': '2001:0db8:3c4d:0015:0000:0000:1a2f:1a4b'
}],
'TTL': 61,
'HealthCheckId': '33',
}, {
# same everything, sub
'Name': '_octodns-one-value.sub.a.unit.tests.',
'Type': 'A',
'ResourceRecords': [{
'Value': '1.2.3.4',
}],
'TTL': 61,
'HealthCheckId': '33',
}, { }, {
# match # match
'Name': '_octodns-one-value.a.unit.tests.', 'Name': '_octodns-one-value.a.unit.tests.',


Loading…
Cancel
Save