Initial support for VMs#911
Draft
jonathan-conder wants to merge 16 commits into
Draft
Conversation
This is something we decided in order to minimize the maintenance overhead of supporting multiple different formats. The cost is that certain operations no longer work: - Restoring a workshop that currently has an old format - Resuming a launch or refresh that began with an old format The first is now a hard error. The second is also a hard error if resuming with `--continue`. If a change was running while the daemon was being updated, then we can still end up with weird workshops that mix two formats. We aim to fix this in the future using a pre-refresh hook. For daemon downgrades, we'll probably require that all workshops are removed first, since old daemons can't anticipate what newer workshops might look like.
It's possible for <NAME>.<PID>.wp to be taken if <PID> matches a project's basename. It's also possible for *.<NAME>-<PID>.wp to be taken, but that doesn't mean <NAME>-<PID>.wp is unavailable. Might as well display it so we can rely on always having a *.wp address.
Now that we remove the NoCloud seed templates, even 20.04 images support the new-style config options.
The current 6/stable LXD snap has reverted some patches to LXCFS which caused canonical/lxd#17983, so this workaround isn't needed. See canonical/lxd-pkg-snap#1236.
With VMs it's difficult to reset the machine-id when taking a snapshot. On the other hand, on first boot the machine-id is set to the SMBIOS UUID, which comes from LXD's volatile.uuid config option. We can do that (in VMs) for subsequent boots by including it in the kernel cmdline. For containers, we might as well match that behaviour. It's easier actually, because we can just use metadata templates. This removes the need to use the MAC address as a DHCP identifier. A workshop will now keep its machine-id from launch until remove.
In order to move away from reinvoking cloud-init when launching or refreshing from a snapshot, we need to move the workshop-specific config to a metadata template (which will be updated on copy, similar to the hostname). It's possible to keep using netplan, but it complains that the instantiated templates have 0644 permissions instead of 0600. The LXD API doesn't provide a way to change this, and we already use some (workshop-agnostic) settings that netplan doesn't support, so I decided to just bypass netplan completely and use systemd-networkd alone. While testing this, I noticed that the hostname systemd-networkd sends over DHCP is immaterial, LXD hard codes it using a config file in /var/snap/lxd/common/lxd/networks/workshopbr0/dnsmasq.hosts/. This actually leads to annoying journal messages because the FQDN is wrong. But luckily dnsmasq ignores it and just looks at the first label, i.e. <WORKSHOP>-<PROJECT>. We can disable this behaviour by setting dns.mode to "dynamic", but I'm holding off on that for now because some weird stuff happened to my network after I enabled it. Prime suspect is NetworkManager thinking it owns the bridge and/or veth devices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
(currently vibe coded for the most part, use at your own risk)
Self-review quick check
Docs
Procedure:
Content:
tutorial/andhow-to/sections).docs/.coverage.yamlupdated, coverage tags added (.. artefact).Or: