From 669d6499eeb718c30c257feda645cc8a874e5197 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 24 Sep 2018 13:05:02 +0200 Subject: [PATCH] Follow up for Ib6f95c22ffd3ea235b60db4da32094d49c2efa2a This patch removes the host parameter of the notify_about_instance_delete() call as it is always filled with CONF.host value. Change-Id: Iff3b605b9410d5a097b53f532870df65780bc1e4 Implements: bp versioned-notification-transformation-stein --- doc/notification_samples/instance-soft_delete-end.json | 2 +- doc/notification_samples/instance-soft_delete-start.json | 2 +- nova/compute/api.py | 8 ++++---- nova/compute/manager.py | 2 +- nova/compute/utils.py | 6 +++--- nova/conductor/manager.py | 2 +- nova/tests/unit/compute/test_compute_api.py | 2 +- nova/tests/unit/compute/test_compute_utils.py | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/notification_samples/instance-soft_delete-end.json b/doc/notification_samples/instance-soft_delete-end.json index 632a18369d02..eb25097b686c 100644 --- a/doc/notification_samples/instance-soft_delete-end.json +++ b/doc/notification_samples/instance-soft_delete-end.json @@ -8,5 +8,5 @@ } }, "priority":"INFO", - "publisher_id":"nova-compute:compute" + "publisher_id":"nova-compute:fake-mini" } diff --git a/doc/notification_samples/instance-soft_delete-start.json b/doc/notification_samples/instance-soft_delete-start.json index 8557860aa81e..d60e3dfd0027 100644 --- a/doc/notification_samples/instance-soft_delete-start.json +++ b/doc/notification_samples/instance-soft_delete-start.json @@ -8,5 +8,5 @@ } }, "priority":"INFO", - "publisher_id":"nova-compute:compute" + "publisher_id":"nova-compute:fake-mini" } diff --git a/nova/compute/api.py b/nova/compute/api.py index 9f8d27948229..52d3d965743b 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1833,7 +1833,7 @@ class API(base.Base): # FIXME: When the instance context is targeted, # we can remove this with compute_utils.notify_about_instance_delete( - self.notifier, cctxt, instance, CONF.host): + self.notifier, cctxt, instance): instance.destroy() else: instance.destroy() @@ -1891,7 +1891,7 @@ class API(base.Base): try: # Now destroy the instance from the cell it lives in. with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host): + self.notifier, context, instance): instance.destroy() except exception.InstanceNotFound: pass @@ -1962,7 +1962,7 @@ class API(base.Base): if not instance.host and not may_have_ports_or_volumes: try: with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host, + self.notifier, context, instance, delete_type if delete_type != 'soft_delete' else 'delete'): @@ -2111,7 +2111,7 @@ class API(base.Base): LOG.warning("instance's host %s is down, deleting from " "database", instance.host, instance=instance) with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, CONF.host, + self.notifier, context, instance, delete_type if delete_type != 'soft_delete' else 'delete'): elevated = context.elevated() diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 1f6cf3f92d12..c7d035bee904 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2824,7 +2824,7 @@ class ComputeManager(manager.Manager): def soft_delete_instance(self, context, instance): """Soft delete an instance on this host.""" with compute_utils.notify_about_instance_delete( - self.notifier, context, instance, self.host, 'soft_delete', + self.notifier, context, instance, 'soft_delete', source=fields.NotificationSource.COMPUTE): try: self.driver.soft_delete(instance) diff --git a/nova/compute/utils.py b/nova/compute/utils.py index 1317e9b48484..0a910e42476e 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -1156,7 +1156,7 @@ class UnlimitedSemaphore(object): @contextlib.contextmanager -def notify_about_instance_delete(notifier, context, instance, host, +def notify_about_instance_delete(notifier, context, instance, delete_type='delete', source=fields.NotificationSource.API): try: @@ -1168,7 +1168,7 @@ def notify_about_instance_delete(notifier, context, instance, host, notify_about_instance_action( context, instance, - host=host, + host=CONF.host, source=source, action=delete_type, phase=fields.NotificationPhase.START) @@ -1181,7 +1181,7 @@ def notify_about_instance_delete(notifier, context, instance, host, notify_about_instance_action( context, instance, - host=host, + host=CONF.host, source=source, action=delete_type, phase=fields.NotificationPhase.END) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 385b767a35d0..14df9c1e057e 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -1419,7 +1419,7 @@ class ComputeTaskManager(base.Base): # bdm, tags and instance record. with obj_target_cell(instance, cell) as cctxt: with compute_utils.notify_about_instance_delete( - self.notifier, cctxt, instance, CONF.host, + self.notifier, cctxt, instance, source=fields.NotificationSource.CONDUCTOR): try: instance.destroy() diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index de352646ea99..cd46be7c8112 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -1712,7 +1712,7 @@ class _ComputeAPIUnitTestMixIn(object): _lookup_instance.assert_called_once_with( self.context, instance.uuid) notify_mock.assert_called_once_with( - self.compute_api.notifier, self.context, instance, 'fake-mini') + self.compute_api.notifier, self.context, instance) destroy_mock.assert_called_once_with() @mock.patch.object(context, 'target_cell') diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py index 9901e99795d0..d0b149c9817d 100644 --- a/nova/tests/unit/compute/test_compute_utils.py +++ b/nova/tests/unit/compute/test_compute_utils.py @@ -1107,7 +1107,7 @@ class ComputeUtilsTestCase(test.NoDBTestCase): instance = fake_instance.fake_instance_obj( self.context, expected_attrs=('system_metadata',)) with compute_utils.notify_about_instance_delete( - mock.sentinel.notifier, self.context, instance, "fake-mini"): + mock.sentinel.notifier, self.context, instance): instance.destroy() expected_notify_calls = [ mock.call(mock.sentinel.notifier, self.context, instance,