[pve-devel] [PATCH ha-manager 2/3] fix check if a resource migrated correctly
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Jan 27 13:16:34 CET 2016
Move the check from exec_resource_agents to the migrate method of
the resource plugins so that we may delete the traces from the
additional method 'is_on_node' which was intended for this
purpose.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/LRM.pm | 4 ++--
src/PVE/HA/Resources/PVECT.pm | 5 +++++
src/PVE/HA/Resources/PVEVM.pm | 5 +++++
src/PVE/HA/Sim/Resources.pm | 13 +++----------
src/PVE/HA/Sim/Resources/VirtCT.pm | 2 +-
5 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm
index a1d466f..1894f3c 100644
--- a/src/PVE/HA/LRM.pm
+++ b/src/PVE/HA/LRM.pm
@@ -683,10 +683,10 @@ sub exec_resource_agent {
my $online = ($cmd eq 'migrate') ? 1 : 0;
- $plugin->migrate($haenv, $id, $target, $online);
+ my $res = $plugin->migrate($haenv, $id, $target, $online);
# something went wrong if service is still on this node
- if ($plugin->is_on_node($haenv, $nodename, $id)) {
+ if (!$res) {
$haenv->log("err", "service $sid not moved (migration error)");
return ERROR;
}
diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm
index 7aa2f1c..781a36a 100644
--- a/src/PVE/HA/Resources/PVECT.pm
+++ b/src/PVE/HA/Resources/PVECT.pm
@@ -96,8 +96,13 @@ sub migrate {
$class->shutdown($haenv, $id);
}
+ my $oldconfig = $class->config_file($id, $nodename);
+
my $upid = PVE::API2::LXC->migrate_vm($params);
$haenv->upid_wait($upid);
+
+ # check if vm really moved
+ return !(-f $oldconfig);
}
sub check_running {
diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm
index 3d626f7..fd96ed3 100644
--- a/src/PVE/HA/Resources/PVEVM.pm
+++ b/src/PVE/HA/Resources/PVEVM.pm
@@ -96,8 +96,13 @@ sub migrate {
$class->shutdown($haenv, $id);
}
+ my $oldconfig = $class->config_file($id, $nodename);
+
my $upid = PVE::API2::Qemu->migrate_vm($params);
$haenv->upid_wait($upid);
+
+ # check if vm really moved
+ return !(-f $oldconfig);
}
sub check_running {
diff --git a/src/PVE/HA/Sim/Resources.pm b/src/PVE/HA/Sim/Resources.pm
index 7e13483..f41d6ee 100644
--- a/src/PVE/HA/Sim/Resources.pm
+++ b/src/PVE/HA/Sim/Resources.pm
@@ -34,16 +34,6 @@ sub config_file {
return "$nodename/$service_type:$id";
}
-sub is_on_node {
- my ($class, $haenv, $node, $id) = @_;
-
- my $service_type = $class->type();
- my $hardware = $haenv->hardware();
- my $ss = $hardware->read_service_status($node);
-
- return defined($ss->{"$service_type:$id"}) ? 1 : 0;
-}
-
sub start {
my ($class, $haenv, $id) = @_;
@@ -113,6 +103,9 @@ sub migrate {
# ensure that the old node doesn't has the service anymore
delete $ss->{$sid};
$hardware->write_service_status($nodename, $ss);
+
+ # check if resource really moved
+ return defined($ss->{$sid}) ? 0 : 1;
}
diff --git a/src/PVE/HA/Sim/Resources/VirtCT.pm b/src/PVE/HA/Sim/Resources/VirtCT.pm
index 10515f7..2d54ab9 100644
--- a/src/PVE/HA/Sim/Resources/VirtCT.pm
+++ b/src/PVE/HA/Sim/Resources/VirtCT.pm
@@ -29,7 +29,7 @@ sub migrate {
$online = 0;
}
- $class->SUPER::migrate($haenv, $id, $target, $online);
+ return $class->SUPER::migrate($haenv, $id, $target, $online);
}
--
2.1.4
More information about the pve-devel
mailing list