public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-ha-manager v5 09/10] api: status: report queued maintenance mode request for lrm entries
Date: Thu, 19 Nov 2026 10:59:30 +0100	[thread overview]
Message-ID: <20261119095931.1748970-10-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261119095931.1748970-1-d.rusovac@proxmox.com>

expose whether a request to enable/disable maintenance mode for a node
is still queued, so that clients can tell when the CRM processed it; no
matter if CRM accepted or ignored the request

peeking into the queued CRM commands reads them without consuming them

Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    new in v5:
    * towards fixing the bug mentioned in the review of v4
    * only needed for the spinner, can be left out together with it

 src/PVE/API2/HA/Status.pm | 16 ++++++++++++++++
 src/PVE/HA/Config.pm      |  4 ++++
 2 files changed, 20 insertions(+)

diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm
index 2622ec1..e3a4e16 100644
--- a/src/PVE/API2/HA/Status.pm
+++ b/src/PVE/API2/HA/Status.pm
@@ -113,6 +113,13 @@ __PACKAGE__->register_method({
                     type => "boolean",
                     optional => 1,
                 },
+                'maintenance-request-queued' => {
+                    description => "For type 'lrm'. Whether a request to enable or disable"
+                        . " maintenance mode for the node is queued and not yet processed by"
+                        . " the CRM.",
+                    type => "boolean",
+                    optional => 1,
+                },
                 crm_state => {
                     description => "For type 'service'. Service state as seen by the CRM.",
                     type => "string",
@@ -266,6 +273,12 @@ __PACKAGE__->register_method({
                 };
         }
 
+        my $maintenance_queued_nodes = {};
+        for my $cmd (split(/\n/, PVE::HA::Config::peek_crm_commands())) {
+            next if $cmd !~ m/^(?:enable|disable)-node-maintenance\s+(\S+)$/;
+            $maintenance_queued_nodes->{$1} = 1;
+        }
+
         foreach my $node (sort keys %{ $status->{node_status} }) {
             my $active_count =
                 PVE::HA::Tools::count_active_services($status->{service_status}, $node);
@@ -273,6 +286,7 @@ __PACKAGE__->register_method({
             my $id = "lrm:$node";
             my $node_request = $status->{node_request} // {};
             my $maintenance_requested = $node_request->{$node}->{maintenance} ? 1 : 0;
+            my $maintenance_queued = $maintenance_queued_nodes->{$node} ? 1 : 0;
             if (!$lrm_status->{timestamp}) {
                 push @$res,
                     {
@@ -281,6 +295,7 @@ __PACKAGE__->register_method({
                         node => $node,
                         status => "$node (unable to read lrm status)",
                         'maintenance-requested' => $maintenance_requested,
+                        'maintenance-request-queued' => $maintenance_queued,
                     };
             } else {
                 my $status_str = &$timestamp_to_status($ctime, $lrm_status->{timestamp});
@@ -325,6 +340,7 @@ __PACKAGE__->register_method({
                         status => $status_text,
                         timestamp => $lrm_status->{timestamp},
                         'maintenance-requested' => $maintenance_requested,
+                        'maintenance-request-queued' => $maintenance_queued,
                     };
             }
         }
diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index b3ab77b..4f02d5f 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -341,6 +341,10 @@ sub any_pending_crm_command {
     return defined($data) && length $data;
 }
 
+sub peek_crm_commands {
+    return cfs_read_file($crm_commands_filename) // '';
+}
+
 sub read_crm_commands {
 
     my $code = sub {
-- 
2.47.3





  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 ` [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 ` Dominik Rusovac [this message]
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-10-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal