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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2024-03-08 13:49:03 +01:00
parent 9d6126e8db
commit 04736ecbd5

View File

@ -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);