summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Uniyal <auniyal@redhat.com>2022-07-06 18:20:02 +0000
committerAmit Uniyal <auniyal@redhat.com>2022-11-29 11:37:35 +0000
commit321573995596be145d3b091e341d7d66853436b8 (patch)
tree0ee6e6bcb7acbae5a8bf09a1d1b4d55eaa36eced
parent92e8ac529cf8f1cc85176fbdf18198e62f8948a8 (diff)
downloadnova-321573995596be145d3b091e341d7d66853436b8.tar.gz
For evacuation, ignore if task_state is not None
ignore instance task state and continue with vm evacutaion. Closes-Bug: #1978983 Change-Id: I5540df6c7497956219c06cff6f15b51c2c8bc29d (cherry picked from commit db919aa15f24c0d74f3c5c0e8341fad3f2392e57) (cherry picked from commit 6d61fccb8455367aaa37ae7bddf3b8befd3c3d88) (cherry picked from commit 8e9aa71e1a4d3074a94911db920cae44334ba2c3) (cherry picked from commit 0b8124b99601e1aba492be8ed564f769438bd93d) (cherry picked from commit 3224ceb3fffc57d2375e5163d8ffbbb77529bc38) (cherry picked from commit 90e65365ab608792c4b8d8c4c3a87798fccadeec)
-rw-r--r--doc/source/admin/evacuate.rst14
-rw-r--r--nova/compute/api.py4
-rw-r--r--nova/tests/functional/regressions/test_bug_1978983.py21
-rw-r--r--releasenotes/notes/ignore-instance-task-state-for-evacuation-e000f141d0153638.yaml11
4 files changed, 34 insertions, 16 deletions
diff --git a/doc/source/admin/evacuate.rst b/doc/source/admin/evacuate.rst
index ef9eccd931..18796d9c23 100644
--- a/doc/source/admin/evacuate.rst
+++ b/doc/source/admin/evacuate.rst
@@ -97,3 +97,17 @@ instances up and running.
using a pattern you might want to use the ``--strict`` flag which got introduced
in version 10.2.0 to make sure nova matches the ``FAILED_HOST``
exactly.
+
+.. note::
+ .. code-block:: bash
+
+ +------+--------+--------------+
+ | Name | Status | Task State |
+ +------+--------+--------------+
+ | vm_1 | ACTIVE | powering-off |
+ +------------------------------+
+
+ If the instance task state is not None, evacuation will be possible. However,
+ depending on the ongoing operation, there may be clean up required in other
+ services which the instance was using, such as neutron, cinder, glance, or
+ the storage backend. \ No newline at end of file
diff --git a/nova/compute/api.py b/nova/compute/api.py
index bc23cbeaa7..d2342e4965 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -4770,7 +4770,7 @@ class API(base.Base):
instance, migration.id)
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED,
- vm_states.ERROR])
+ vm_states.ERROR], task_state=None)
def evacuate(self, context, instance, host, on_shared_storage,
admin_password=None, force=None):
"""Running evacuate to target host.
@@ -4797,7 +4797,7 @@ class API(base.Base):
context, instance.uuid)
instance.task_state = task_states.REBUILDING
- instance.save(expected_task_state=[None])
+ instance.save(expected_task_state=None)
self._record_action_start(context, instance, instance_actions.EVACUATE)
# NOTE(danms): Create this as a tombstone for the source compute
diff --git a/nova/tests/functional/regressions/test_bug_1978983.py b/nova/tests/functional/regressions/test_bug_1978983.py
index c07b047b39..49430041ce 100644
--- a/nova/tests/functional/regressions/test_bug_1978983.py
+++ b/nova/tests/functional/regressions/test_bug_1978983.py
@@ -13,10 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-
from nova import test
from nova.tests import fixtures as nova_fixtures
-from nova.tests.functional.api import client
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit.image import fake
@@ -64,24 +62,19 @@ class EvacuateServerWithTaskState(
networks='none')))
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
- self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
+ self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])
# stop host1 compute service
self.src.stop()
+ self.api.put_service_force_down(self.src.service_ref.uuid, True)
# poweroff instance
self._stop_server(server, wait_for_stop=False)
server = self._wait_for_server_parameter(self.admin_api,
server, {'OS-EXT-STS:task_state': 'powering-off'})
- # FIXME(auniyal): As compute service is down in source node
- # instance is stuck at powering-off, evacuation fails with
- # msg: Cannot 'evacuate' instance <instance-id> while it is in
- # task_state powering-off (HTTP 409)
-
- ex = self.assertRaises(
- client.OpenStackApiException,
- self._evacuate_server,
- server,
- expected_host=self.dest.host)
- self.assertEqual(409, ex.response.status_code)
+ # evacuate instance
+ server = self._evacuate_server(
+ server, expected_host=self.dest.host
+ )
+ self.assertEqual(self.dest.host, server['OS-EXT-SRV-ATTR:host'])
diff --git a/releasenotes/notes/ignore-instance-task-state-for-evacuation-e000f141d0153638.yaml b/releasenotes/notes/ignore-instance-task-state-for-evacuation-e000f141d0153638.yaml
new file mode 100644
index 0000000000..46ebf0bd2d
--- /dev/null
+++ b/releasenotes/notes/ignore-instance-task-state-for-evacuation-e000f141d0153638.yaml
@@ -0,0 +1,11 @@
+---
+fixes:
+ - |
+ If compute service is down in source node and user try to stop
+ instance, instance gets stuck at powering-off, hence evacuation fails with
+ msg: Cannot 'evacuate' instance <instance-id> while it is in
+ task_state powering-off.
+ It is now possible for evacuation to ignore the vm task state.
+ For more details see: `bug 1978983`_
+
+ .. _`bug 1978983`: https://bugs.launchpad.net/nova/+bug/1978983 \ No newline at end of file