Browse Source

Merge "Fix pool update with duplicate masters" into stable/victoria

stable/victoria
Zuul 4 weeks ago
committed by Gerrit Code Review
parent
commit
7cbbd3a18f
2 changed files with 45 additions and 5 deletions
  1. +7
    -2
      designate/manage/pool.py
  2. +38
    -3
      designate/tests/test_manage/test_update_pool.py

+ 7
- 2
designate/manage/pool.py View File

@ -51,8 +51,13 @@ class PoolCommands(base.Commands):
masters = []
for target in pool.targets:
for master in target.get("masters", []):
masters.append({'host': master['host'],
'port': master['port']})
master = {'host': master['host'], 'port': master['port']}
found = False
for existing_master in masters:
if master == existing_master:
found = True
if not found:
masters.append(master)
return masters
policy.init()


+ 38
- 3
designate/tests/test_manage/test_update_pool.py View File

@ -26,11 +26,11 @@ class UpdatePoolTestCase(DesignateManageTestCase):
self.stdlog = fixtures.StandardLogging()
self.useFixture(self.stdlog)
def hydrate_pool_targets(self, targets):
def hydrate_pool_targets(self, target_masters):
pool_targets = objects.PoolTargetList()
masters = objects.PoolTargetMasterList()
for target in targets:
masters.append(target)
for target_master in target_masters:
masters.append(target_master)
target = objects.PoolTarget(masters=masters)
target.masters = masters
pool_targets.append(target)
@ -63,3 +63,38 @@ class UpdatePoolTestCase(DesignateManageTestCase):
"update_zone") as mock_update_zone:
command._update_zones(pool)
mock_update_zone.assert_called_once()
def test_update_pools_zones_multiple_masters(self):
values = dict(
name='example.com.',
email='info@example.com',
type='PRIMARY'
)
zone = self.central_service.create_zone(
self.admin_context, zone=objects.Zone.from_dict(values))
# Ensure the correct NS Records are in place
pool = self.central_service.get_pool(
self.admin_context, zone.pool_id)
targets1 = self.hydrate_pool_targets([
objects.PoolTargetMaster(
pool_target_id=pool.id,
host="127.0.0.1",
port="53")
])
targets2 = self.hydrate_pool_targets([
objects.PoolTargetMaster(
pool_target_id=pool.id,
host="127.0.0.1",
port="53")
])
pool.targets = objects.PoolTargetList()
pool.targets.extend(targets1.objects + targets2.objects)
command = PoolCommands()
command.context = self.admin_context
command.central_api = self.central_service
command._update_zones(pool)

Loading…
Cancel
Save