From 1a241d0fb374c8747e3712313417a4fa284a4e43 Mon Sep 17 00:00:00 2001 From: zhengyao1 Date: Mon, 19 Mar 2018 10:51:00 +0800 Subject: [PATCH] remove _cleanup_running_deleted_instances repeat detach volume the volumes already detached during the above _shutdown_instance() call. So detach is not requested from _cleanup_volumes() in this case. So the call change to self._cleanup_volumes(context, instance, bdms, detach=False). Change-Id: I833f259972dd2e0e6bb3bbaa0e5a78a93f59b076 Closes-Bug: #1756507 --- nova/compute/manager.py | 3 ++- nova/tests/unit/compute/test_compute.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index ea1b93cf7174..e42b7a3c6c1b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -7418,7 +7418,8 @@ class ComputeManager(manager.Manager): try: self._shutdown_instance(context, instance, bdms, notify=False) - self._cleanup_volumes(context, instance, bdms) + self._cleanup_volumes(context, instance, bdms, + detach=False) except Exception as e: LOG.warning("Periodic cleanup failed to delete " "instance: %s", diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index ea644c91e0fc..4bb2c2ffc64f 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -6952,7 +6952,8 @@ class ComputeTestCase(BaseTestCase, mock_shutdown.assert_has_calls([ mock.call(ctxt, inst1, bdms, notify=False), mock.call(ctxt, inst2, bdms, notify=False)]) - mock_cleanup.assert_called_once_with(ctxt, inst2, bdms) + mock_cleanup.assert_called_once_with(ctxt, inst2, bdms, + detach=False) mock_get_uuid.assert_has_calls([ mock.call(ctxt, inst1.uuid, use_slave=True), mock.call(ctxt, inst2.uuid, use_slave=True)])