]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
fix #1602: allow to delete 'ignored' services over API
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 23 Jan 2019 09:34:40 +0000 (10:34 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 25 Jan 2019 08:31:45 +0000 (09:31 +0100)
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@proxmox.com>
src/PVE/API2/HA/Resources.pm

index 637d72b2f5c453feac3d8e5ae4e8dd73019e940b..ee6f98eb8322a7894a3974bc733fa38d02b7d6b9 100644 (file)
@@ -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};