From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 850871FF13A for ; Wed, 22 Jul 2026 16:03:28 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 580652157F; Wed, 22 Jul 2026 16:03:01 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager 7/7] fix #7230: resources: let shutdown api handle timeout fallback value Date: Wed, 22 Jul 2026 16:01:49 +0200 Message-ID: <20260722140149.296952-8-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260722140149.296952-1-d.kral@proxmox.com> References: <20260722140149.296952-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784728918127 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.224 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: U7DJLGOVWLC3HGUHCYABNLYRABZGNVOG X-Message-ID-Hash: U7DJLGOVWLC3HGUHCYABNLYRABZGNVOG X-MailFrom: d.kral@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: PVE::API2::LXC::Status::vm_shutdown() and PVE::API2::Qemu::vm_shutdown() already fallback to either the configured shutdown timeout or the default value of 60 seconds. Therefore, let the API handlers decide what the timeout value should be set to. This does only partially fix #7230 as HA resources are still force-stopped as the shutdown timeout runs out. Signed-off-by: Daniel Kral --- src/PVE/HA/Resources/PVECT.pm | 10 +++++----- src/PVE/HA/Resources/PVEVM.pm | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PVE/HA/Resources/PVECT.pm b/src/PVE/HA/Resources/PVECT.pm index 177b9070..ead66e0e 100644 --- a/src/PVE/HA/Resources/PVECT.pm +++ b/src/PVE/HA/Resources/PVECT.pm @@ -87,7 +87,6 @@ sub shutdown { my ($class, $haenv, $id, $timeout) = @_; my $nodename = $haenv->nodename(); - my $shutdown_timeout = $timeout // 60; my $upid; my $params = { @@ -95,11 +94,12 @@ sub shutdown { vmid => $id, }; - if ($shutdown_timeout) { - $params->{timeout} = $shutdown_timeout; - $upid = PVE::API2::LXC::Status->vm_shutdown($params); - } else { + # stop the CT immediately if $timeout is set to exactly 0 + if (defined($timeout) && $timeout == 0) { $upid = PVE::API2::LXC::Status->vm_stop($params); + } else { + $params->{timeout} = $timeout; + $upid = PVE::API2::LXC::Status->vm_shutdown($params); } PVE::HA::Tools::upid_wait($upid, $haenv); diff --git a/src/PVE/HA/Resources/PVEVM.pm b/src/PVE/HA/Resources/PVEVM.pm index 87532716..d89a0bce 100644 --- a/src/PVE/HA/Resources/PVEVM.pm +++ b/src/PVE/HA/Resources/PVEVM.pm @@ -87,7 +87,6 @@ sub shutdown { my ($class, $haenv, $id, $timeout) = @_; my $nodename = $haenv->nodename(); - my $shutdown_timeout = $timeout // 60; my $upid; my $params = { @@ -95,12 +94,13 @@ sub shutdown { vmid => $id, }; - if ($shutdown_timeout) { - $params->{timeout} = $shutdown_timeout; + # stop the VM immediately if $timeout is set to exactly 0 + if (defined($timeout) && $timeout == 0) { + $upid = PVE::API2::Qemu->vm_stop($params); + } else { + $params->{timeout} = $timeout; $params->{forceStop} = 1; $upid = PVE::API2::Qemu->vm_shutdown($params); - } else { - $upid = PVE::API2::Qemu->vm_stop($params); } PVE::HA::Tools::upid_wait($upid, $haenv); -- 2.47.3