Skip to content

Commit a9199f6

Browse files
committed
Wait for image to be active after creation
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
1 parent 250504b commit a9199f6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

container-images/tcib/base/os/tempest/run_tempest.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ CONCURRENCY="${CONCURRENCY:-}"
9595
TEMPESTCONF_ARGS=""
9696
TEMPEST_ARGS=""
9797
TEMPEST_DEBUG_MODE="${TEMPEST_DEBUG_MODE:-false}"
98+
TEMPEST_IMAGE_CREATE_TIMEOUT="${TEMPEST_IMAGE_CREATE_TIMEOUT:-300}"
9899

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

221+
function get_image_status {
222+
openstack image show $IMAGE_ID -f value -c status
223+
}
224+
220225
function upload_extra_images {
221226
for image_index in "${!TEMPEST_EXTRA_IMAGES_NAME[@]}"; do
222227
if ! openstack image show ${TEMPEST_EXTRA_IMAGES_NAME[image_index]}; then
@@ -241,7 +246,19 @@ function upload_extra_images {
241246
image_create_params+=(--container-format ${TEMPEST_EXTRA_IMAGES_CONTAINER_FORMAT[image_index]})
242247

243248
image_create_params+=(--public ${TEMPEST_EXTRA_IMAGES_NAME[image_index]})
244-
openstack image create --import ${image_create_params[@]}
249+
IMAGE_ID=$(openstack image create --import ${image_create_params[@]} -f value -c id)
250+
STATUS=$(get_image_status)
251+
START_TIME=$(date +%s)
252+
while [ "$STATUS" != "active" ]; do
253+
echo "Current status: $STATUS. Waiting for image to become active..."
254+
sleep 5
255+
if [ $(($(date +%s) - $START_TIME)) -gt $TEMPEST_IMAGE_CREATE_TIMEOUT ]; then
256+
echo "Error: Image creation exceeded the timeout period of $TEMPEST_IMAGE_CREATE_TIMEOUT seconds."
257+
exit 1
258+
fi
259+
STATUS=$(get_image_status)
260+
done
261+
echo "Image $IMAGE_ID is now active."
245262
fi
246263

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

0 commit comments

Comments
 (0)