From 04736ecbd56f3b4703c4e1720dfa9b3dbc96b3ce Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 8 Mar 2024 13:49:03 +0100 Subject: [PATCH] api: clone vm: comment and style clean-up deactivation error-handling Make the post-if check for the target not already running more prominent by using a full if block. Also comment on why we ignore the error here, while the commit changing that explained it well, this is one of the things that might be better of with a in-code comment (as doing the deactivation is described as important here, so one might wonder why the code continues if that fails) Signed-off-by: Thomas Lamprecht --- PVE/API2/Qemu.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 1ff5abe4..40b6c302 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -3820,11 +3820,12 @@ __PACKAGE__->register_method({ PVE::QemuServer::create_ifaces_ipams_ips($newconf, $newid); if ($target) { - # always deactivate volumes - avoid lvm LVs to be active on several nodes - eval { - PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) if !$running; - }; - log_warn($@) if ($@); + if (!$running) { + # always deactivate volumes – avoids that LVM LVs are active on several nodes + eval { PVE::Storage::deactivate_volumes($storecfg, $vollist, $snapname) }; + # but only warn when that fails (e.g., parallel clones keeping them active) + log_warn($@) if $@; + } PVE::Storage::deactivate_volumes($storecfg, $newvollist);