Browse Source

Merge pull request #244 from github/children-first

Apply sub-zones before parents
pull/247/head
Ross McFarland 8 years ago
committed by GitHub
parent
commit
118cd32ef4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      octodns/manager.py

+ 12
- 0
octodns/manager.py View File

@ -65,6 +65,11 @@ class MainThreadExecutor(object):
class Manager(object): class Manager(object):
log = logging.getLogger('Manager') log = logging.getLogger('Manager')
@classmethod
def _plan_keyer(cls, p):
plan = p[1]
return len(plan.changes[0].record.zone.name) if plan.changes else 0
def __init__(self, config_file, max_workers=None, include_meta=False): def __init__(self, config_file, max_workers=None, include_meta=False):
self.log.info('__init__: config_file=%s', config_file) self.log.info('__init__: config_file=%s', config_file)
@ -288,6 +293,13 @@ class Manager(object):
# plan pairs. # plan pairs.
plans = [p for f in futures for p in f.result()] plans = [p for f in futures for p in f.result()]
# Best effort sort plans children first so that we create/update
# children zones before parents which should allow us to more safely
# extract things into sub-zones. Combining a child back into a parent
# can't really be done all that safely in general so we'll optimize for
# this direction.
plans.sort(key=self._plan_keyer, reverse=True)
for output in self.plan_outputs.values(): for output in self.plan_outputs.values():
output.run(plans=plans, log=self.log) output.run(plans=plans, log=self.log)


Loading…
Cancel
Save