From 9c906a175b34e67ad76690cbd3f361225bc897b9 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 18 Jan 2019 13:53:09 +0000 Subject: [PATCH] Wait for volume attachment in CI before detach In some cases the volume attachment is not finished by the time we attempt to detach it, causing the following error: Volume status must be 'in-use' and attach_status must be 'attached' to detach. This change waits for the volume to be attached before detaching. Change-Id: Id23d114cf8a2b40f8f0784cbfb84e9fa0829adc0 --- tests/test-openstack.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test-openstack.sh b/tests/test-openstack.sh index dbaddadada..156125252d 100755 --- a/tests/test-openstack.sh +++ b/tests/test-openstack.sh @@ -28,6 +28,17 @@ function test_openstack_logged { echo "TESTING: Cinder volume attachment" openstack volume create --size 2 test_volume openstack server add volume kolla_boot_test test_volume --device /dev/vdb + attempt=1 + while [[ $(openstack volume show test_volume -f value -c status) != "in-use" ]]; do + echo "Volume not attached yet" + attempt=$((attempt+1)) + if [[ $attempt -eq 10 ]]; then + echo "Volume failed to attach" + openstack volume show test_volume + return 1 + fi + sleep 10 + done openstack server remove volume kolla_boot_test test_volume echo "SUCCESS: Cinder volume attachment" fi