Merge ~sdeziel/ubuntu/+source/lxd-installer:lxd-next-lts into ubuntu/+source/lxd-installer:ubuntu/devel

Proposed by Simon Déziel
Status: Merged
Merged at revision: f181ed17a0e97dbce65c082398e253d0e0fffc92
Proposed branch: ~sdeziel/ubuntu/+source/lxd-installer:lxd-next-lts
Merge into: ubuntu/+source/lxd-installer:ubuntu/devel
Diff against target: 117 lines (+70/-8)
4 files modified
debian/changelog (+9/-0)
debian/tests/control (+4/-0)
debian/tests/install-on-demand (+44/-0)
lxd-installer-service (+13/-8)
Reviewer Review Type Date Requested Status
Lucas Kanashiro (community) Approve
Thomas Parrott (community) Approve
Ubuntu Sponsors Pending
Review via email: mp+459613@code.launchpad.net

Commit message

Use LXD 5.21 track (LTS) on Ubuntu 24.04

To post a comment you must log in.
Revision history for this message
Simon Déziel (sdeziel) wrote :

Here is the testing procedure:

$ lxc launch ubuntu-minimal-daily:24.04 c1
Creating c1
Starting c1
$ lxc file push lxd-installer_4_all.deb c1/tmp/lxd-installer_4_all.deb

$ lxc exec c1 -- apt-get install /tmp/lxd-installer_4_all.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'lxd-installer' instead of '/tmp/lxd-installer_4_all.deb'
The following packages will be upgraded:
  lxd-installer
...
Preparing to unpack /tmp/lxd-installer_4_all.deb ...
Unpacking lxd-installer (4) over (3) ...
...

# Workaround https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/2046379
# The PR fixing this was merged but no snapd release was published yet
$ lxc exec c1 -- apt-get update
$ lxc exec c1 -- apt-get install -y fuse3

# Make sure no LXD snap is installed
$ lxc exec c1 -- snap list
No snaps are installed yet. Try 'snap install hello-world'.

# Confirm lxd-installer pulls LXD snap (this takes a while)
$ lxc exec c1 -- lxc list
Installing LXD snap, please be patient.
If this is your first time running LXD on this machine, you should also run: lxd init
To start your first container, try: lxc launch ubuntu:22.04
Or for a virtual machine: lxc launch ubuntu:22.04 --vm

+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+

# Confirm lxd was pulled from the right channel: 5.21/stable/ubuntu-24.04
$ lxc exec c1 -- snap changes
ID Status Spawn Ready Summary
1 Done today at 21:43 UTC today at 21:43 UTC Initialize system state
2 Done today at 21:44 UTC today at 21:45 UTC Install "lxd" snap from "5.21/stable/ubuntu-24.04" channel
3 Done today at 21:44 UTC today at 21:44 UTC Initialize device

Revision history for this message
Thomas Parrott (tomparrott) wrote :

Looks good to me.
Although im wondering if we should make fuse3 a dependency of lxd-installer to workaround the snapd bug?

Revision history for this message
Thomas Parrott (tomparrott) wrote :

approve

review: Approve
Revision history for this message
Simon Déziel (sdeziel) wrote :

@tomparrot, that's actually a good suggestion, I'll make sure to ask Lucas about it, thanks!

Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Since the fix was already merged in snapd (but not released yet) I'd avoid adding the fix here. Hopefully, the fix will be released soon by snapd (?)

Revision history for this message
Lucas Kanashiro (lucaskanashiro) :
review: Needs Fixing
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Simon, the steps to test this change presented in your first comment looks well detailed and easy to script. Don't you think it would be good to have a DEP-8 test to make sure it is launching the correct version (track) of the lxd snap in each Ubuntu release? You could run the test in a VM (using the isolation-machine restriction) and there launch containers for each Ubuntu release and check if the correct version of the lxd snap is installed.

Revision history for this message
Simon Déziel (sdeziel) wrote :

@Lucas, thanks for flagging the typo in my email, fixed now

Revision history for this message
Simon Déziel (sdeziel) wrote :

Thanks Lucas for helping me get the autopkgtest bits working with LXD ;)

Here they are in action:

