]> git.proxmox.com Git - pve-container.git/commitdiff
Fix #1547: on migration abort, the CT starts again
authorAlwin Antreich <a.antreich@proxmox.com>
Fri, 9 Mar 2018 15:14:59 +0000 (16:14 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 12 Mar 2018 12:14:14 +0000 (13:14 +0100)
When a migration fails, the final_cleanup phase now starts the container
on the source node again, if it was a migration in restart_mode and the
CT was running.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
src/PVE/API2/LXC/Status.pm
src/PVE/LXC.pm
src/PVE/LXC/Migrate.pm

index 39882e26e9514f3f6c834acc3ef8e7ff83d0769a..976f264a73a4bcc1755ce577957db1aaff781f19 100644 (file)
@@ -187,13 +187,7 @@ __PACKAGE__->register_method({
 
                    my $storage_cfg = cfs_read_file("storage.cfg");
 
-                   PVE::LXC::update_lxc_config($vmid, $conf);
-
-                   local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
-
-                   my $cmd = ['systemctl', 'start', "pve-container\@$vmid"];
-
-                   run_command($cmd);
+                   PVE::LXC::vm_start($vmid, $conf, $skiplock);
 
                    return;
                };
index 80d79e19c2bf9dd2323fefe1b50b2037f6dc773a..b03e726ff29f2bd0a2879dec095dea39ffec1698 100644 (file)
@@ -1515,6 +1515,20 @@ sub userns_command {
     return [];
 }
 
+sub vm_start {
+    my ($vmid, $conf, $skiplock) = @_;
+
+    update_lxc_config($vmid, $conf);
+
+    local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
+
+    my $cmd = ['systemctl', 'start', "pve-container\@$vmid"];
+
+    PVE::Tools::run_command($cmd);
+
+    return;
+}
+
 # Helper to stop a container completely and make sure it has stopped completely.
 # This is necessary because we want the post-stop hook to have completed its
 # unmount-all step, but post-stop happens after lxc puts the container into the
index ee78a5f43a57f103e61b58ae1f0c968a073eab4d..1364b8d480c0ce108b0c67f410b2577ab5732ada 100644 (file)
@@ -354,6 +354,13 @@ sub final_cleanup {
        if (my $err = $@) {
            $self->log('err', $err);
        }
+       # in restart mode, we start the container on the source node
+       # on migration error
+       if ($self->{opts}->{restart} && $self->{was_running}) {
+           $self->log('info', "start container on source node");
+           my $skiplock = 1;
+           PVE::LXC::vm_start($vmid, $self->{vmconf}, $skiplock);
+       }
     } else {
        my $cmd = [ @{$self->{rem_ssh}}, 'pct', 'unlock', $vmid ];
        $self->cmd_logerr($cmd, errmsg => "failed to clear migrate lock");