Skip to content

Commit

Permalink
Wait for image to be active after creation
Browse files Browse the repository at this point in the history
We encountered Tempest failures due to the image being
in the importing process.
This patch ensures the image is active when the Tempest
tests are executed.

Jira: https://issues.redhat.com/browse/OSPRH-9284
  • Loading branch information
lkuchlan committed Aug 8, 2024
1 parent 250504b commit 91a1422
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion container-images/tcib/base/os/tempest/run_tempest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CONCURRENCY="${CONCURRENCY:-}"
TEMPESTCONF_ARGS=""
TEMPEST_ARGS=""
TEMPEST_DEBUG_MODE="${TEMPEST_DEBUG_MODE:-false}"
IMAGE_TIMEOUT=300

function catch_error_if_debug {
echo "File run_tempest.sh has run into an error!"
Expand Down Expand Up @@ -217,6 +218,10 @@ if [ -n "$CONCURRENCY" ] && [ -z ${TEMPEST_CONCURRENCY} ]; then
TEMPEST_ARGS+="--concurrency ${CONCURRENCY} "
fi

function get_image_status {
openstack image show $IMAGE_ID -f value -c status
}

function upload_extra_images {
for image_index in "${!TEMPEST_EXTRA_IMAGES_NAME[@]}"; do
if ! openstack image show ${TEMPEST_EXTRA_IMAGES_NAME[image_index]}; then
Expand All @@ -241,7 +246,19 @@ function upload_extra_images {
image_create_params+=(--container-format ${TEMPEST_EXTRA_IMAGES_CONTAINER_FORMAT[image_index]})

image_create_params+=(--public ${TEMPEST_EXTRA_IMAGES_NAME[image_index]})
openstack image create --import ${image_create_params[@]}
IMAGE_ID=$(openstack image create --import ${image_create_params[@]} -f value -c id)
STATUS=$(get_image_status)
START_TIME=$(date +%s)
while [ "$STATUS" != "active" ]; do
echo "Current status: $STATUS. Waiting for image to become active..."
sleep 5
if [ $(($(date +%s) - $START_TIME)) -gt $IMAGE_TIMEOUT ]; then
echo "Error: Image creation exceeded the timeout period of $IMAGE_TIMEOUT seconds."
exit 1
fi
STATUS=$(get_image_status)
done
echo "Image $IMAGE_ID is now active."
fi

if ! openstack flavor show ${TEMPEST_EXTRA_IMAGES_FLAVOR_NAME[image_index]}; then
Expand Down

0 comments on commit 91a1422

Please sign in to comment.