cinder: Wait for encrypted volume to be deleted before removing type
Cinder volume deletion is async and can take time to complete in the c-vol backend *after* c-api has already returned to the caller. As such we need to wait until encrypted volumes are deleted fully before attempting to delete the associated encrypted volume type as this request will fail when the volume is still being deleted by c-vol. This change adds a simple waiter to ensure the volume is removed before removing the type. Change-Id: I466763ae9fc5a7ad13b498d43b0c16802c1b800b Closes-Bug: #1907157
This commit is contained in:
parent
ef61a7e2da
commit
0e92ea75ee
|
@ -249,6 +249,23 @@ function verify_noapi {
|
|||
echo "Cinder verify found the expected state file: SUCCESS!"
|
||||
}
|
||||
|
||||
function _wait_for_volume_delete() {
|
||||
local DELETE_TIMEOUT=30
|
||||
local volume="$1"
|
||||
local count=0
|
||||
local status=$(openstack volume list --name ${volume} -f value -c ID | wc -l)
|
||||
echo "Waiting for volume ${volume} to be deleted."
|
||||
while [ $status -ne 0 ]
|
||||
do
|
||||
sleep 1
|
||||
count=$((count+1))
|
||||
if [ ${count} -eq ${DELETE_TIMEOUT} ]; then
|
||||
die $LINENO "Timed out waiting for volume ${volume} to be deleted."
|
||||
fi
|
||||
status=$(openstack volume list --name ${volume} -f value -c ID | wc -l)
|
||||
done
|
||||
}
|
||||
|
||||
function destroy {
|
||||
_cinder_set_user
|
||||
# Disassociate the floating IP from the server.
|
||||
|
@ -261,6 +278,10 @@ function destroy {
|
|||
openstack volume delete $CINDER_VOL2
|
||||
openstack volume delete $CINDER_VOL3
|
||||
|
||||
# Volume delete is async so wait for the encrypted volume to be removed
|
||||
# before proceeding and trying to delete the volume type below.
|
||||
_wait_for_volume_delete $CINDER_VOL3
|
||||
|
||||
openstack security group delete $CINDER_USER
|
||||
|
||||
# lastly, get rid of our volume type and user - done as admin
|
||||
|
|
Loading…
Reference in New Issue