scenario: Use wait_for_volume_attachment_remove_from_server in nova_volume_detach

Detaching a volume from an instance in Nova is an asynchronous
operation. While the request can be accepted the underlying act of
detaching the device from the instance, disconnecting the volume from
the host, updating cinder and deleting records in Nova can take some
considerable time.

As such when detaching a volume callers should continue to poll the
os-volume_attachments Nova API to determine when the underlying volume
attachment, also known as a Block Device Mapping or BDM, is removed.

Bug #1908399 outlines an issue where the scenario helper method
nova_volume_detach was being called multiple times during tests and
cleanup while only waiting for the volume status to change to available.
This allowed for a race to occur where additional requests could be made
to detach the volume while the volume attachment still remained in Nova
resulting in a 400 error being returned by n-api.

This change addresses this by switching between the volume resource
status and the volume attachment removal waiters.

Closes-Bug: #1908399
Change-Id: Ib6ae2c30be65eb444976b0330fd23d9457146284
Lee Yarwood 2 years ago
parent 7d775d6d1c
commit 5423c53095

@ -741,14 +741,12 @@ class ScenarioTest(tempest.test.BaseTestCase):
def nova_volume_detach(self, server, volume):
"""Compute volume detach
This utility detaches volume from compute and check whether the
volume status is 'available' state, and if not, an exception
will be thrown.
This utility detaches the volume from the server and checks whether the
volume attachment has been removed from Nova.
self.servers_client.detach_volume(server['id'], volume['id'])
volume['id'], 'available')
volume = self.volumes_client.show_volume(volume['id'])['volume']
self.servers_client, server['id'], volume['id'])
def ping_ip_address(self, ip_address, should_succeed=True,
ping_timeout=None, mtu=None, server=None):