]> git.proxmox.com Git - pve-storage.git/commitdiff
lvm: volume import: handle worker returned by free_image
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 4 May 2021 09:52:54 +0000 (11:52 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 21 Jun 2021 07:38:03 +0000 (09:38 +0200)
only affects LVM storages with 'saferemove 1' where the import fails at a rather
advanced stage. Previously in such cases, the renamed (by free_image) volume
del-vm-XYZ-disk-N would be left over.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage/LVMPlugin.pm

index df49b765fb1eaa8162b1a48c1814ae0c2d2fc246..b85fb89ac287915d7c0b67d0b652b962ee659425 100644 (file)
@@ -670,8 +670,16 @@ sub volume_import {
        $class->volume_import_write($fh, $file);
     };
     if (my $err = $@) {
-       eval { $class->free_image($storeid, $scfg, $volname, 0) };
+       my $cleanup_worker = eval { $class->free_image($storeid, $scfg, $volname, 0) };
        warn $@ if $@;
+
+       if ($cleanup_worker) {
+           my $rpcenv = PVE::RPCEnvironment::get();
+           my $authuser = $rpcenv->get_user();
+
+           $rpcenv->fork_worker('imgdel', undef, $authuser, $cleanup_worker);
+       }
+
        die $err;
     }