all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Thomas Skinner <thomas@atskinner.net>
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	[thread overview]
Message-ID: <20261119095931.1748970-2-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261119095931.1748970-1-d.rusovac@proxmox.com>

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 <thomas@atskinner.net>
Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

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





  reply	other threads:[~2026-11-19  9:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  9:59 [PATCH-SERIES docs/ha-manager/manager v5 00/10] fix #6144: add api and ui for node maintenance mode Dominik Rusovac
2026-11-19  9:59 ` Dominik Rusovac [this message]
2026-11-19  9:59 ` [PATCH pve-manager v5 02/10] fix #6144: ui: ha: status: allow toggling " Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-manager v5 03/10] ui: ha: status: show spinner while maintenance mode request is queued Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 04/10] test: add test for ignoring maintenance mode request Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 05/10] manager: standardize log messages for " Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 06/10] manager: factor out check " Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 07/10] cli: reject maintenance mode requests rejected by crm Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 08/10] api: status: report maintenance mode request for lrm entries Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-ha-manager v5 09/10] api: status: report queued " Dominik Rusovac
2026-11-19  9:59 ` [PATCH pve-docs v5 10/10] ha-manager: maintenance mode: mention web ui menu Dominik Rusovac
2026-11-19 22:28 ` applied: [PATCH-SERIES docs/ha-manager/manager v5 00/10] fix #6144: add api and ui for node maintenance mode Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119095931.1748970-2-d.rusovac@proxmox.com \
    --to=d.rusovac@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=thomas@atskinner.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal