Browse Source

Fix bug in MetaProcessor up to date record check

pull/1122/head
Ross McFarland 2 years ago
parent
commit
b8dab67d6a
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 34 additions and 9 deletions
  1. +2
    -0
      CHANGELOG.md
  2. +9
    -4
      octodns/processor/meta.py
  3. +23
    -5
      tests/test_octodns_processor_meta.py

+ 2
- 0
CHANGELOG.md View File

@ -1,5 +1,7 @@
## v1.?.0 - 2023-??-?? -
* Fix for bug in MetaProcessor _up_to_date check that was failing when there was
a plan with a single change type with a single value, e.g. CNAME.
* Support added for config env variable expansion on nested levels, not just
top-level provider/processor keys


+ 9
- 4
octodns/processor/meta.py View File

@ -131,18 +131,23 @@ class MetaProcessor(BaseProcessor):
return desired, existing
def _up_to_date(self, change):
def _is_up_to_date_meta(self, change):
# always something so we can see if its type and name
record = change.record
# existing state, if there is one
existing = getattr(change, 'existing', None)
return existing is not None and _keys(existing.values) == _keys(
self.values
return (
record._type == 'TXT'
and record.name == self.record_name
and existing is not None
and _keys(existing.values) == _keys(self.values)
)
def process_plan(self, plan, sources, target):
if (
plan
and len(plan.changes) == 1
and self._up_to_date(plan.changes[0])
and self._is_up_to_date_meta(plan.changes[0])
):
# the only change is the meta record, and it's not meaningfully
# changing so we don't actually want to make the change


+ 23
- 5
tests/test_octodns_processor_meta.py View File

@ -48,6 +48,12 @@ class TestMetaProcessor(TestCase):
},
)
not_txt = Record.new(
zone,
'cname',
{'type': 'CNAME', 'ttl': 61, 'value': 'points.to.something.'},
)
@patch('octodns.processor.meta.MetaProcessor.now')
@patch('octodns.processor.meta.MetaProcessor.uuid')
def test_args_and_values(self, uuid_mock, now_mock):
@ -101,16 +107,28 @@ class TestMetaProcessor(TestCase):
# uuid's have 4 -
self.assertEqual(4, proc.values[0].count('-'))
def test_up_to_date(self):
def test_is_up_to_date_meta(self):
proc = MetaProcessor('test')
# Creates always need to happen
self.assertFalse(proc._up_to_date(Create(self.meta_needs_update)))
self.assertFalse(proc._up_to_date(Create(self.meta_up_to_date)))
self.assertFalse(
proc._is_up_to_date_meta(Create(self.meta_needs_update))
)
self.assertFalse(proc._is_up_to_date_meta(Create(self.meta_up_to_date)))
# Updates depend on the contents
self.assertFalse(proc._up_to_date(Update(self.meta_needs_update, None)))
self.assertTrue(proc._up_to_date(Update(self.meta_up_to_date, None)))
self.assertFalse(
proc._is_up_to_date_meta(Update(self.meta_needs_update, None))
)
self.assertTrue(
proc._is_up_to_date_meta(Update(self.meta_up_to_date, None))
)
# not a meta txt
self.assertFalse(proc._is_up_to_date_meta(Update(self.not_meta, None)))
# not even a txt record
self.assertFalse(proc._is_up_to_date_meta(Update(self.not_txt, None)))
@patch('octodns.processor.meta.MetaProcessor.now')
def test_process_source_zone(self, now_mock):


Loading…
Cancel
Save