The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6546
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Fixes bug where 2 phase sync was not supported when using new storage layer.
From 37fbfa8f7c502c69380a80812dfa90bce529765d Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Tue, 3 Dec 2019 15:40:21 +0000 Subject: [PATCH 1/4] lxd/storage/backend/lxd: Comment typos Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/backend_lxd.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go index 18840f0008..a347fb62e8 100644 --- a/lxd/storage/backend_lxd.go +++ b/lxd/storage/backend_lxd.go @@ -842,8 +842,8 @@ func (b *lxdBackend) CreateInstanceFromMigration(inst instance.Instance, conn io }() // If the negotiated migration method is rsync and the instance's base image is - // already on the host then pre-create the instance's volume using the locla image - // to try and speed up the rsync of the incoming volume by avoiding the new to + // already on the host then pre-create the instance's volume using the local image + // to try and speed up the rsync of the incoming volume by avoiding the need to // transfer the base image files too. if args.MigrationType.FSType == migration.MigrationFSType_RSYNC { fingerprint := inst.ExpandedConfig()["volatile.base_image"] From 33be0f9b99db85d3ecb081059616d12f8662c217 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Wed, 4 Dec 2019 08:56:06 +0000 Subject: [PATCH 2/4] lxd/storage/drivers/drive/dir: Add support for 2-phase migration Adds support for a final rootfs volume sync stage which is sometimes requested by sender. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/driver_dir.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lxd/storage/drivers/driver_dir.go b/lxd/storage/drivers/driver_dir.go index 2a6b83c6b3..7d8a0563bd 100644 --- a/lxd/storage/drivers/driver_dir.go +++ b/lxd/storage/drivers/driver_dir.go @@ -431,7 +431,24 @@ func (d *dir) CreateVolumeFromMigration(vol Volume, conn io.ReadWriteCloser, vol wrapper = migration.ProgressTracker(op, "fs_progress", vol.name) } - return rsync.Recv(path, conn, wrapper, volTargetArgs.MigrationType.Features) + err = rsync.Recv(path, conn, wrapper, volTargetArgs.MigrationType.Features) + if err != nil { + return err + } + + // Receive the final main volume sync if needed. + if volTargetArgs.Live { + if volTargetArgs.TrackProgress { + wrapper = migration.ProgressTracker(op, "fs_progress", vol.name) + } + + err = rsync.Recv(path, conn, wrapper, volTargetArgs.MigrationType.Features) + if err != nil { + return err + } + } + + return nil }, op) if err != nil { return err From c9f000ad7828f419b7b95fc45e0318be60311795 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Wed, 4 Dec 2019 08:57:06 +0000 Subject: [PATCH 3/4] lxd/migration/migration/volumes: Adds Live property to VolumeTargetArgs Allows source node to indicate to target node that a 2-phase volume sync is needed. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/migration/migration_volumes.go | 1 + 1 file changed, 1 insertion(+) diff --git a/lxd/migration/migration_volumes.go b/lxd/migration/migration_volumes.go index 18b329d1a9..391a0e8353 100644 --- a/lxd/migration/migration_volumes.go +++ b/lxd/migration/migration_volumes.go @@ -34,6 +34,7 @@ type VolumeTargetArgs struct { MigrationType Type TrackProgress bool Refresh bool + Live bool } // TypesToHeader converts one or more Types to a MigrationHeader. It uses the first type argument From c3661764266e2fb0aa12a9c7c71aaa19c436f3b3 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Wed, 4 Dec 2019 09:00:48 +0000 Subject: [PATCH 4/4] lxd/migrate/container: Add support for 2-phase sync in migrationSink.Do() This fixes a bug where the criu property was not being populated in the migration response header. This field is leveraged in the source to indicate whether the instance is running and whether a 2-phase sync is needed so its important this is sent back even if criu not being used. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/migrate_container.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go index 9c8f5787bf..b33dcd37f0 100644 --- a/lxd/migrate_container.go +++ b/lxd/migrate_container.go @@ -893,6 +893,7 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation) MigrationType: respType, Refresh: args.Refresh, // Indicate to receiver volume should exist. TrackProgress: false, // Do not use a progress tracker on receiver. + Live: args.Live, // Indicates we will get a final rootfs sync. } // At this point we have already figured out the parent container's root @@ -950,7 +951,6 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation) respHeader = migration.MigrationHeader{ Fs: &myType, - Criu: criuType, Snapshots: offerHeader.Snapshots, SnapshotNames: offerHeader.SnapshotNames, Refresh: &c.refresh, @@ -985,6 +985,9 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation) return fmt.Errorf("Instance type not supported") } + // Add CRIU info to response. + respHeader.Criu = criuType + if c.refresh { // Get our existing snapshots. targetSnapshots, err := c.src.instance.Snapshots() @@ -1078,7 +1081,12 @@ func (c *migrationSink) Do(state *state.State, migrateOp *operations.Operation) fsConn = c.src.fsConn } + // Default to not expecting to receive the final rootfs sync. sendFinalFsDelta := false + + // If we are doing a stateful live transfer or the CRIU type indicates we + // are doing a stateless transfer with a running instance then we should + // expect the source to send us a final rootfs sync. if live { sendFinalFsDelta = true }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel