Browse Source

Merge pull request #997 from octodns/ownership-remove-last-change

fix issue in OwnershipProcessor when last change is removed
pull/1004/head
Ross McFarland 3 years ago
committed by GitHub
parent
commit
d35b246ed4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -1
      octodns/processor/ownership.py
  3. +21
    -0
      tests/test_octodns_processor_ownership.py

+ 1
- 0
CHANGELOG.md View File

@ -29,6 +29,7 @@
* Added simple IgnoreRootNsFilter
* Minor refactor on YamlProvider to add get_filenames making it a bit easier to
create specialized providers inheriting from it
* Fixed bug in OwnershipProcessor when all changes were removed from plans
## v0.9.21 - 2022-10-16 - Last of the oughts


+ 3
- 1
octodns/processor/ownership.py View File

@ -90,7 +90,9 @@ class OwnershipProcessor(BaseProcessor):
# change is we should do
filtered_changes.append(change)
if plan.changes != filtered_changes:
if not filtered_changes:
return None
elif plan.changes != filtered_changes:
return Plan(
plan.existing,
plan.desired,


+ 21
- 0
tests/test_octodns_processor_ownership.py View File

@ -7,6 +7,7 @@ from unittest import TestCase
from helpers import PlannableProvider
from octodns.processor.ownership import OwnershipProcessor
from octodns.provider.plan import Plan
from octodns.record import Delete, Record
from octodns.zone import Zone
@ -119,3 +120,23 @@ class TestOwnershipProcessor(TestCase):
self.assertTrue(got)
self.assertEqual(plan, got)
self.assertEqual(len(plan.changes), len(got.changes))
def test_remove_last_change(self):
ownership = OwnershipProcessor('ownership')
record = Record.new(
zone, 'a', {'ttl': 30, 'type': 'A', 'value': '4.4.4.4'}
)
existing = Zone('unit.tests.', [])
existing.add_record(record)
desired = Zone('unit.tests.', [])
change = Delete(record)
plan = Plan(
existing=existing, desired=desired, changes=[change], exists=True
)
self.assertEqual(1, len(plan.changes))
plan = ownership.process_plan(plan)
self.assertFalse(plan)

Loading…
Cancel
Save