Browse Source

Fix Templating processor not working on alias zones

pull/1278/head
Jonathan Leroy 5 months ago
parent
commit
3e7cca0c6c
No known key found for this signature in database GPG Key ID: CF226DF21118649E
3 changed files with 17 additions and 1 deletions
  1. +4
    -0
      .changelog/e9b2bb64775a4b88a993bde159330b23.md
  2. +7
    -1
      octodns/manager.py
  3. +6
    -0
      octodns/zone.py

+ 4
- 0
.changelog/e9b2bb64775a4b88a993bde159330b23.md View File

@ -0,0 +1,4 @@
---
type: patch
---
Fix Templating processor not working on alias zones

+ 7
- 1
octodns/manager.py View File

@ -4,6 +4,7 @@
from collections import deque from collections import deque
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from copy import deepcopy
from hashlib import sha256 from hashlib import sha256
from importlib import import_module from importlib import import_module
from importlib.metadata import PackageNotFoundError from importlib.metadata import PackageNotFoundError
@ -500,7 +501,7 @@ class Manager(object):
if desired: if desired:
# This is an alias zone, rather than populate it we'll copy the # This is an alias zone, rather than populate it we'll copy the
# records over from `desired`. # records over from `desired`.
for _, records in desired._records.items():
for _, records in desired._pre_processing_records.items():
for record in records: for record in records:
zone.add_record(record.copy(zone=zone), lenient=lenient) zone.add_record(record.copy(zone=zone), lenient=lenient)
else: else:
@ -520,6 +521,10 @@ class Manager(object):
) )
source.populate(zone) 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: for processor in processors:
zone = processor.process_source_zone(zone, sources=sources) zone = processor.process_source_zone(zone, sources=sources)
@ -690,6 +695,7 @@ class Manager(object):
raise ManagerException(msg) raise ManagerException(msg)
aliased_zones[zone_name] = source_zone aliased_zones[zone_name] = source_zone
self.log.info('sync: alias_of=%s', source_zone)
continue continue
lenient = config.get('lenient', False) lenient = config.get('lenient', False)


+ 6
- 0
octodns/zone.py View File

@ -90,6 +90,12 @@ class Zone(object):
# node that we always store things with Record.name which will be idna # 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 # encoded thus we don't have to deal with idna/utf8 collisions
self._records = defaultdict(set) 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 self._root_ns = None
# optional leading . to match empty hostname # optional leading . to match empty hostname
# optional trailing . b/c some sources don't have it on their fqdn # optional trailing . b/c some sources don't have it on their fqdn


Loading…
Cancel
Save