summaryrefslogtreecommitdiff
path: root/designate/manage
diff options
context:
space:
mode:
authorJorge Niedbalski <jorge.niedbalski@canonical.com>2020-05-28 14:57:49 -0400
committerNicolas Bock <nicolas.bock@canonical.com>2021-04-23 13:31:08 -0600
commit0b5634643b4b69cd0a7d5499f258602604741d22 (patch)
treeb713bf09655041ebaec882711746786bcaf6fdb8 /designate/manage
parentacc82755f1e8df8bb8f0ab7b4524f691637a312e (diff)
downloaddesignate-stable/stein.tar.gz
Update zones masters using pool target masters.stein-eolstable/stein
This change enforces the update of the zone masters for all zones that belongs to a particular pool, using the pool's defined target(s) masters and forcing a update_zone call. This change also, moves the backend base class update_zone method as an abstract method, allowing to each backend implementation to create its own update logic. For the case of bind9 its extended to allow running a rndc modzone with the new given masters for the zone fixing the behavior exposed on LP: #1879798. Fixes-Bug: #1879798 Change-Id: I9dddd4130a0cbb29311eeb52e077e216c8c03f3a Signed-off-by: Jorge Niedbalski <jorge.niedbalski@canonical.com> Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com> (cherry picked from commit 3756fc51e71aaf0ba7cfb9155ca5d1de26ab78bc)
Diffstat (limited to 'designate/manage')
-rw-r--r--designate/manage/pool.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/designate/manage/pool.py b/designate/manage/pool.py
index f5dd5ef7..e3511e61 100644
--- a/designate/manage/pool.py
+++ b/designate/manage/pool.py
@@ -23,6 +23,7 @@ import oslo_messaging as messaging
from designate import exceptions
from designate import rpc
from designate import objects
+from designate import policy
from designate.central import rpcapi as central_rpcapi
from designate.manage import base
from designate.objects.adapters import DesignateAdapter
@@ -43,6 +44,30 @@ class PoolCommands(base.Commands):
rpc.init(cfg.CONF)
self.central_api = central_rpcapi.CentralAPI()
+ def _update_zones(self, pool):
+ LOG.info("Updating zone masters for pool: {}".format(pool.id))
+
+ def __get_masters_from_pool(pool):
+ masters = []
+ for target in pool.targets:
+ for master in target.get("masters", []):
+ masters.append({'host': master['host'],
+ 'port': master['port']})
+ return masters
+
+ policy.init()
+
+ self.context.all_tenants = True
+ zones = self.central_api.find_zones(
+ self.context,
+ criterion={'pool_id': pool.id})
+
+ for zone in zones:
+ zone.masters = objects.ZoneMasterList().from_list(
+ __get_masters_from_pool(pool))
+ self.central_api.update_zone(self.context,
+ zone)
+
@base.args('--file', help='The path to the file the yaml output should be '
'written to',
default='/etc/designate/pools.yaml')
@@ -163,6 +188,9 @@ class PoolCommands(base.Commands):
output_msg.append("Update Pool: %s" % pool)
else:
pool = self.central_api.update_pool(self.context, pool)
+ # Bug: Changes in the pool targets should trigger a
+ # zone masters update LP: #1879798.
+ self._update_zones(pool)
except exceptions.PoolNotFound:
pool = DesignateAdapter.parse('YAML', xpool, objects.Pool())