[pve-devel] [PATCH ha-manager] fix #1602: allow to delete 'ignored' services over API

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jan 23 10:34:40 CET 2019


service_is_ha_managed returns false if a service is in the resource
configuration but marked as 'ignore', as for the internal stack it is
as it wasn't HA managed at all.

But user should be able to remvoe it from the configuration easily
even in this state, without setting the requesttate to anything else
first.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/API2/HA/Resources.pm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index 10acedf..0fd631a 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -296,12 +296,18 @@ __PACKAGE__->register_method ({
 
 	my ($sid, $type, $name) = PVE::HA::Config::parse_sid(extract_param($param, 'sid'));
 
-	PVE::HA::Config::service_is_ha_managed($sid);
+	my $cfg = PVE::HA::Config::read_resources_config();
+
+	# cannot use service_is_ha_managed as it ignores 'ignored' services,
+	# see bug report #1602
+	if (!defined($cfg->{ids}) || !defined($cfg->{ids}->{$sid})) {
+	    die "cannot delete service '$sid', not HA managed!\n";
+	}
 
 	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
-		my $cfg = PVE::HA::Config::read_resources_config();
+		$cfg = PVE::HA::Config::read_resources_config();
 
 		delete $cfg->{ids}->{$sid};
 
-- 
2.20.1





More information about the pve-devel mailing list