`$ autopkgtest -U -s ../lxd-installer_4_source.changes -- lxd ubuntu-minimal-daily:24.04`
```
...
autopkgtest [21:48:51]: test install-on-demand: [-----------------------
+ . /etc/os-release
+ PRETTY_NAME=Ubuntu Noble Numbat (development branch)
+ NAME=Ubuntu
+ VERSION_ID=24.04
+ VERSION=24.04 (Noble Numbat)
+ VERSION_CODENAME=noble
+ ID=ubuntu
+ ID_LIKE=debian
+ HOME_URL=https://www.ubuntu.com/
+ SUPPORT_URL=https://help.ubuntu.com/
+ BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
+ PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
+ UBUNTU_CODENAME=noble
+ LOGO=ubuntu-logo
+ echo Executing test on Ubuntu version 24.04
+ echo Check which lxd-installer version we have installed
Executing test on Ubuntu version 24.04
Check which lxd-installer version we have installed
+ dpkg -l
+ grep -wF lxd-installer
ii lxd-installer 4 all Wrapper to install lxd snap on demand
Make sure LXD's snap is not seeded in the current image
+ echo Make sure LXD's snap is not seeded in the current image
+ snap list lxd
error: no matching snaps installed
+ echo Report list of installed snaps:
Report list of installed snaps:
+ snap list
No snaps are installed yet. Try 'snap install hello-world'.
+ echo Trigger the on-demand installation
+ lxc list
Trigger the on-demand installation
Installing LXD snap, please be patient.
Check which version of LXD was installed
+ echo Check which version of LXD was installed
+ snap list lxd
Name Version Rev Tracking Publisher Notes
lxd 5.20-f3dd836 27049 5.21/stable/… canonical** -
+ snap info lxd
+ awk /^tracking: / {print $2}
+ TRACKING=5.21/stable/ubuntu-24.04
+ [ 24.04 = 24.04 ]
+ EXPECTS=5.21/stable/ubuntu-24.04
+ echo Verify it matches the expected version
+ [ 5.21/stable/ubuntu-24.04 = 5.21/stable/ubuntu-24.04 ]
+ echo lxd-installer installed LXD from the right track (5.21/stable/ubuntu-24.04)
Verify it matches the expected version
lxd-installer installed LXD from the right track (5.21/stable/ubuntu-24.04)
autopkgtest [21:50:31]: test install-on-demand: -----------------------]
autopkgtest [21:50:32]: test install-on-demand: - - - - - - - - - - results - - - - - - - - - -
install-on-demand PASS
autopkgtest [21:50:32]: @@@@@@@@@@@@@@@@@@@@ summary
install-on-demand PASS
```

Revision history for this message
Simon Déziel (sdeziel) wrote :

`autopkgtest -U -s ../lxd-installer_4_source.changes -- lxd ubuntu-minimal-daily:22.04`
```
autopkgtest [21:55:45]: test install-on-demand: [-----------------------
Executing test on Ubuntu version 22.04
Check which lxd-installer version we have installed
+ . /etc/os-release
+ PRETTY_NAME=Ubuntu 22.04.4 LTS
+ NAME=Ubuntu
+ VERSION_ID=22.04
+ VERSION=22.04.4 LTS (Jammy Jellyfish)
+ VERSION_CODENAME=jammy
+ ID=ubuntu
+ ID_LIKE=debian
+ HOME_URL=https://www.ubuntu.com/
+ SUPPORT_URL=https://help.ubuntu.com/
+ BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
+ PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
+ UBUNTU_CODENAME=jammy
+ echo Executing test on Ubuntu version 22.04
+ echo Check which lxd-installer version we have installed
+ dpkg -l
+ grep -wF lxd-installer
ii lxd-installer 4 all Wrapper to install lxd snap on demand
+ echo Make sure LXD's snap is not seeded in the current image
+ snap list lxd
Make sure LXD's snap is not seeded in the current image
error: no matching snaps installed
Report list of installed snaps:
+ echo Report list of installed snaps:
+ snap list
No snaps are installed yet. Try 'snap install hello-world'.
+ echoTrigger the on-demand installation
 Trigger the on-demand installation
+ lxc list
Installing LXD snap, please be patient.
+ Check which version of LXD was installed
echo Check which version of LXD was installed
+ snap list lxd
Name Version Rev Tracking Publisher Notes
lxd 5.0.3-ffb17cf 27037 5.0/stable/… canonical** -
+ snap info lxd
+ awk /^tracking: / {print $2}
+ TRACKING=5.0/stable/ubuntu-22.04
+ [ 22.04 = 24.04 ]
+ [ 22.04 = 22.04 ]
+ EXPECTS=5.0/stable/ubuntu-22.04
+ echo Verify it matches the expected version
+ [ 5.0/stable/ubuntu-22.04 = 5.0/stable/ubuntu-22.04 ]
+ echo lxd-installer installed LXD from the right track (5.0/stable/ubuntu-22.04)
Verify it matches the expected version
lxd-installer installed LXD from the right track (5.0/stable/ubuntu-22.04)
autopkgtest [21:57:01]: test install-on-demand: -----------------------]
autopkgtest [21:57:02]: test install-on-demand: - - - - - - - - - - results - - - - - - - - - -
install-on-demand PASS
autopkgtest [21:57:02]: @@@@@@@@@@@@@@@@@@@@ summary
install-on-demand PASS
```

