From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id D1FEC1FF0DF for ; Thu, 19 Nov 2026 11:00:05 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 26DA52173D; Thu, 19 Nov 2026 10:59:42 +0100 (CET) From: Dominik Rusovac To: pve-devel@lists.proxmox.com Subject: [PATCH pve-ha-manager v5 07/10] cli: reject maintenance mode requests rejected by crm Date: Thu, 19 Nov 2026 10:59:28 +0100 Message-ID: <20261119095931.1748970-8-d.rusovac@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119095931.1748970-1-d.rusovac@proxmox.com> References: <20261119095931.1748970-1-d.rusovac@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795082375562 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 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_MED -2.3 Sender listed at https://www.dnswl.org/, medium 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: 67Y6DIWHLA25WT6X5ZOIAWZXDCKULVTM X-Message-ID-Hash: 67Y6DIWHLA25WT6X5ZOIAWZXDCKULVTM X-MailFrom: d.rusovac@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: the CLI queued maintenance mode requests with no checks, so users only learned from the CRM's log that a request was rejected reject those before queuing the CRM command using the same logic as the CRM. this only concerns requests to enable maintenance mode, as the CRM always processes requests to disable it requests for nodes unknown to HA are rejected as well, since maintenance mode only affects HA managed resources and the queued command would make an idle CRM become active dying in the log function is supposed to forward the reason for rejection to callers deref node parameter once Signed-off-by: Dominik Rusovac --- Notes: new in v5 src/PVE/CLI/ha_manager.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/PVE/CLI/ha_manager.pm b/src/PVE/CLI/ha_manager.pm index 6625de6..74f18d9 100644 --- a/src/PVE/CLI/ha_manager.pm +++ b/src/PVE/CLI/ha_manager.pm @@ -138,10 +138,26 @@ __PACKAGE__->register_method({ code => sub { my ($param) = @_; - PVE::Cluster::check_node_exists($param->{node}); + my $node = $param->{node}; + PVE::Cluster::check_node_exists($node); + + # maintenance mode only affects HA managed resources and queuing the CRM command for a + # node unknown to HA would make an idle CRM become active for nothing + my $node_status = PVE::HA::Config::read_manager_status()->{node_status} // {}; + die "node '$node' is not part of HA\n" if !defined($node_status->{$node}); + + my $disable = $param->{disable}; + if (!$disable) { + my $log_fn = sub { + my ($level, $msg) = @_; + die "$msg\n"; + }; + + PVE::HA::Config::check_enable_maintenance($node, $log_fn); + } - my $cmd = $param->{disable} ? 'disable-node-maintenance' : 'enable-node-maintenance'; - PVE::HA::Config::queue_crm_commands("$cmd $param->{node}"); + my $cmd = $disable ? 'disable-node-maintenance' : 'enable-node-maintenance'; + PVE::HA::Config::queue_crm_commands("$cmd $node"); return undef; }, -- 2.47.3