From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 18C5E79372 for ; Tue, 4 May 2021 11:53:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0DB3026D64 for ; Tue, 4 May 2021 11:53:00 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CEA8226D28 for ; Tue, 4 May 2021 11:52:58 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A084C426AF for ; Tue, 4 May 2021 11:52:58 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 4 May 2021 11:52:54 +0200 Message-Id: <20210504095254.6563-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210504095254.6563-1-f.ebner@proxmox.com> References: <20210504095254.6563-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lvmplugin.pm] Subject: [pve-devel] [PATCH storage 2/2] lvm: volume import: handle worker returned by free_image X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2021 09:53:00 -0000 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 --- 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