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

lxd-migrate/main: Drop lxd-bridge bits dating from LXD 2.0 #166

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions lxd-migrate/lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,29 +284,6 @@ func (d *lxdDaemon) uninstall() error {
return err
}

// Check if we can get rid of liblxc1, liblxc-common and lxcfs too
//// Ubuntu 18.04
err = packagesRemovable([]string{"liblxc1", "liblxc-common", "lxcfs"})
if err == nil {
_, err := shared.RunCommand("apt-get", "remove", "--purge", "--yes", "liblxc1", "liblxc-common", "lxcfs")
if err != nil {
return err
}

return nil
}

//// Ubuntu 16.04
err = packagesRemovable([]string{"liblxc1", "lxc-common", "lxcfs"})
if err == nil {
_, err := shared.RunCommand("apt-get", "remove", "--purge", "--yes", "liblxc1", "lxc-common", "lxcfs")
if err != nil {
return err
}

return nil
}

return nil
}

Expand Down
49 changes: 0 additions & 49 deletions lxd-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ func run() error {
if err == nil {
fmt.Printf("The source server is empty, no migration needed.\n")

if shared.PathExists("/usr/lib/lxd/lxd-bridge") {
shared.RunCommand("/usr/lib/lxd/lxd-bridge", "stop")

if shared.PathExists("/etc/default/lxd-bridge") {
_, err = shared.RunCommand("mv", "/etc/default/lxd-bridge", "/etc/default/lxd-bridge.migrated")
if err != nil {
return fmt.Errorf("Failed to move the bridge configuration: %v", err)
}
}
}

return removePackages(src, dst)
}

Expand Down Expand Up @@ -202,21 +191,6 @@ func run() error {
return fmt.Errorf("Failed to update the storage pools: %v", err)
}

// Copy the network config
if src.networks == nil && dst.networks == nil {
fmt.Printf("=> Moving bridge configuration\n")

// Atempt to stop lxd-bridge
systemdCtl("stop", "lxd-bridge")

if shared.PathExists("/etc/default/lxd-bridge") {
_, err = shared.RunCommand("mv", "/etc/default/lxd-bridge", "/var/snap/lxd/common/lxd-bridge/config")
if err != nil {
return fmt.Errorf("Failed to move the bridge configuration: %v", err)
}
}
}

// Start the destination LXD
fmt.Printf("=> Starting the destination LXD\n")
err = dst.start()
Expand All @@ -238,29 +212,6 @@ func run() error {
return err
}

if src.networks == nil && dst.networks != nil {
// Update the network configuration
fmt.Printf("=> Converting the network configuration\n")
_, err = shared.RunCommand("upgrade-bridge")
if err != nil {
return fmt.Errorf("Failed to convert the network configuration: %v", err)
}

// Reload LXD post-update (to re-create the bridge if needed)
fmt.Printf("=> Reloading LXD after network update\n")
err = dst.reload()
if err != nil {
return err
}

// Wait for LXD to be online
fmt.Printf("=> Waiting for LXD to come online\n")
err = dst.wait(false)
if err != nil {
return err
}
}

// Show the updated destination server
fmt.Printf("\n=== Destination server\n")
err = dst.update()
Expand Down
151 changes: 0 additions & 151 deletions lxd-migrate/scripts/upgrade-bridge

This file was deleted.

3 changes: 0 additions & 3 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1493,12 +1493,9 @@ parts:
# Build the binaries
go build -o "${CRAFT_PART_INSTALL}/bin/lxd-migrate" -tags=libsqlite3 ./

# Install bridge script
mkdir -p ${CRAFT_PART_INSTALL}/bin/
cp scripts/upgrade-bridge ${CRAFT_PART_INSTALL}/bin/upgrade-bridge
prime:
- bin/lxd-migrate
- bin/upgrade-bridge

lxd-ui:
source: https://github.com/canonical/lxd-ui
Expand Down
5 changes: 1 addition & 4 deletions snapcraft/commands/lxc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ fi

# Migrate data if needed
if [ ! -d "${SNAP_USER_COMMON}/config" ]; then
if [ -d "${SNAP_USER_DATA}/.config/lxc" ]; then
mv "${SNAP_USER_DATA}/.config/lxc" "${SNAP_USER_COMMON}/config" || true
rmdir "${SNAP_USER_DATA}/.config/" || true
elif [ -d "${SNAP_REAL_HOME}/.config/lxc" ]; then
if [ -d "${SNAP_REAL_HOME}/.config/lxc" ]; then
cp -r "${SNAP_REAL_HOME}/.config/lxc" "${SNAP_USER_COMMON}/config" || true
fi

Expand Down
Loading