Like this it's clearer that the volume is still there. The warning
is easily missed.

Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---
 src/PVE/API2/LXC.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 9eb52dc..6280430 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1892,7 +1892,14 @@ __PACKAGE__->register_method({
                        PVE::Storage::deactivate_volumes($storage_cfg, [ 
$old_volid ]);
                        PVE::Storage::vdisk_free($storage_cfg, $old_volid);
                    };
-                   warn $@ if $@;
+                   if (my $err = $@) {
+                       warn $err;
+                       PVE::LXC::Config->lock_config($vmid, sub {
+                           my $conf = PVE::LXC::Config->load_config($vmid);
+                           PVE::LXC::Config->add_unused_volume($conf, 
$old_volid);
+                           PVE::LXC::Config->write_config($vmid, $conf);
+                       });
+                   }
                }
            };
            my $err = $@;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to