Revision history for this message
Simon Déziel (sdeziel) wrote :

`autopkgtest -U -s ../lxd-installer_4_source.changes -- lxd ubuntu-minimal-daily:20.04`
```
autopkgtest [22:02:09]: test install-on-demand: [-----------------------
+ . /etc/os-release
+ NAME=Ubuntu
+ VERSION=20.04.6 LTS (Focal Fossa)
+ ID=ubuntu
+ ID_LIKE=debian
+ PRETTY_NAME=Ubuntu 20.04.6 LTS
+ VERSION_ID=20.04
+ HOME_URL=https://www.ubuntu.com/
+ SUPPORT_URL=https://help.ubuntu.com/
+ BUG_REPORT_URL=https://bugs.launchpad.net/ubuntu/
+ PRIVACY_POLICY_URL=https://www.ubuntu.com/legal/terms-and-policies/privacy-policy
+ VERSION_CODENAME=focal
+ UBUNTU_CODENAME=focal
+ echo Executing test on Ubuntu version 20.04
+ echo Check which lxd-installer version we have installed
+ dpkg -l
+ grep -wF lxd-installer
Executing test on Ubuntu version 20.04
Check which lxd-installer version we have installed
ii lxd-installer 4 all Wrapper to install lxd snap on demand
Make sure LXD's snap is not seeded in the current image
+ echo Make sure LXD's snap is not seeded in the current image
+ snap list lxd
error: no matching snaps installed
+ echo Report list of installed snaps:
+ snap list
Report list of installed snaps:
No snaps are installed yet. Try 'snap install hello-world'.
+ echo Trigger the on-demand installation
+ lxc list
Trigger the on-demand installation
Installing LXD snap, please be patient.
+ echo Check which version of LXD was installed
+ snap list lxd
Check which version of LXD was installed
Name Version Rev Tracking Publisher Notes
lxd 4.0.9-a29c6f1 24061 4.0/stable/… canonical** -
+ snap info lxd
+ awk /^tracking: / {print $2}
+ TRACKING=4.0/stable/ubuntu-20.04
+ [ 20.04 = 24.04 ]
+ [ 20.04 = 22.04 ]
+ [ 20.04 = 20.04 ]
+ EXPECTS=4.0/stable/ubuntu-20.04
+ echo Verify it matches the expected version
+ [ 4.0/stable/ubuntu-20.04 = 4.0/stable/ubuntu-20.04 ]
+ echo lxd-installer installed LXD from the right track (4.0/stable/ubuntu-20.04)
Verify it matches the expected version
lxd-installer installed LXD from the right track (4.0/stable/ubuntu-20.04)
autopkgtest [22:03:26]: test install-on-demand: -----------------------]
autopkgtest [22:03:26]: test install-on-demand: - - - - - - - - - - results - - - - - - - - - -
install-on-demand PASS
autopkgtest [22:03:26]: @@@@@@@@@@@@@@@@@@@@ summary
install-on-demand PASS
```

Revision history for this message
Lucas Kanashiro (lucaskanashiro) :
review: Needs Fixing
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Thanks Simon! LGTM now, +1.

review: Approve
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Package uploaded:

