diff --git a/.changelog/e9b2bb64775a4b88a993bde159330b23.md b/.changelog/e9b2bb64775a4b88a993bde159330b23.md new file mode 100644 index 0000000..b774278 --- /dev/null +++ b/.changelog/e9b2bb64775a4b88a993bde159330b23.md @@ -0,0 +1,4 @@ +--- +type: patch +--- +Fix Templating processor not working on alias zones \ No newline at end of file diff --git a/octodns/manager.py b/octodns/manager.py index a18b255..3b021d1 100644 --- a/octodns/manager.py +++ b/octodns/manager.py @@ -4,6 +4,7 @@ from collections import deque from concurrent.futures import ThreadPoolExecutor +from copy import deepcopy from hashlib import sha256 from importlib import import_module from importlib.metadata import PackageNotFoundError @@ -500,7 +501,7 @@ class Manager(object): if desired: # This is an alias zone, rather than populate it we'll copy the # records over from `desired`. - for _, records in desired._records.items(): + for _, records in desired._pre_processing_records.items(): for record in records: zone.add_record(record.copy(zone=zone), lenient=lenient) else: @@ -520,6 +521,10 @@ class Manager(object): ) source.populate(zone) + # Frozen copy of zone records *before* going through processors so + # alias zone can copy them if needed. + zone._pre_processing_records = deepcopy(zone._records) + for processor in processors: zone = processor.process_source_zone(zone, sources=sources) @@ -690,6 +695,7 @@ class Manager(object): raise ManagerException(msg) aliased_zones[zone_name] = source_zone + self.log.info('sync: alias_of=%s', source_zone) continue lenient = config.get('lenient', False) diff --git a/octodns/zone.py b/octodns/zone.py index a94cda9..2a6d26b 100644 --- a/octodns/zone.py +++ b/octodns/zone.py @@ -90,6 +90,12 @@ class Zone(object): # node that we always store things with Record.name which will be idna # encoded thus we don't have to deal with idna/utf8 collisions self._records = defaultdict(set) + # Frozen copy of populated records set just before calling processors in + # Manager._populate_and_plan(), so alias zones can be populated with + # "raw" records instead of already processed records. + # This is especially useful for processors who changes records based on + # zone/records data like Templating processor. + self._pre_processing_records = None self._root_ns = None # optional leading . to match empty hostname # optional trailing . b/c some sources don't have it on their fqdn