From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id C78991FF0DF for ; Thu, 19 Nov 2026 11:00:44 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 14875217FF; Thu, 19 Nov 2026 10:59:44 +0100 (CET) From: Dominik Rusovac 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 Message-ID: <20261119095931.1748970-10-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: 1795082375771 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 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: SCWV2XPYKUNB4QNVZQ7NPSVY7JA25ZKK X-Message-ID-Hash: SCWV2XPYKUNB4QNVZQ7NPSVY7JA25ZKK 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: 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 --- 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