Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LXD server UUID file #12544

Merged
merged 2 commits into from
Nov 23, 2023
Merged

Add LXD server UUID file #12544

merged 2 commits into from
Nov 23, 2023

Conversation

roosterfish
Copy link
Contributor

This takes the required bits from the Dell PowerFlex PR in order to introduce a new UUID file which is unique for every LXD server.

The UUID can be retrieved via the daemons State struct using the ServerUUID field. This is comparable with the contents of /etc/machine-id or /var/lib/dbus/machine-id which can be decoded from hexadecimal to its 128 bit UUID representation. However using those files has dependencies on dbus and systemd. See https://wiki.debian.org/MachineId.

Having a unique UUID file per daemon also ensures that multiple instances of LXD on the same machine don't use the same UUID.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@simondeziel
Copy link
Member

@roosterfish I don't have much context on this but was wondering why another UUID would be needed? We already have one:

$ lxc launch --vm ubuntu-daily:22.04 j
Creating j
Starting j

$ lxc config show j | grep uuid
  volatile.uuid: b6b8ed20-dbec-4c72-947a-2abbfa97f586
  volatile.uuid.generation: b6b8ed20-dbec-4c72-947a-2abbfa97f586

$ lxc exec j -- cat /sys/devices/virtual/dmi/id/product_uuid
b6b8ed20-dbec-4c72-947a-2abbfa97f586

$ lxc exec j -- cat /etc/machine-id
b6b8ed20dbec4c72947a2abbfa97f586

I'm pretty sure the /sys/devices/virtual/dmi/id/product_uuid file is populated by the kernel itself, so no dbus nor systemd involved there. Could this file be used instead?

@tomponline
Copy link
Member

@simondeziel this came up as part of #12304 as each cluster member (not per instance) requires a persistent unique UUID for NVME.

The latter two examples were discussed as we consulted with https://0pointer.de/blog/projects/ids.html during the discussion.

DMI ID was not suitable because if hardware changes (such as motherboard) it would change.

The nearest suitable one was /var/lib/dbus/machine-id (which /etc/machine-id is derived from), but we observed this wasn't present on all systems (such as Alpine which didn't have dbus installed by default).

We decided to just generated a UUID and store it persistently as the most reliable way to get a per-host ID without any external dependencies.

lxd/daemon.go Outdated Show resolved Hide resolved
lxd/daemon.go Outdated Show resolved Hide resolved
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@simondeziel
Copy link
Member

@simondeziel this came up as part of #12304 as each cluster member (not per instance) requires a persistent unique UUID for NVME.

Yep, that was the root of my confusion, I was thinking of a per-instance UUID, sorry for the noise.

@tomponline tomponline merged commit c869cab into canonical:main Nov 23, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants