[pve-devel] [PATCH container 1/2] Fix #1547: on migration abort, the CT starts again
Alwin Antreich
a.antreich at proxmox.com
Fri Mar 9 16:14:59 CET 2018
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 at proxmox.com>
---
src/PVE/API2/LXC/Status.pm | 8 +-------
src/PVE/LXC.pm | 14 ++++++++++++++
src/PVE/LXC/Migrate.pm | 7 +++++++
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
index 39882e2..976f264 100644
--- a/src/PVE/API2/LXC/Status.pm
+++ b/src/PVE/API2/LXC/Status.pm
@@ -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;
};
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 80d79e1..1b0da19 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -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
diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index ee78a5f..dfe8f55 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -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");
--
2.11.0
More information about the pve-devel
mailing list