diff --git a/CHANGELOG.md b/CHANGELOG.md index 673537c..3a7df78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/octodns/processor/meta.py b/octodns/processor/meta.py index 4c71724..42299ea 100644 --- a/octodns/processor/meta.py +++ b/octodns/processor/meta.py @@ -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 diff --git a/tests/test_octodns_processor_meta.py b/tests/test_octodns_processor_meta.py index b99dd19..05e5515 100644 --- a/tests/test_octodns_processor_meta.py +++ b/tests/test_octodns_processor_meta.py @@ -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):