[pve-devel] [PATCH container 1/2] migrate: restart in phase1

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Oct 12 10:08:07 CEST 2017


to reduce downtime and for correct error handling. otherwise if phase1
fails, we'd still attempt to restart the container on the target node

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/LXC/Migrate.pm | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index 93446d7..cab2aed 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -318,6 +318,14 @@ sub phase1 {
     $self->{conf_migrated} = 1;
 
     $self->switch_replication_job_target();
+
+    # in restart mode, we start the container on the target node
+    # after all volumes and the config file have been migrated
+    if ($self->{opts}->{restart} && $self->{was_running}) {
+	$self->log('info', "start container on target node");
+	my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'start', $vmid, '--skip-lock'];
+	$self->cmd($cmd);
+    }
 }
 
 sub phase1_cleanup {
@@ -366,14 +374,6 @@ sub final_cleanup {
 	my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'unlock', $vmid ];
 	$self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock");	
     }
-
-    # in restart mode, we start the container on the target node
-    # after migration
-    if ($self->{opts}->{restart} && $self->{was_running}) {
-	$self->log('info', "start container on target node");
-	my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'start', $vmid];
-	$self->cmd($cmd);
-    }
 }
 
 1;
-- 
2.14.1





More information about the pve-devel mailing list