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 28FEB1FF0DF for ; Thu, 19 Nov 2026 10:59:43 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id DE7CE216A5; Thu, 19 Nov 2026 10:59:40 +0100 (CET) From: Dominik Rusovac To: pve-devel@lists.proxmox.com Subject: [PATCH pve-manager v5 01/10] fix #6144: api: nodes: add endpoint to set maintenance mode Date: Thu, 19 Nov 2026 10:59:22 +0100 Message-ID: <20261119095931.1748970-2-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: 1795082374961 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: AMBZ6XZG4DXZME3OTQ4WNR6DHAAXELBP X-Message-ID-Hash: AMBZ6XZG4DXZME3OTQ4WNR6DHAAXELBP 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 CC: Thomas Skinner X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: node maintenance mode can currently only be requested with the HA manager's CLI, which can't be used from the web UI add an endpoint to enable/disable maintenance mode for a node, which lives below the node path rather than the HA API, so that the maintenance concept can be extended to more than HA managed resources later on for now, it runs the HA manager's CLI command to request the HA node maintenance mode. the CLI rejects requests that the CRM would ignore, e.g. for nodes unknown to HA, while HA is disarmed or if the node is not online, and its error message is forwarded Originally-by: Thomas Skinner Signed-off-by: Dominik Rusovac --- Notes: changes since v4: * reword commit subject and body * reorder name, path, method, ... etc. * reword 'maintenance-mode' description * run the HA manager's CLI command instead of reading the HA manager status and queuing the CRM command directly, as suggested in the v4 review, and forward its error message PVE/API2/Nodes.pm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index 07b3ce1f..117daa45 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -249,6 +249,7 @@ __PACKAGE__->register_method({ { name => 'hosts' }, { name => 'journal' }, { name => 'lxc' }, + { name => 'maintenance' }, { name => 'migrateall' }, { name => 'netstat' }, { name => 'network' }, @@ -2908,6 +2909,50 @@ __PACKAGE__->register_method({ }, }); +__PACKAGE__->register_method({ + name => 'maintenance_set', + path => 'maintenance', + method => 'PUT', + description => "Enable or disable maintenance mode for the node. Currently, this only" + . " requests the HA node maintenance mode.", + protected => 1, + permissions => { + check => ['perm', '/nodes/{node}', ['Sys.Modify']], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + 'maintenance-mode' => { + description => "Specifies whether the maintenance mode for the specified" + . " node should be enabled or disabled.", + type => 'string', + enum => ['enable', 'disable'], + }, + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + my $node = $param->{node}; + my $mode = $param->{'maintenance-mode'}; + + my $err = ''; + eval { + PVE::Tools::run_command( + [ + 'ha-manager', 'crm-command', 'node-maintenance', $mode, $node, + ], + errfunc => sub { $err .= "$_[0]\n" }, + ); + }; + die($err || $@) if $@; + + return undef; + }, +}); + # bash completion helper sub complete_templet_repo { -- 2.47.3