Merge ~morphis/snappy-hwe-snaps/+git/build-scripts:bug/check-deb-install-status into ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master

Proposed by Simon Fels
Status: Merged
Approved by: Jim Hodapp
Approved revision: b1c057b794d54f10dc416d872247e507cf2a2b9a
Merged at revision: 776581b6f9fd5fb4f5ab15a994f4a082915a8ab6
Proposed branch: ~morphis/snappy-hwe-snaps/+git/build-scripts:bug/check-deb-install-status
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master
Diff against target: 24 lines (+12/-1)
1 file modified
jobs/generic-run-snap-spread-tests (+12/-1)
Reviewer Review Type Date Requested Status
Jim Hodapp (community) Approve
Alfonso Sanchez-Beato Approve
Konrad Zapałowicz (community) code Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+316937@code.launchpad.net

Description of the change

Check deb package install status before trying to install again

This removes the chance of having a conflict with an already locked deb database when we run the job multiple times. For the last tiny tiny chance of having a conflict we simply ignore the failing apt install call and let the build fail later on when it attempts to use one of the missing tools.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Ack

review: Approve (code)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
Jim Hodapp (jhodapp) wrote :

Very nice enhancement. Thanks, looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/generic-run-snap-spread-tests b/jobs/generic-run-snap-spread-tests
2index 9dd31d6..585deb9 100644
3--- a/jobs/generic-run-snap-spread-tests
4+++ b/jobs/generic-run-snap-spread-tests
5@@ -70,7 +70,18 @@ $SSH sudo systemd-run --scope $REMOTE_WORKSPACE/build-spread.sh
6 if [ $($SSH snap list | grep ubuntu-image | wc -l) -eq 0 ] ; then
7 $SSH sudo snap install --edge --devmode ubuntu-image
8 fi
9-$SSH sudo apt install -y --force-yes kpartx qemu-kvm
10+
11+ensure_package_is_installed() {
12+ status=$($SSH dpkg-query --show --showformat='${db:Status-Status}\n' "$1")
13+ if [ "$status" != "installed" ] ; then
14+ # Ignoring failures or for the tiny change of conflicting
15+ # with another job running in parallel and trying the same.
16+ $SSH sudo apt install -y --force-yes "$1" || true
17+ fi
18+}
19+
20+ensure_package_is_installed kpartx
21+ensure_package_is_installed qemu-vkm
22
23 cat << EOF > $WORKSPACE/run-spread-tests.sh
24 #!/bin/bash

Subscribers

People subscribed via source and target branches

to all changes: