]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #2580: api/delete: drop VM from HA resources if purge is set
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Mar 2020 12:31:41 +0000 (13:31 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Mar 2020 12:39:00 +0000 (13:39 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Qemu.pm
debian/control

index 036d95d5ac4001fe5ded9165dbf25522eccf882b..d8d3f3e6b312b6fa7e4e6a357c167736c9473147 100644 (file)
@@ -1471,10 +1471,12 @@ __PACKAGE__->register_method({
        my $conf = PVE::QemuConfig->load_config($vmid);
        my $storecfg = PVE::Storage::config();
        PVE::QemuConfig->check_protection($conf, "can't remove VM $vmid");
-       die "unable to remove VM $vmid - used in HA resources\n"
-           if PVE::HA::Config::vm_is_ha_managed($vmid);
+
+       my $ha_managed = PVE::HA::Config::service_is_configured("vm:$vmid");
 
        if (!$param->{purge}) {
+           die "unable to remove VM $vmid - used in HA resources and purge parameter not set.\n"
+               if $ha_managed;
            # don't allow destroy if with replication jobs but no purge param
            my $repl_conf = PVE::ReplicationConfig->new();
            $repl_conf->check_for_existing_jobs($vmid);
@@ -1497,8 +1499,14 @@ __PACKAGE__->register_method({
                PVE::AccessControl::remove_vm_access($vmid);
                PVE::Firewall::remove_vmfw_conf($vmid);
                if ($param->{purge}) {
+                   print "purging VM $vmid from related configurations..\n";
                    PVE::ReplicationConfig::remove_vmid_jobs($vmid);
                    PVE::VZDump::Plugin::remove_vmid_from_backup_jobs($vmid);
+
+                   if ($ha_managed) {
+                       PVE::HA::Config::delete_service_from_config("vm:$vmid");
+                       print "NOTE: removed VM $vmid from HA resource configuration.\n";
+                   }
                }
 
                # only now remove the zombie config, else we can have reuse race
index 3473b9c45ef5650b6cef0c03754931800254b772..41762fc83f6467810ad330d27e3828cbca851e91 100644 (file)
@@ -43,7 +43,7 @@ Depends: dbus,
          pve-cluster,
          pve-edk2-firmware (>= 1.20181023-1),
          pve-firewall,
-         pve-ha-manager (>= 3.0-3),
+         pve-ha-manager (>= 3.0-9),
          pve-qemu-kvm (>= 3.0.1-62),
          socat,
          ${misc:Depends},