Wait for volume to be available before attaching it
On slower test nodes we're seeing failures where the 2nd cinder volume created is not yet available by the time we try to attach it to a server which fails with a 400 InvalidVolume error. This fixes the bug by waiting for the volume to be available before trying to attach it. Change-Id: I833d79ecc97ddc844bf156ab64477c7c77424f20 Closes-Bug: #1807520
This commit is contained in:
parent
674861b787
commit
2f03ec23fd
@ -141,6 +141,24 @@ function create {
|
||||
eval $(openstack volume create --size 1 $CINDER_VOL2 -f shell)
|
||||
resource_save cinder cinder_volume2_id $id
|
||||
|
||||
# Wait for the volume to be available before attaching it to the server.
|
||||
# TODO(mriedem): Replace this (and the wait loop above) with --wait once
|
||||
# OSC story 2002158 is complete.
|
||||
timeleft=30
|
||||
while [[ $timeleft -gt 0 ]]; do
|
||||
local status=$(openstack volume show $CINDER_VOL2 -f value -c status)
|
||||
if [[ "$status" != "available" ]]; then
|
||||
echo "Volume is not yet available, waiting..."
|
||||
sleep 1
|
||||
timeleft=$((timeleft - 1))
|
||||
if [[ $timeleft == 0 ]]; then
|
||||
die $LINENO "Timed out waiting for volume $CINDER_VOL2 to be available"
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Attach second volume and ensure it becomes in-use
|
||||
openstack server add volume $CINDER_SERVER $CINDER_VOL2
|
||||
local timeleft=30
|
||||
|
Loading…
x
Reference in New Issue
Block a user