]> git.proxmox.com Git - pve-container.git/commitdiff
fix #2580: api/delete: drop CT from HA resources if purge is set
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Mar 2020 12:15:53 +0000 (13:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Mar 2020 12:27:23 +0000 (13:27 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
debian/control
src/PVE/API2/LXC.pm

index ee44483be10d50e7768ed16c40d9190ef9df42ec..056174c4b00899a565843e232ca2509536aa233c 100644 (file)
@@ -25,7 +25,7 @@ Depends: file,
          libpve-storage-perl (>= 5.0-31),
          lxc-pve,
          pve-cluster (>= 4.0-8),
-         pve-ha-manager (>= 3.0-3),
+         pve-ha-manager (>= 3.0-9),
          pve-lxc-syscalld,
          xz-utils,
          ${misc:Depends},
index a48cf95cea10a5088d75577a6ead5dcc287e053e..a5aa5fc1b5ad781472a098fb4e1388d032979585 100644 (file)
@@ -662,10 +662,12 @@ __PACKAGE__->register_method({
        my $storage_cfg = cfs_read_file("storage.cfg");
        PVE::LXC::Config->check_protection($conf, "can't remove CT $vmid");
 
-       die "unable to remove CT $vmid - used in HA resources\n"
-           if PVE::HA::Config::vm_is_ha_managed($vmid);
+       my $ha_managed = PVE::HA::Config::service_is_configured("ct:$vmid");
 
        if (!$param->{purge}) {
+           die "unable to remove CT $vmid - used in HA resources and purge parameter not set.\n"
+               if $ha_managed;
+
            # do not allow destroy if there are replication jobs without purge
            my $repl_conf = PVE::ReplicationConfig->new();
            $repl_conf->check_for_existing_jobs($vmid);
@@ -687,8 +689,14 @@ __PACKAGE__->register_method({
            PVE::AccessControl::remove_vm_access($vmid);
            PVE::Firewall::remove_vmfw_conf($vmid);
            if ($param->{purge}) {
+               print "purging CT $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("ct:$vmid");
+                   print "NOTE: removed CT $vmid from HA resource configuration.\n";
+               }
            }
 
            # only now remove the zombie config, else we can have reuse race