Merge "For evacuation, ignore if task_state is not None"

This commit is contained in:
Zuul 2022-08-04 14:02:38 +00:00 committed by Gerrit Code Review
commit 7f5279edc9
4 changed files with 35 additions and 17 deletions

View File

@ -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.

View File

@ -5557,7 +5557,7 @@ class API:
@reject_vtpm_instances(instance_actions.EVACUATE)
@block_accelerators(until_service=SUPPORT_ACCELERATOR_SERVICE_FOR_REBUILD)
@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.
@ -5584,7 +5584,7 @@ class API:
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

View File

@ -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
@ -44,6 +42,7 @@ class EvacuateServerWithTaskState(
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
api_version='v2.1'))
self.api = api_fixture.admin_api
self.api.microversion = 'latest'
self.src = self._start_compute(host='host1')
self.dest = self._start_compute(host='host2')
@ -53,26 +52,20 @@ class EvacuateServerWithTaskState(
"""
server = self._create_server(networks=[])
self.api.microversion = 'latest'
server = self._wait_for_state_change(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(
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'])

View File

@ -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