From: Dominik Rusovac <d.rusovac@proxmox.com>
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 [thread overview]
Message-ID: <20261119095931.1748970-8-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261119095931.1748970-1-d.rusovac@proxmox.com>
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 <d.rusovac@proxmox.com>
---
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
next prev parent reply other threads:[~2026-11-19 10:00 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 ` [PATCH pve-manager v5 01/10] fix #6144: api: nodes: add endpoint to set " Dominik Rusovac
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 ` Dominik Rusovac [this message]
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-8-d.rusovac@proxmox.com \
--to=d.rusovac@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox