workaround: Wait for instance.host=None when shelving

There is a race in Nova where an instance being shelved is set to the
SHELVED_OFFLOADED vm_state before the instance.host is cleared. It
appears to be non-trivial to fix given the comments in that code
explictly say the updates have the be in that order.

This works around the issue by waiting until the instance.host is None
before considering the shelve offload to be completed.

Related-Bug: #2045785

Change-Id: Ia45247a7aa14eb5f0038d4512a0b4ebe6af5a573
This commit is contained in:
melanie witt 2024-10-02 19:09:41 +00:00
parent 82b37d1406
commit 4e96588cf4

View File

@ -150,6 +150,15 @@ class UnshelveToHostMultiNodesTest(base.BaseV2ComputeAdminTest):
compute.shelve_server(self.servers_client, server['id'], compute.shelve_server(self.servers_client, server['id'],
force_shelve_offload=True) force_shelve_offload=True)
# Work around https://bugs.launchpad.net/nova/+bug/2045785
# This can be removed when ^ is fixed.
def _check_server_host_is_none():
server_details = self.os_admin.servers_client.show_server(
server['id'])
self.assertIsNone(server_details['server']['OS-EXT-SRV-ATTR:host'])
self.wait_for(_check_server_host_is_none)
self.os_admin.servers_client.unshelve_server( self.os_admin.servers_client.unshelve_server(
server['id'], server['id'],
body={'unshelve': {'host': host}} body={'unshelve': {'host': host}}