The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/1745
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) === The problem here is that depending on the migration type, we might delete the container on the source host directly after the migrate returns, which can race with defer and cause the delete to fail. Instead, let's explicitly delete the stuff we need to before returning, so there is no race. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From eb2a87f8d939499a556b6e1c409ea2abd096318e Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Thu, 10 Mar 2016 18:10:00 -0700 Subject: [PATCH] migration: don't defer cleanup of sending snapshots The problem here is that depending on the migration type, we might delete the container on the source host directly after the migrate returns, which can race with defer and cause the delete to fail. Instead, let's explicitly delete the stuff we need to before returning, so there is no race. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxd/migrate.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lxd/migrate.go b/lxd/migrate.go index 0150e66..aee88c1 100644 --- a/lxd/migrate.go +++ b/lxd/migrate.go @@ -341,19 +341,20 @@ func (s *migrationSourceWs) Do(op *operation) error { driver, _ = rsyncMigrationSource(s.container) } - defer driver.Cleanup() - if err := driver.SendWhileRunning(s.fsConn); err != nil { + driver.Cleanup() s.sendControl(err) return err } if s.live { if header.Criu == nil { + driver.Cleanup() err := fmt.Errorf("Got no CRIU socket type for live migration") s.sendControl(err) return err } else if *header.Criu != CRIUType_CRIU_RSYNC { + driver.Cleanup() err := fmt.Errorf("Formats other than criu rsync not understood") s.sendControl(err) return err @@ -361,6 +362,7 @@ func (s *migrationSourceWs) Do(op *operation) error { checkpointDir, err := ioutil.TempDir("", "lxd_checkpoint_") if err != nil { + driver.Cleanup() s.sendControl(err) return err } @@ -374,6 +376,7 @@ func (s *migrationSourceWs) Do(op *operation) error { } if err != nil { + driver.Cleanup() log, err2 := GetCRIULogErrors(checkpointDir, "dump") /* couldn't find the CRIU log file which means we @@ -396,16 +399,20 @@ func (s *migrationSourceWs) Do(op *operation) error { * p.haul's protocol, it will make sense to do these in parallel. */ if err := RsyncSend(shared.AddSlash(checkpointDir), s.criuConn); err != nil { + driver.Cleanup() s.sendControl(err) return err } if err := driver.SendAfterCheckpoint(s.fsConn); err != nil { + driver.Cleanup() s.sendControl(err) return err } } + driver.Cleanup() + msg := MigrationControl{} if err := s.recv(&msg); err != nil { s.disconnect()
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel