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

Support local unix socket in lxd-migrate - from Incus #13599

Merged
merged 5 commits into from
Jun 13, 2024

Conversation

MusicDin
Copy link
Member

If tool lxd-migrate is capable of connection to a local LXD unix socket, first offer the user option to use the socket.

In addition, go client function for connecting to a LXD unix socket is expanded to check for snapped LXD unix socket.

stgraber and others added 2 commits June 13, 2024 10:20
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
(cherry picked from commit fd5f83b0bf804c97e970898b91a5366168315742)
Signed-off-by: Din Music <din.music@canonical.com>
License: Apache-2.0
Signed-off-by: Din Music <din.music@canonical.com>
@MusicDin MusicDin marked this pull request as ready for review June 13, 2024 12:17
lxd-migrate/utils.go Outdated Show resolved Hide resolved
} else {
path = "/var/lib/lxd/unix.socket"
if !shared.PathIsWritable(shared.HostPath(path)) {
path = "/var/snap/lxd/common/lxd/unix.socket"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change required? How is the lxc command working inside the snap, does it set LXD_DIR env?

Are you adding this for lxd-migrate's benefit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should re-arrange it so that if /var/snap/lxd/common/lxd/unix.socket is writable we use it, otherwise fallback to /var/lib/lxd/unix.socket

Copy link
Member Author

@MusicDin MusicDin Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the lxc command working inside the snap, does it set LXD_DIR env?

Yes.

https://github.com/canonical/lxd-pkg-snap/blob/latest-edge/snapcraft/commands/lxc#L32-L38

Is this change required? Are you adding this for lxd-migrate's benefit?

The lxd-migrate is not snapped, so it will not have LXD_DIR set. Therefore, we can avoid this change and make lxd-migrate check for the snapped LXD socket explicitly.

So, it will benefit lxd-migrate, but I wanted to take this opportunity to change this, as it will also benefit Terraform provider, and probably pylxd which are currently trying which socket exists as they are not snapped.

I think we should re-arrange it so that if /var/snap/lxd/common/lxd/unix.socket is writable we use it, otherwise fallback to /var/lib/lxd/unix.socket

Fixed.

Signed-off-by: Din Music <din.music@canonical.com>
MusicDin and others added 2 commits June 13, 2024 14:07
Signed-off-by: Din Music <din.music@canonical.com>
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
(cherry picked from commit 09e4119da1ca24d2c08a0bd9597a7e6a16803a74)
Signed-off-by: Din Music <din.music@canonical.com>
License: Apache-2.0
@tomponline tomponline merged commit 32a6d73 into canonical:main Jun 13, 2024
29 checks passed
@MusicDin MusicDin deleted the cp/local-lxd-migrate branch June 13, 2024 21:46
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.

None yet

3 participants