X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=pipelines%2Fimages%2Fimagebuild.sh;h=8731e1517c6669ecd4d04712a988029fd7c3d8f8;hb=9611d4c7fdbe46758592c2936f0eb5d572e2f8bf;hp=1b36a0331f5d6290493742957d4089c1fe0f6c2d;hpb=30b28562b262df9cfcf243afe50b13100db58a8f;p=lttng-ci.git diff --git a/pipelines/images/imagebuild.sh b/pipelines/images/imagebuild.sh index 1b36a03..8731e15 100644 --- a/pipelines/images/imagebuild.sh +++ b/pipelines/images/imagebuild.sh @@ -111,7 +111,7 @@ INSTANCE_NAME="$(echo "${INSTANCE_NAME}" | cut -d ':' -f 2 | tr -d ' ')" set -e CLEANUP+=( - "lxc stop ${INSTANCE_NAME}" + "lxc stop -f ${INSTANCE_NAME}" ) # VMs may take more time to start, wait until instance is running @@ -197,21 +197,25 @@ LANG=C ANSIBLE_STRATEGY=linear ansible-playbook \ -l "${INSTANCE_IP}" -i fake-inventory # Publish -lxc publish "${INSTANCE_NAME}" --alias "${TARGET_IMAGE_NAME}" -f +if FINGERPRINT=$(lxc publish "${INSTANCE_NAME}" -f 2>&1 | grep -E -o '[A-Fa-f0-9]{64}') ; then + echo "Published instance with fingerprint '${FINGERPRINT}'" +else + fail 1 "No fingerprint for published instance" +fi TRIES=0 if [[ "${TEST}" == "true" ]] ; then set +e while [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; do - if ! INSTANCE_NAME=$(lxc -q launch -e "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" "${TARGET_IMAGE_NAME}") ; then + if ! INSTANCE_NAME=$(lxc -q launch -e "${VM_ARG[@]}" -p default -p "${LXD_INSTANCE_PROFILE}" "${FINGERPRINT}") ; then TRIES=$((TRIES + 1)) echo "Failed to launch instance try ${TRIES}/${TRIES_MAX}" if [[ "${TRIES}" -lt "${TRIES_MAX}" ]] ; then sleep $((1 + RANDOM % 10)) continue fi - fail 1 "Failed to launch an instance using newly published image '${TARGET_IMAGE_NAME}'" + fail 1 "Failed to launch an instance using newly published image '${FINGERPRINT}'" else INSTANCE_NAME="$(echo "${INSTANCE_NAME}" | cut -d':' -f2 | tr -d ' ')" CLEANUP+=( @@ -222,3 +226,6 @@ if [[ "${TEST}" == "true" ]] ; then done set -e fi + +lxc image alias delete "${TARGET_IMAGE_NAME}" || true +lxc image alias create "${TARGET_IMAGE_NAME}" "${FINGERPRINT}"