diff options
author | Dmitry Galkin <galkindmitrii@gmail.com> | 2018-08-07 09:22:31 +0000 |
---|---|---|
committer | Michael Johnson <johnsomor@gmail.com> | 2020-05-11 16:49:55 +0000 |
commit | 076600dd9107baf567c3dc032a0901dfeda73784 (patch) | |
tree | bd3f8feac7dadb2629548f96624ecb617dc0c95c | |
parent | 0dae66c1b4c87f054a183a4284f656113d0bed86 (diff) | |
download | designate-stable/queens.tar.gz |
Worker should send NOTIFY also to all servers in 'also_notifies' pool settings.queens-eolstable/queens
Change-Id: I0a85c5df5c323d6f636c8cb92ee5201c14cdb306
Closes-Bug: #1785769
(cherry picked from commit 6e79c2e0816ca59cff9a8b0eb238e1e5add7b943)
-rw-r--r-- | designate/tests/test_workers/test_service.py | 4 | ||||
-rw-r--r-- | designate/worker/service.py | 23 |
2 files changed, 23 insertions, 4 deletions
diff --git a/designate/tests/test_workers/test_service.py b/designate/tests/test_workers/test_service.py index f8d576ce..e41607a7 100644 --- a/designate/tests/test_workers/test_service.py +++ b/designate/tests/test_workers/test_service.py @@ -60,6 +60,8 @@ class TestService(TestCase): self.service._pool = mock.Mock() self.service.get_pool = mock.Mock() pool = mock.Mock() + pool.also_notifies = mock.MagicMock() + pool.also_notifies.__iter__.return_value = [] self.service.get_pool.return_value = pool self.service._do_zone_action(self.context, self.zone) @@ -72,7 +74,7 @@ class TestService(TestCase): self.zone.action ) - self.service._executor.run.assert_called_with(ZoneAction()) + self.service._executor.run.assert_called_with([ZoneAction()]) def test_get_pool(self): pool = mock.Mock() diff --git a/designate/worker/service.py b/designate/worker/service.py index 8385ceb2..fdf826ee 100644 --- a/designate/worker/service.py +++ b/designate/worker/service.py @@ -35,6 +35,13 @@ LOG = logging.getLogger(__name__) CONF = cfg.CONF +class AlsoNotifyTask(object): + """ + Placeholder to define options for also_notify targets + """ + pass + + class Service(service.RPCService, service.Service): RPC_API_VERSION = '1.0' @@ -121,10 +128,20 @@ class Service(service.RPCService, service.Service): def _do_zone_action(self, context, zone): pool = self.get_pool(zone.pool_id) - task = zonetasks.ZoneAction( + all_tasks = [] + all_tasks.append(zonetasks.ZoneAction( self.executor, context, pool, zone, zone.action - ) - return self.executor.run(task) + )) + + # Send a NOTIFY to each also-notifies + for also_notify in pool.also_notifies: + notify_target = AlsoNotifyTask() + notify_target.options = {'host': also_notify.host, + 'port': also_notify.port} + all_tasks.append(zonetasks.SendNotify(self.executor, + zone, + notify_target)) + return self.executor.run(all_tasks) def create_zone(self, context, zone): """ |