[lxc-devel] [lxd/master] migration: fix btrfs live migration
brauner on Github
lxc-bot at linuxcontainers.org
Wed Apr 25 14:11:06 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180425/581f21e0/attachment.bin>
-------------- next part --------------
From 795d74cafced1b4c39c6623d197754ef9d42a83c Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 25 Apr 2018 16:09:42 +0200
Subject: [PATCH] migration: fix btrfs live migration
Closes #4475.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/container_lxc.go | 5 +++++
lxd/migrate_container.go | 4 ++++
lxd/storage_btrfs.go | 10 ++++++++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 63e137031..640dbc552 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -5104,6 +5104,11 @@ func (c *containerLXC) Migrate(args *CriuMigrationArgs) error {
opts.PredumpDir = fmt.Sprintf("../%s", args.preDumpDir)
}
+ if !c.IsRunning() {
+ // otherwise the migration will needlessly fail
+ args.stop = false
+ }
+
migrateErr = c.c.Migrate(args.cmd, opts)
}
diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index 9e1bd8aca..2d583fc28 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -993,6 +993,10 @@ func (c *migrationSink) Do(migrateOp *operation) error {
for {
select {
case err = <-restore:
+ if err != nil {
+ disconnector()
+ return err
+ }
controller(err)
return err
case msg, ok := <-source:
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 6c2e02f4f..67ef92d95 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -2097,8 +2097,6 @@ func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots [
return err
}
- defer os.RemoveAll(btrfsPath)
-
err = btrfsSubVolumesDelete(receivedSnapshot)
if err != nil {
logger.Errorf("Failed to delete BTRFS subvolume \"%s\": %s.", btrfsPath, err)
@@ -2184,6 +2182,7 @@ func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots [
wrapper := StorageProgressWriter(op, "fs_progress", *snap.Name)
err = btrfsRecv(*(snap.Name), tmpSnapshotMntPoint, snapshotMntPoint, true, wrapper)
+ os.RemoveAll(tmpSnapshotMntPoint)
if err != nil {
return err
}
@@ -2215,6 +2214,13 @@ func (s *storageBtrfs) MigrationSink(live bool, container container, snapshots [
return err
}
+ if live {
+ err = btrfsRecv("", tmpContainerMntPoint, containerMntPoint, false, wrapper)
+ if err != nil {
+ return err
+ }
+ }
+
return nil
}
More information about the lxc-devel
mailing list