Uploading lxd-installer_4.dsc
Uploading lxd-installer_4.tar.xz
Uploading lxd-installer_4_source.buildinfo
Uploading lxd-installer_4_source.changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 6d504f0..784338a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+lxd-installer (4) noble; urgency=medium
7+
8+ * lxd-installer-service
9+ - Add new LTS track name (5.21) to be used on Ubuntu 24.04
10+ - Better handle the (unlikely) case of /etc/os-release being unreadable
11+ * Add autopkgtest to verify the right track is used by lxd-installer
12+
13+ -- Simon Deziel <simon.deziel@canonical.com> Thu, 11 Jan 2024 11:58:15 -0500
14+
15 lxd-installer (3) noble; urgency=medium
16
17 * update channel selection to ubuntu-VERSION_ID (LP: #2044185)
18diff --git a/debian/tests/control b/debian/tests/control
19new file mode 100644
20index 0000000..4d66602
21--- /dev/null
22+++ b/debian/tests/control
23@@ -0,0 +1,4 @@
24+Tests: install-on-demand
25+Depends: @,
26+ fuse3, # Workaround https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/2046379
27+Restrictions: allow-stderr isolation-container needs-root
28diff --git a/debian/tests/install-on-demand b/debian/tests/install-on-demand
29new file mode 100755
30index 0000000..0be1202
31--- /dev/null
32+++ b/debian/tests/install-on-demand
33@@ -0,0 +1,44 @@
34+#!/bin/sh
35+
36+set -eux
37+
38+. /etc/os-release
39+echo "Executing test on ${NAME:-Unknown} version ${VERSION_ID:-n/a}"
40+
41+echo "Check which lxd-installer version we have installed"
42+dpkg -l | grep -wF lxd-installer
43+
44+echo "Make sure LXD's snap is not seeded in the current image"
45+if snap list lxd; then
46+ echo "Removing seeded LXD snap"
47+ snap remove --purge lxd
48+fi
49+
50+echo "Report list of installed snaps:"
51+snap list
52+
53+echo "Trigger the on-demand installation"
54+lxc list
55+
56+echo "Check which version of LXD was installed"
57+snap list lxd
58+
59+TRACKING="$(snap info lxd | awk '/^tracking: / {print $2}')"
60+if [ "${VERSION_ID:-}" = "24.04" ]; then
61+ EXPECTS="5.21/stable/ubuntu-${VERSION_ID}"
62+elif [ "${VERSION_ID:-}" = "22.04" ]; then
63+ EXPECTS="5.0/stable/ubuntu-${VERSION_ID}"
64+elif [ "${VERSION_ID:-}" = "20.04" ]; then
65+ EXPECTS="4.0/stable/ubuntu-${VERSION_ID}"
66+else
67+ EXPECTS="latest/stable"
68+fi
69+
70+echo "Verify it matches the expected version"
71+if [ "${TRACKING}" = "${EXPECTS}" ]; then
72+ echo "lxd-installer installed LXD from the right track (${EXPECTS})"
73+else
74+ echo "lxd-installer did not install LXD from the expected track (${TRACKING} != ${EXPECTS})" >&2
75+ exit 1
76+fi
77+
78diff --git a/lxd-installer-service b/lxd-installer-service
79index 536f316..8812e38 100644
80--- a/lxd-installer-service
81+++ b/lxd-installer-service
82@@ -1,22 +1,27 @@
83 #!/bin/sh
84 lxd_channel() {
85- channel_version="latest"
86+ track="latest"
87
88 # lxd follows a pattern of $VERSION/stable/ubuntu-$VERSION
89 # default in development is "latest"
90 # with major version assigned and opened prior to Ubuntu release
91 # shellcheck disable=SC1091
92 [ -r /etc/os-release ] && . /etc/os-release
93- channel_suffix="stable/ubuntu-${VERSION_ID}"
94- case "${UBUNTU_CODENAME:-""}" in
95- "jammy")
96- channel_version="5.0";;
97- "focal")
98- channel_version="4.0";;
99+ case "${VERSION_ID:-""}" in
100+ "24.04")
101+ track="5.21";;
102+ "22.04")
103+ track="5.0";;
104+ "20.04")
105+ track="4.0";;
106 *)
107 ;;
108 esac
109- echo "${channel_version}/${channel_suffix}"
110+ if [ -n "${VERSION_ID:-""}" ]; then
111+ echo "${track}/stable/ubuntu-${VERSION_ID}"
112+ else
113+ echo "${track}/stable"
114+ fi
115 }
116
117 snap install lxd --channel="$(lxd_channel)" 1>&2

Subscribers

People subscribed via source and target branches