mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
pools used as fallbacks should count as seen
This commit is contained in:
@@ -531,6 +531,7 @@ class _DynamicMixin(object):
|
|||||||
|
|
||||||
pools_exist = set()
|
pools_exist = set()
|
||||||
pools_seen = set()
|
pools_seen = set()
|
||||||
|
pools_seen_as_fallback = set()
|
||||||
if not isinstance(pools, dict):
|
if not isinstance(pools, dict):
|
||||||
reasons.append('pools must be a dict')
|
reasons.append('pools must be a dict')
|
||||||
elif not pools:
|
elif not pools:
|
||||||
@@ -573,9 +574,12 @@ class _DynamicMixin(object):
|
|||||||
'value {}'.format(_id, value_num))
|
'value {}'.format(_id, value_num))
|
||||||
|
|
||||||
fallback = pool.get('fallback', None)
|
fallback = pool.get('fallback', None)
|
||||||
if fallback is not None and fallback not in pools:
|
if fallback is not None:
|
||||||
reasons.append('undefined fallback "{}" for pool "{}"'
|
if fallback in pools:
|
||||||
.format(fallback, _id))
|
pools_seen_as_fallback.add(fallback)
|
||||||
|
else:
|
||||||
|
reasons.append('undefined fallback "{}" for pool "{}"'
|
||||||
|
.format(fallback, _id))
|
||||||
|
|
||||||
# Check for loops
|
# Check for loops
|
||||||
fallback = pools[_id].get('fallback', None)
|
fallback = pools[_id].get('fallback', None)
|
||||||
@@ -644,7 +648,7 @@ class _DynamicMixin(object):
|
|||||||
reasons.extend(GeoCodes.validate(geo, 'rule {} '
|
reasons.extend(GeoCodes.validate(geo, 'rule {} '
|
||||||
.format(rule_num)))
|
.format(rule_num)))
|
||||||
|
|
||||||
unused = pools_exist - pools_seen
|
unused = pools_exist - pools_seen - pools_seen_as_fallback
|
||||||
if unused:
|
if unused:
|
||||||
unused = '", "'.join(sorted(unused))
|
unused = '", "'.join(sorted(unused))
|
||||||
reasons.append('unused pools: "{}"'.format(unused))
|
reasons.append('unused pools: "{}"'.format(unused))
|
||||||
|
|||||||
@@ -109,6 +109,29 @@ cname:
|
|||||||
- pool: iad
|
- pool: iad
|
||||||
type: CNAME
|
type: CNAME
|
||||||
value: target.unit.tests.
|
value: target.unit.tests.
|
||||||
|
pool-only-in-fallback:
|
||||||
|
dynamic:
|
||||||
|
pools:
|
||||||
|
one:
|
||||||
|
fallback: two
|
||||||
|
values:
|
||||||
|
- value: 1.1.1.1
|
||||||
|
three:
|
||||||
|
values:
|
||||||
|
- value: 3.3.3.3
|
||||||
|
two:
|
||||||
|
values:
|
||||||
|
- value: 2.2.2.2
|
||||||
|
rules:
|
||||||
|
- geos:
|
||||||
|
- NA-US
|
||||||
|
pool: one
|
||||||
|
- geos:
|
||||||
|
- AS-SG
|
||||||
|
pool: three
|
||||||
|
ttl: 300
|
||||||
|
type: A
|
||||||
|
values: [4.4.4.4]
|
||||||
real-ish-a:
|
real-ish-a:
|
||||||
dynamic:
|
dynamic:
|
||||||
pools:
|
pools:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class TestYamlProvider(TestCase):
|
|||||||
self.assertEquals(22, len(zone.records))
|
self.assertEquals(22, len(zone.records))
|
||||||
|
|
||||||
source.populate(dynamic_zone)
|
source.populate(dynamic_zone)
|
||||||
self.assertEquals(5, len(dynamic_zone.records))
|
self.assertEquals(6, len(dynamic_zone.records))
|
||||||
|
|
||||||
# Assumption here is that a clean round-trip means that everything
|
# Assumption here is that a clean round-trip means that everything
|
||||||
# worked as expected, data that went in came back out and could be
|
# worked as expected, data that went in came back out and could be
|
||||||
@@ -68,11 +68,11 @@ class TestYamlProvider(TestCase):
|
|||||||
|
|
||||||
# Dynamic plan
|
# Dynamic plan
|
||||||
plan = target.plan(dynamic_zone)
|
plan = target.plan(dynamic_zone)
|
||||||
self.assertEquals(5, len([c for c in plan.changes
|
self.assertEquals(6, len([c for c in plan.changes
|
||||||
if isinstance(c, Create)]))
|
if isinstance(c, Create)]))
|
||||||
self.assertFalse(isfile(dynamic_yaml_file))
|
self.assertFalse(isfile(dynamic_yaml_file))
|
||||||
# Apply it
|
# Apply it
|
||||||
self.assertEquals(5, target.apply(plan))
|
self.assertEquals(6, target.apply(plan))
|
||||||
self.assertTrue(isfile(dynamic_yaml_file))
|
self.assertTrue(isfile(dynamic_yaml_file))
|
||||||
|
|
||||||
# There should be no changes after the round trip
|
# There should be no changes after the round trip
|
||||||
@@ -148,6 +148,10 @@ class TestYamlProvider(TestCase):
|
|||||||
self.assertTrue('value' in dyna)
|
self.assertTrue('value' in dyna)
|
||||||
# self.assertTrue('dynamic' in dyna)
|
# self.assertTrue('dynamic' in dyna)
|
||||||
|
|
||||||
|
dyna = data.pop('pool-only-in-fallback')
|
||||||
|
self.assertTrue('value' in dyna)
|
||||||
|
# self.assertTrue('dynamic' in dyna)
|
||||||
|
|
||||||
# make sure nothing is left
|
# make sure nothing is left
|
||||||
self.assertEquals([], list(data.keys()))
|
self.assertEquals([], list(data.keys()))
|
||||||
|
|
||||||
@@ -397,7 +401,7 @@ class TestOverridingYamlProvider(TestCase):
|
|||||||
# Load the base, should see the 5 records
|
# Load the base, should see the 5 records
|
||||||
base.populate(zone)
|
base.populate(zone)
|
||||||
got = {r.name: r for r in zone.records}
|
got = {r.name: r for r in zone.records}
|
||||||
self.assertEquals(5, len(got))
|
self.assertEquals(6, len(got))
|
||||||
# We get the "dynamic" A from the base config
|
# We get the "dynamic" A from the base config
|
||||||
self.assertTrue('dynamic' in got['a'].data)
|
self.assertTrue('dynamic' in got['a'].data)
|
||||||
# No added
|
# No added
|
||||||
@@ -406,7 +410,7 @@ class TestOverridingYamlProvider(TestCase):
|
|||||||
# Load the overrides, should replace one and add 1
|
# Load the overrides, should replace one and add 1
|
||||||
override.populate(zone)
|
override.populate(zone)
|
||||||
got = {r.name: r for r in zone.records}
|
got = {r.name: r for r in zone.records}
|
||||||
self.assertEquals(6, len(got))
|
self.assertEquals(7, len(got))
|
||||||
# 'a' was replaced with a generic record
|
# 'a' was replaced with a generic record
|
||||||
self.assertEquals({
|
self.assertEquals({
|
||||||
'ttl': 3600,
|
'ttl': 3600,
|
||||||
|
|||||||
Reference in New Issue
Block a user