snap restart lxd is causing systemd units that were not previously running to be started

Bug #2028141 reported by Gabriel Mougard
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
New
Undecided
Unassigned

Bug Description

An unintended behavior in the `snap restart lxd` command has been observed, resulting in the undesired creation of an `lxdbr0` interface and a modification to the default profile. This issue arises even when a different existing bridge is specified during `lxd init`. The precise steps to reproduce the problem are as follows:

1. Install LXD using `snap install lxd`.

2. Run `lxd init` and specify an existing bridge (i.e., `lxdbr1`) instead of creating a new one.

3. Confirm there is no `lxdbr0` using `lxc network list` and check that the default profile is configured as intended using `lxc profile show default`.

4. Restart LXD using `snap restart lxd`.

5.Run `lxc network list` and `lxc profile show default` again. At this point, a `lxdbr0` interface exists, and the default profile has been altered to use it.

It is important to note that this issue is not triggered when using the alternative commands `snap stop lxd` followed by `snap start lxd`, nor when using `sudo systemctl reload snap.lxd.daemon`. It appears to be specific to `snap restart lxd`, suggesting a potential bug within the `snap restart` command itself.

As mentioned in the original gh discussion thread, the problem seems related to the `snap restart` command starting sub-units, like the `lxd-user` process, even if they weren't previously running. The undesired side-effect of this behavior is an API request being sent to LXD upon `snap restart lxd` which creates the `lxdbr0` network, even if this is not desired or requested by the user.

A current workaround for this issue is to have an interface named `lxdbr0` present, either by leaving the unwanted one that LXD creates, or by naming an unmanaged interface as `lxdbr0`. Without this, the `snap restart lxd` command will create `lxdbr0` and change the default profile.

---

Here is the link to the github thread of the original issue : https://github.com/canonical/lxd/issues/11906

Thanks

description: updated
Revision history for this message
Thomas Parrott (tomparrott) wrote :
Download full text (4.5 KiB)

The description above is a side effect of the apparent behaviour of `snap restart lxd`.

Example:

On a fresh ubuntu:22.04 VM:

```
systemctl | grep snap.lxd
  snap-lxd-25112.mount loaded active mounted Mount unit for lxd, revision 25112
  snap.lxd.daemon.unix.socket loaded active listening Socket unix for snap application lxd.daemon
  snap.lxd.user-daemon.unix.socket loaded active listening Socket unix for snap application lxd.user-daemon
```

Note that the sockets are in a listening state for lxd.daemon and lxd.user-daemon.

Then if we do `snap stop lxd` followed by `snap start lxd` we can see the systemd units are restored to the same state as before (listening).

```
root@v1:~# snap stop lxd
Stopped.
root@v1:~# systemctl | grep snap.lxd
  snap-lxd-25112.mount loaded active mounted Mount unit for lxd, revision 25112
```

```
root@v1:~# systemctl | grep snap.lxd
  snap-lxd-25112.mount loaded active mounted Mount unit for lxd, revision 25112
root@v1:~# snap start lxd
Started.
root@v1:~# systemctl | grep snap.lxd
  snap-lxd-25112.mount loaded active mounted Mount unit for lxd, revision 25112
  snap.lxd.daemon.unix.socket loaded active listening Socket unix for snap application lxd.daemon
  snap.lxd.user-daemon.unix.socket loaded active listening Socket unix for snap application lxd.user-daemon
```

But if we now do `snap restart lxd` (which to my mind should be equivalent of doing `snap stop lxd` and then`snap start lxd`) we end up with something quite different:

```
root@v1:~# snap restart lxd
Restarted.
root@v1:~# systemctl | grep snap.lxd
  snap-lxd-25112.mount loaded active mounted Mount unit for lxd, revision 25112
  var-snap-lxd-common-ns-mntns.mount loaded active mounted /var/snap/lxd/common/ns/mntns
  var-snap-lxd-common-ns-shmounts.mount loaded active mounted /var/snap/lxd/common/ns/shmounts
  var-snap-lxd-common-ns.mount loaded active mounted /var/snap/lxd/common/ns
  snap.lxd.daemon.service loaded active running Service for snap application lxd.daemon
  snap.lxd.user-daemon.service loaded active running Service for snap applicati...

Read more...

summary: - Unexpected Creation of lxdbr0 and profile modification on `snap restart
- lxd`
+ snap restart lxd is causing systemd units that were not previously
+ running to be started
Revision history for this message
Thomas Parrott (tomparrott) wrote :

Hi there,

Is there any update on this issue?

Thanks
Tom

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.