Skip to content

Commit 2f202eb

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "For evacuation, ignore if task_state is not None" into stable/xena
2 parents 90a25a7 + 8e9aa71 commit 2f202eb

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

doc/source/admin/evacuate.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,17 @@ instances up and running.
9797
using a pattern you might want to use the ``--strict`` flag which got introduced
9898
in version 10.2.0 to make sure nova matches the ``FAILED_HOST``
9999
exactly.
100+
101+
.. note::
102+
.. code-block:: bash
103+
104+
+------+--------+--------------+
105+
| Name | Status | Task State |
106+
+------+--------+--------------+
107+
| vm_1 | ACTIVE | powering-off |
108+
+------------------------------+
109+
110+
If the instance task state is not None, evacuation will be possible. However,
111+
depending on the ongoing operation, there may be clean up required in other
112+
services which the instance was using, such as neutron, cinder, glance, or
113+
the storage backend.

nova/compute/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,7 +5396,7 @@ def live_migrate_abort(self, context, instance, migration_id,
53965396
@reject_vtpm_instances(instance_actions.EVACUATE)
53975397
@block_accelerators(until_service=SUPPORT_ACCELERATOR_SERVICE_FOR_REBUILD)
53985398
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.STOPPED,
5399-
vm_states.ERROR])
5399+
vm_states.ERROR], task_state=None)
54005400
def evacuate(self, context, instance, host, on_shared_storage,
54015401
admin_password=None, force=None):
54025402
"""Running evacuate to target host.
@@ -5423,7 +5423,7 @@ def evacuate(self, context, instance, host, on_shared_storage,
54235423
context, instance.uuid)
54245424

54255425
instance.task_state = task_states.REBUILDING
5426-
instance.save(expected_task_state=[None])
5426+
instance.save(expected_task_state=None)
54275427
self._record_action_start(context, instance, instance_actions.EVACUATE)
54285428

54295429
# NOTE(danms): Create this as a tombstone for the source compute

nova/tests/functional/regressions/test_bug_1978983.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
# License for the specific language governing permissions and limitations
1414
# under the License.
1515

16-
1716
from nova import test
1817
from nova.tests import fixtures as nova_fixtures
19-
from nova.tests.functional.api import client
2018
from nova.tests.functional import fixtures as func_fixtures
2119
from nova.tests.functional import integrated_helpers
2220

@@ -44,6 +42,7 @@ def setUp(self):
4442
api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
4543
api_version='v2.1'))
4644
self.api = api_fixture.admin_api
45+
self.api.microversion = 'latest'
4746

4847
self.src = self._start_compute(host='host1')
4948
self.dest = self._start_compute(host='host2')
@@ -53,26 +52,20 @@ def test_evacuate_instance(self):
5352
"""
5453
server = self._create_server(networks=[])
5554

56-
self.api.microversion = 'latest'
5755
server = self._wait_for_state_change(server, 'ACTIVE')
58-
self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
56+
self.assertEqual(self.src.host, server['OS-EXT-SRV-ATTR:host'])
5957

6058
# stop host1 compute service
6159
self.src.stop()
60+
self.api.put_service_force_down(self.src.service_ref.uuid, True)
6261

6362
# poweroff instance
6463
self._stop_server(server, wait_for_stop=False)
6564
server = self._wait_for_server_parameter(
6665
server, {'OS-EXT-STS:task_state': 'powering-off'})
6766

68-
# FIXME(auniyal): As compute service is down in source node
69-
# instance is stuck at powering-off, evacuation fails with
70-
# msg: Cannot 'evacuate' instance <instance-id> while it is in
71-
# task_state powering-off (HTTP 409)
72-
73-
ex = self.assertRaises(
74-
client.OpenStackApiException,
75-
self._evacuate_server,
76-
server,
77-
expected_host=self.dest.host)
78-
self.assertEqual(409, ex.response.status_code)
67+
# evacuate instance
68+
server = self._evacuate_server(
69+
server, expected_host=self.dest.host
70+
)
71+
self.assertEqual(self.dest.host, server['OS-EXT-SRV-ATTR:host'])
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
fixes:
3+
- |
4+
If compute service is down in source node and user try to stop
5+
instance, instance gets stuck at powering-off, hence evacuation fails with
6+
msg: Cannot 'evacuate' instance <instance-id> while it is in
7+
task_state powering-off.
8+
It is now possible for evacuation to ignore the vm task state.
9+
For more details see: `bug 1978983`_
10+
11+
.. _`bug 1978983`: https://bugs.launchpad.net/nova/+bug/1978983

0 commit comments

Comments
 (0)