Merge ~sdeziel/ubuntu/+source/lxd-agent-loader:prepare-0.6 into ubuntu/+source/lxd-agent-loader:ubuntu/devel

Proposed by Simon Déziel
Status: Merged
Merged at revision: 51f567c2cb6eb466fe76dd2077288c2f77700ef5
Proposed branch: ~sdeziel/ubuntu/+source/lxd-agent-loader:prepare-0.6
Merge into: ubuntu/+source/lxd-agent-loader:ubuntu/devel
Diff against target: 155 lines (+46/-22)
6 files modified
99-lxd-agent.rules (+5/-1)
debian/changelog (+18/-0)
debian/control (+4/-4)
debian/copyright (+3/-3)
lxd-agent-setup (+11/-8)
lxd-agent.service (+5/-6)
Reviewer Review Type Date Requested Status
Lucas Kanashiro (community) Approve
Review via email: mp+458532@code.launchpad.net

Commit message

Sync the systemd unit and udev rules files from upstream

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

This was tested locally:

Create a test VM and copy the built package into it:

```
$ lxc launch ubuntu-daily:24.04 v1 --vm
$ sleep 30
$ lxc file push lxd-agent-loader_0.6_all.deb v1/tmp/
```

Use SSH to access the VM instead of `lxc exec` as the `exec` method depends on the `lxd-agent` that will be bounced during the package upgrade:

```
$ lxc exec v1 -- ssh-import-id sdeziel
$ ssh <email address hidden> apt-get install /tmp/lxd-agent-loader_0.6_all.deb
Warning: Permanently added 'v1.lxd' (ED25519) to the list of known hosts.
Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be upgraded:
  lxd-agent-loader
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4074 B of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /tmp/lxd-agent-loader_0.6_all.deb lxd-agent-loader all 0.6 [4074 B]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
(Reading database ... 65520 files and directories currently installed.)
Preparing to unpack .../lxd-agent-loader_0.6_all.deb ...
Unpacking lxd-agent-loader (0.6) over (0.5) ...
Setting up lxd-agent-loader (0.6) ...
...
```

Confirm `lxc exec` still works:

```
$ lxc exec v1 -- hostname
v1
```

Confirm the `lxd-agent` was bounced during the package upgrade:

```
$ lxc exec v1 -- journalctl -u lxd-agent
...
Jan 12 15:13:27 v1 systemd[1]: Started lxd-agent.service - LXD - agent.
Jan 12 15:13:50 v1 systemd[1]: Stopping lxd-agent.service - LXD - agent...
Jan 12 15:13:50 v1 systemd[1]: lxd-agent.service: Deactivated successfully.
Jan 12 15:13:50 v1 systemd[1]: Stopped lxd-agent.service - LXD - agent.
Jan 12 15:13:50 v1 systemd[1]: Starting lxd-agent.service - LXD - agent...
Jan 12 15:13:51 v1 systemd[1]: Started lxd-agent.service - LXD - agent.
```

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

Thanks for this MP Simon! In general it LGTM. I added some inline comments with a question and some suggestions for the changelog. Feel free to ping me if you have any question.

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

@Lucas, thanks for the review. I believe I addressed all the points you raised.

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

Force pushing seems to have lost my reply to your question re the Standards-Version bump. So before bumping from 4.6.0.1 to 4.6.2 we reviewed https://www.debian.org/doc/debian-policy/upgrading-checklist.html#version-4-6-1 and https://www.debian.org/doc/debian-policy/upgrading-checklist.html#version-4-6-2 and concluded no change was needed.

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

Thanks for answering the question, what you did is the correct way of updating the Standards-Version.

I have some inline comments regarding the changelog entry.

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

@Lucas, thanks again for that constructive feedback. I've massaged the d/changelog based on your good suggestions, please take another look.

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

Thanks Simon! It looks way better now :) I have a simple fix for you inline.

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

@Lucas, lines are now wrapped.

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

Perfect, LGTM!

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

Package uploaded:

