[lxc-devel] [lxd/master] lxd/migrate/container: Merges duplicate multi sync logic and adds comments

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jan 13 09:21:41 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200113/ea186abb/attachment.bin>
-------------- next part --------------
From f593d6c028714f5175d5f7e9adfd0ef36d7dc7c8 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 13 Jan 2020 09:10:25 +0000
Subject: [PATCH] lxd/migrate/container: Merges duplicate multi sync logic and
 adds comments

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/migrate_container.go | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index 74d6235652..4f4b08128e 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -499,6 +499,12 @@ func (s *migrationSourceWs) Do(state *state.State, migrateOp *operations.Operati
 	}
 
 	volSourceArgs := &migration.VolumeSourceArgs{}
+
+	// If s.live is true or Criu is set to CRIUTYPE_NONE rather than nil, it indicates that the
+	// source instance is running and that we should do a two stage transfer to minimize downtime.
+	// Indicate this info to the storage driver so that it can alter its behaviour if needed.
+	volSourceArgs.MultiSync = s.live || (respHeader.Criu != nil && *respHeader.Criu == migration.CRIUType_NONE)
+
 	if pool != nil {
 		rsyncBwlimit = pool.Driver().Config()["rsync.bwlimit"]
 		migrationType, err = migration.MatchTypes(respHeader, migration.MigrationFSType_RSYNC, poolMigrationTypes)
@@ -518,8 +524,6 @@ func (s *migrationSourceWs) Do(state *state.State, migrateOp *operations.Operati
 		volSourceArgs.MigrationType = migrationType
 		volSourceArgs.Snapshots = sendSnapshotNames
 		volSourceArgs.TrackProgress = true
-		volSourceArgs.MultiSync = s.live || (respHeader.Criu != nil && *respHeader.Criu == migration.CRIUType_NONE)
-
 		err = pool.MigrateInstance(s.instance, &shared.WebsocketIO{Conn: s.fsConn}, volSourceArgs, migrateOp)
 		if err != nil {
 			return abort(err)
@@ -746,11 +750,10 @@ func (s *migrationSourceWs) Do(state *state.State, migrateOp *operations.Operati
 		}
 	}
 
-	// If s.live is true or Criu is set to CRIUTYPE_NONE rather than nil, it indicates
-	// that the source container is running and that we should do a two stage transfer
-	// to minimize downtime.
-	if s.live || (respHeader.Criu != nil && *respHeader.Criu == migration.CRIUType_NONE) {
+	// Perform final sync if in multi sync mode.
+	if volSourceArgs.MultiSync {
 		if pool != nil {
+			// Indicate to the storage driver we are doing final sync.
 			volSourceArgs.FinalSync = true
 
 			err = pool.MigrateInstance(s.instance, &shared.WebsocketIO{Conn: s.fsConn}, volSourceArgs, migrateOp)


More information about the lxc-devel mailing list