Merge ~paride/autopkgtest-cloud:clean-alien-packages into autopkgtest-cloud:master

Proposed by Paride Legovini
Status: Merged
Approved by: Brian Murray
Approved revision: f63bcbeeb8edb934753bcbf5dcb58797a9ff5e64
Merged at revision: 0656e75829c2e28d572c046a7a17d2d9f82e4ded
Proposed branch: ~paride/autopkgtest-cloud:clean-alien-packages
Merge into: autopkgtest-cloud:master
Diff against target: 59 lines (+50/-0)
1 file modified
charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh (+50/-0)
Reviewer Review Type Date Requested Status
Paride Legovini Needs Fixing
Julian Andres Klode (community) Approve
Tim Andersson Pending
Ubuntu Release Team Pending
Review via email: mp+442340@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paride Legovini (paride) wrote :

To reviewers: note the usage of -o Dpkg::Options::="--force-confnew". My idea is that if we *downgrade* a package we want the "new" config files (i.e. those from the *older* package, the one being installed), as the already installed conf files may not be supported by the older package version.

Revision history for this message
Paride Legovini (paride) :
Revision history for this message
Julian Andres Klode (juliank) wrote :

Some comment but overall this should work.

review: Approve
Revision history for this message
Brian Murray (brian-murray) wrote :

One comment.

Revision history for this message
Paride Legovini (paride) :
Revision history for this message
Paride Legovini (paride) wrote :

Ready for another review.

Revision history for this message
Paride Legovini (paride) wrote :

I found a bug: we need DEBIAN_FRONTEND=noninteractive even when purging '?obsolete' packages, as debconf questions may also appear in that stage. Actually hit this in staging. The script was trying to remove a running kernel.

review: Needs Fixing
Revision history for this message
Paride Legovini (paride) wrote :

I updated the MP, the only change wrt the previous version is that I added

  DEBIAN_FRONTEND=noninteractive

to the line where we purge '?obsolete' packages. I tested this in staging by removing the mantic image and manually running the script, simulating what we do when opening a new series.

Revision history for this message
Paride Legovini (paride) wrote :

As discussed, added a comment on '?obsolete' removal possibly removing the running kernel.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
2index c6d401c..92c2d70 100644
3--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
4+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker-config-production/setup-canonical.sh
5@@ -1,5 +1,55 @@
6 # Canonical/Ubuntu specific testbed setup
7
8+RELEASE=$(lsb_release --codename --short 2>/dev/null)
9+
10+# Make the installed package versions match what is available from the configured
11+# repositories, even if a downgrade is required.
12+#
13+# We may end up with images with packages newer than those available from the
14+# repositories when opening a new release (images are created using the
15+# previous release dailies as a base, which may include 0-day SRUs, or
16+# Launchpad may fail to copy packages, see openssl 3.0.8-1ubuntu2), or when
17+# package versions are pulled from the archive.
18+#
19+# Note: 'release a=' matches the Suite field in the repository Release file.
20+cat >/etc/apt/preferences.d/force-downgrade-to-release.pref <<EOF
21+Package: *
22+Pin: release a=$RELEASE
23+Pin-Priority: 1001
24+
25+Package: *
26+Pin: release a=$RELEASE-updates
27+Pin-Priority: 1001
28+
29+Package: *
30+Pin: release n=$RELEASE-security
31+Pin-Priority: 1001
32+EOF
33+# This is going to be a downgrade-only (or no-op) dist-upgrade, as setup-testbed
34+# already dist-upgraded the system. Force the usage of the conf files of the
35+# package being installed (--force-confnew), as conf files "from the future"
36+# may not be supported by the older package version we're downgrading to.
37+DEBIAN_FRONTEND=noninteractive eatmydata apt-get -y --allow-downgrades -o Dpkg::Options::="--force-confnew" dist-upgrade
38+rm /etc/apt/preferences.d/force-downgrade-to-release.pref
39+
40+# Remove packages not available from any configured repository, e.g.
41+# packages fully removed from the archive. This requires the analyze-pattern
42+# feature, which has been introduced in apt 2.0.1 (>= Focal).
43+#
44+# Note: autoremove/--autoremove always runs on the entire set of installed
45+# packages. Together with --autopurge/purge each removal becomes a purge.
46+#
47+# Removing '?obsolete' packages may remove the running kernel. This is not
48+# expected to be an issue.
49+if /usr/lib/apt/apt-helper analyze-pattern '?true' >/dev/null 2>&1; then
50+ DEBIAN_FRONTEND=noninteractive eatmydata apt-get -y purge --autoremove '?obsolete'
51+else
52+ # We're on an older release (analyze-pattern is not available).
53+ # Still do an autopurge to get rid of packages that got orphaned
54+ # by downgrades.
55+ eatmydata apt-get -y autoremove --purge
56+fi
57+
58 # compatibility with old Jenkins testbeds for trusty
59 if grep -q trusty /etc/lsb-release; then apt-get update || (sleep 10; apt-get update); apt-get install -y build-essential; fi
60

Subscribers

People subscribed via source and target branches