Uploading lxd-agent-loader_0.6.dsc
Uploading lxd-agent-loader_0.6.tar.xz
Uploading lxd-agent-loader_0.6_source.buildinfo
Uploading lxd-agent-loader_0.6_source.changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/99-lxd-agent.rules b/99-lxd-agent.rules
2index 82abd4d..74af920 100644
3--- a/99-lxd-agent.rules
4+++ b/99-lxd-agent.rules
5@@ -1 +1,5 @@
6-ACTION=="add", SYMLINK=="virtio-ports/org.linuxcontainers.lxd", TAG+="systemd", ACTION=="add", RUN+="/bin/systemctl start lxd-agent.service"
7+# Start the lxd-agent.service when QEMU serial devices (symlinks in virtio-ports) appear.
8+SYMLINK=="virtio-ports/com.canonical.lxd", TAG+="systemd", ENV{SYSTEMD_WANTS}+="lxd-agent.service"
9+
10+# Legacy serial device name for backward compatibility.
11+SYMLINK=="virtio-ports/org.linuxcontainers.lxd", TAG+="systemd", ENV{SYSTEMD_WANTS}+="lxd-agent.service"
12diff --git a/debian/changelog b/debian/changelog
13index e31a583..5969e98 100644
14--- a/debian/changelog
15+++ b/debian/changelog
16@@ -1,3 +1,21 @@
17+lxd-agent-loader (0.6) noble; urgency=medium
18+
19+ * Update for new virtio-serial device name (LP: #2044859)
20+ - lxd-agent-setup: Add script comment
21+ - lxd-agent.service: Update lxd-agent systemd unit
22+ - 99-lxd-agent.rules: Update udev rules
23+ * Small tweaks to lxd-agent-setup script:
24+ - lxd-agent-setup: do not preserve the ownership during the cp to avoid
25+ chown
26+ - lxd-agent-setup: reduce the size of /run/lxd_agent tmpfs and set
27+ nodev,nosuid,noatime
28+ - lxd-agent-setup: mount the config drive as readonly
29+ - lxd-agent-setup: consistently rely on $PATH to find binaries
30+ * d/control: Update homepage attribute and bump Standards-Version to 4.6.2
31+ * d/copyright: Update copyright year and project source
32+
33+ -- Simon Deziel <simon.deziel@canonical.com> Mon, 27 Nov 2023 17:01:06 -0500
34+
35 lxd-agent-loader (0.5) jammy; urgency=medium
36
37 * Units: Sync with upstream:
38diff --git a/debian/control b/debian/control
39index c12c1e1..64270a4 100644
40--- a/debian/control
41+++ b/debian/control
42@@ -2,8 +2,8 @@ Source: lxd-agent-loader
43 Section: admin
44 Priority: optional
45 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
46-Standards-Version: 4.6.0.1
47-Homepage: https://linuxcontainers.org/
48+Standards-Version: 4.6.2
49+Homepage: https://github.com/canonical/lxd
50 Build-Depends: debhelper-compat (= 13)
51 Rules-Requires-Root: no
52
53@@ -15,5 +15,5 @@ Description: LXD - VM agent loader
54 The LXD VM agent enables access to advanced LXD features such as file
55 transfer and command spawning inside virtual machines run by LXD.
56 .
57- This package contains init scripts that will automatically load the
58- agent and run it when started in a LXD VM.
59+ This package will automatically load and run the agent when started in
60+ a LXD VM.
61diff --git a/debian/copyright b/debian/copyright
62index 528d4c4..49753e2 100644
63--- a/debian/copyright
64+++ b/debian/copyright
65@@ -1,12 +1,12 @@
66 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
67 Upstream-Name: lxd
68 Upstream-Contact: lxc-devel@lists.linuxcontainers.org
69-Source: https://linuxcontainers.org/lxd/downloads
70+Source: https://github.com/canonical/lxd
71 Comment: The content of this package is synced with
72- https://github.com/lxc/lxd/blob/master/lxd/instance/drivers/driver_qemu.go
73+ https://github.com/canonical/lxd/blob/main/lxd/instance/drivers/driver_qemu.go
74
75 Files: *
76-Copyright: 2020 LXD contributors
77+Copyright: 2023 LXD contributors
78 License: Apache-2
79
80 License: Apache-2
81diff --git a/lxd-agent-setup b/lxd-agent-setup
82index 42e16ae..4999c08 100755
83--- a/lxd-agent-setup
84+++ b/lxd-agent-setup
85@@ -1,15 +1,21 @@
86 #!/bin/sh
87+#
88+# Setup script for lxd-agent that is executed by the lxd-agent systemd unit before lxd-agent is started.
89+# The script sets up a temporary mount point, copies data from the mount (including lxd-agent binary),
90+# and then unmounts it. It also ensures appropriate permissions for the LXD agent's runtime directory.
91+#
92+
93 set -eu
94 PREFIX="/run/lxd_agent"
95
96 # Functions.
97 mount_virtiofs() {
98- mount -t virtiofs config "${PREFIX}/.mnt" >/dev/null 2>&1
99+ mount -t virtiofs config "${PREFIX}/.mnt" -o ro >/dev/null 2>&1
100 }
101
102 mount_9p() {
103- /sbin/modprobe 9pnet_virtio >/dev/null 2>&1 || true
104- /bin/mount -t 9p config "${PREFIX}/.mnt" -o access=0,trans=virtio >/dev/null 2>&1
105+ modprobe 9pnet_virtio >/dev/null 2>&1 || true
106+ mount -t 9p config "${PREFIX}/.mnt" -o ro,access=0,trans=virtio >/dev/null 2>&1
107 }
108
109 fail() {
110@@ -22,18 +28,15 @@ fail() {
111 # Setup the mount target.
112 umount -l "${PREFIX}" >/dev/null 2>&1 || true
113 mkdir -p "${PREFIX}"
114-mount -t tmpfs tmpfs "${PREFIX}" -o mode=0700,size=50M
115+mount -t tmpfs tmpfs "${PREFIX}" -o mode=0700,nodev,nosuid,noatime,size=25M
116 mkdir -p "${PREFIX}/.mnt"
117
118 # Try virtiofs first.
119 mount_virtiofs || mount_9p || fail "Couldn't mount virtiofs or 9p, failing."
120
121 # Copy the data.
122-cp -Ra "${PREFIX}/.mnt/"* "${PREFIX}"
123+cp -Ra --no-preserve=ownership "${PREFIX}/.mnt/"* "${PREFIX}"
124
125 # Unmount the temporary mount.
126 umount "${PREFIX}/.mnt"
127 rmdir "${PREFIX}/.mnt"
128-
129-# Fix up permissions.
130-chown -R root:root "${PREFIX}"
131diff --git a/lxd-agent.service b/lxd-agent.service
132index e68a65b..66bc4f3 100644
133--- a/lxd-agent.service
134+++ b/lxd-agent.service
135@@ -1,8 +1,10 @@
136+# Systemd unit for lxd-agent. It ensures the lxd-agent is copied from the shared filesystem before
137+# it is started. The service is triggered dynamically via udev rules when certain virtio-ports are
138+# detected, rather than being enabled at boot.
139 [Unit]
140 Description=LXD - agent
141-Documentation=https://linuxcontainers.org/lxd
142-ConditionPathExists=/dev/virtio-ports/org.linuxcontainers.lxd
143-Before=cloud-init.target cloud-init.service cloud-init-local.service
144+Documentation=https://documentation.ubuntu.com/lxd/en/latest/
145+Before=multi-user.target cloud-init.target cloud-init.service cloud-init-local.service
146 DefaultDependencies=no
147
148 [Service]
149@@ -14,6 +16,3 @@ Restart=on-failure
150 RestartSec=5s
151 StartLimitInterval=60
152 StartLimitBurst=10
153-
154-[Install]
155-WantedBy=multi-user.target

Subscribers

People subscribed via source and target branches