[pve-devel] [PATCH ha-manager] Resource/API: abort early if resource in error state
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Nov 24 16:27:58 CET 2016
If a service is in error state the single state change command that
can make sense is setting the disabled request state.
Thus abort on all other commands early to enhance user experience.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/API2/HA/Resources.pm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index 621c9e6..f1fac54 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -187,6 +187,14 @@ __PACKAGE__->register_method ({
if !$group_cfg->{ids}->{$group};
}
+ my $service_status = PVE::HA::Config::get_service_status($sid);
+ if ($service_status->{state} eq 'error' &&
+ !(defined($param->{state}) && $param->{state} eq 'disabled')) {
+ # service in error state, must be disabled first before new state
+ # request can be executed
+ die "service '$sid' in error state, must be disabled and fixed first\n";
+ }
+
PVE::HA::Config::lock_ha_domain(
sub {
@@ -288,6 +296,11 @@ __PACKAGE__->register_method ({
PVE::HA::Config::service_is_ha_managed($sid);
+ my $service_status = PVE::HA::Config::get_service_status($sid);
+ if ($service_status->{state} eq 'error') {
+ die "service '$sid' in error state, must be disabled and fixed first\n";
+ }
+
PVE::HA::Config::queue_crm_commands("migrate $sid $param->{node}");
return undef;
@@ -319,6 +332,11 @@ __PACKAGE__->register_method ({
PVE::HA::Config::service_is_ha_managed($sid);
+ my $service_status = PVE::HA::Config::get_service_status($sid);
+ if ($service_status->{state} eq 'error') {
+ die "service '$sid' in error state, must be disabled and fixed first\n";
+ }
+
PVE::HA::Config::queue_crm_commands("relocate $sid $param->{node}");
return undef;
--
2.1.4
More information about the pve-devel
mailing list