From 2b454ccc229f14fccf2246a152a41721230a88f7 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Fri, 27 Nov 2020 21:36:50 +0100 Subject: [PATCH] manager: error when an alias zone is synced without its source Signed-off-by: Marc 'risson' Schmitt --- octodns/manager.py | 9 ++++++++- tests/test_octodns_manager.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/octodns/manager.py b/octodns/manager.py index 9283d19..6c05a55 100644 --- a/octodns/manager.py +++ b/octodns/manager.py @@ -375,12 +375,19 @@ class Manager(object): futures = [] for zone_name, zone_source in aliased_zones.items(): source_config = self.config['zones'][zone_source] + print(source_config) + try: + desired_config = desired[zone_source] + except KeyError: + raise ManagerException('Zone {} cannot be sync without zone ' + '{} sinced it is aliased' + .format(zone_name, zone_source)) futures.append(self._executor.submit( self._populate_and_plan, zone_name, [], [self.providers[t] for t in source_config['targets']], - desired=desired[zone_source], + desired=desired_config, lenient=lenient )) diff --git a/tests/test_octodns_manager.py b/tests/test_octodns_manager.py index 4e1a756..f757466 100644 --- a/tests/test_octodns_manager.py +++ b/tests/test_octodns_manager.py @@ -191,6 +191,14 @@ class TestManager(TestCase): 'zone alias.tests. is an alias zone', text_type(ctx.exception)) + # Sync an alias without the zone it refers to + with self.assertRaises(ManagerException) as ctx: + tc = Manager(get_config_filename('simple-alias-zone.yaml')) \ + .sync(eligible_zones=["alias.tests."]) + self.assertEquals('Zone alias.tests. cannot be sync without zone ' + 'unit.tests. sinced it is aliased', + text_type(ctx.exception)) + def test_compare(self): with TemporaryDirectory() as tmpdir: environ['YAML_TMP_DIR'] = tmpdir.dirname