]> git.proxmox.com Git - pve-container.git/commitdiff
move_volume: if deleting old volume fails, add it as unused
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 23 Mar 2020 11:18:54 +0000 (12:18 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 27 Mar 2020 07:50:46 +0000 (08:50 +0100)
Especially useful when there are linked clones using the volume
that is being moved, but shouldn't hurt otherwise either.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/API2/LXC.pm

index 307fd907e2e83321ca22342b0cea010785d284d7..e0289634c5588863472864a1eb069884e640c603 100644 (file)
@@ -1858,7 +1858,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 = $@;