← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:amend_create_nova_image_new_release into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:amend_create_nova_image_new_release into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/452974
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:amend_create_nova_image_new_release into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-new-release b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-new-release
index 349c217..9a96899 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-new-release
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/create-nova-image-new-release
@@ -97,19 +97,20 @@ trap 'openstack server delete ${SRVID}' EXIT TERM INT QUIT PIPE
 eval "$(openstack server show -f shell "${SRVID}")"
 ipaddr=$(echo "${addresses}" | awk 'BEGIN { FS="=" } { print $2 }')
 
-SSH_CMD="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@$ipaddr"
+SSH_CMD=(ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@"${ipaddr}")
+WAIT_CMD=$(printf "while ! %s true; do sleep 5; done" "${SSH_CMD[*]}")
 echo "Waiting for ssh (may cause some error messages)..."
-timeout 300 sh -c "while ! $SSH_CMD true; do sleep 5; done"
+timeout 300 sh -c "${WAIT_CMD}"
 
 echo "Waiting until cloud-init is done..."
-timeout 25m "${SSH_CMD}" 'while [ ! -e /var/lib/cloud/instance/boot-finished ]; do sleep 1; done'
+timeout 25m "${SSH_CMD[@]}" 'while [ ! -e /var/lib/cloud/instance/boot-finished ]; do sleep 1; done'
 
 echo "Running setup script..."
-"${SSH_CMD}" "sudo env MIRROR='${MIRROR:-}' RELEASE='$RELEASE' sh -" < "${SETUP_TESTBED}"
+"${SSH_CMD[@]}" "sudo env MIRROR='${MIRROR:-}' RELEASE='$RELEASE' sh -" < "${SETUP_TESTBED}"
 
 echo "Running Canonical setup script..."
 CANONICAL_SCRIPT="$(dirname "$(dirname "$(readlink -f "${0}")")")"/worker-config-production/setup-canonical.sh
-"${SSH_CMD}" "sudo env MIRROR='${MIRROR:-}' RELEASE='$RELEASE' sh -" < "${CANONICAL_SCRIPT}"
+"${SSH_CMD[@]}" "sudo env MIRROR='${MIRROR:-}' RELEASE='$RELEASE' sh -" < "${CANONICAL_SCRIPT}"
 
 echo "Check that the upgraded image boots..."
 while true; do
@@ -126,17 +127,17 @@ while true; do
     sleep 10
 done
 
-if ! timeout 300 sh -c "while ! $SSH_CMD true; do sleep 5; done"; then
+if ! timeout 300 sh -c "${WAIT_CMD}"; then
     echo "ERROR: upgraded instance does not reboot; console-log:" >&2
     openstack console log show "${SRVID}" >&2 || true
     exit 1
 fi
 
 echo "Cleaning systemd journal..."
-$SSH_CMD sudo journalctl --rotate --vacuum-time=12h || true
+"${SSH_CMD[@]}" sudo journalctl --rotate --vacuum-time=12h || true
 
 echo "Powering off to get a clean file system..."
-$SSH_CMD sudo poweroff || true
+"${SSH_CMD[@]}" sudo poweroff || true
 eval "$(openstack server show -f shell "${SRVID}")"
 while [ "${os_ext_sts_vm_state}" != "stopped" ]; do
         sleep 1

Follow ups