[pve-devel] [PATCH storage 2/2] lvm: volume import: handle worker returned by free_image

Fabian Ebner f.ebner at proxmox.com
Tue May 4 11:52:54 CEST 2021


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 at proxmox.com>
---
 PVE/Storage/LVMPlugin.pm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index df49b76..b85fb89 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -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;
     }
 
-- 
2.20.1





More information about the pve-devel mailing list