public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH ha-manager 1/3] api: status: add fencing status entry with armed/standby state
Date: Mon,  9 Mar 2026 22:57:08 +0100	[thread overview]
Message-ID: <20260309220128.973793-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20260309220128.973793-1-t.lamprecht@proxmox.com>

Add a fencing entry to the HA status output that shows whether the
fencing mechanism is active or idle. The CRM only opens the watchdog
when actively running as master, so distinguish between:

- armed: CRM is active master, watchdog connected
- standby: no active CRM master (e.g. no services configured, cluster
  just started), watchdog not open

Each LRM entry additionally shows its per-node watchdog state. The LRM
holds its watchdog while it has the agent lock (active or maintenance
state).

Previously there was no indication of the fencing state at all, which
made it hard to tell whether the watchdog was actually protecting the
cluster.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---

Some details here might be questioned, and tbh. I'm not *that* happy
with the status endpoint's return schema structure, but that's
pre-existing and probably needs a breaking change on a majore release if
we want to clean this up  for real.

 src/PVE/API2/HA/Status.pm | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm
index a1e5787..a6b00b9 100644
--- a/src/PVE/API2/HA/Status.pm
+++ b/src/PVE/API2/HA/Status.pm
@@ -91,7 +91,7 @@ __PACKAGE__->register_method({
                 },
                 type => {
                     description => "Type of status entry.",
-                    enum => ["quorum", "master", "lrm", "service"],
+                    enum => ["quorum", "master", "lrm", "service", "fencing"],
                 },
                 quorate => {
                     description => "For type 'quorum'. Whether the cluster is quorate or not.",
@@ -143,6 +143,13 @@ __PACKAGE__->register_method({
                     type => "string",
                     optional => 1,
                 },
+                armed_state => {
+                    description => "For type 'fencing'. Whether HA fencing is armed"
+                        . " or on standby.",
+                    type => "string",
+                    enum => ['armed', 'standby'],
+                    optional => 1,
+                },
             },
         },
     },
@@ -193,6 +200,23 @@ __PACKAGE__->register_method({
                 };
         }
 
+        # the CRM only opens the watchdog when actively running as master
+        my $crm_active =
+            defined($status->{master_node})
+            && defined($status->{timestamp})
+            && $timestamp_to_status->($ctime, $status->{timestamp}) eq 'active';
+
+        my $armed_state = $crm_active ? 'armed' : 'standby';
+        my $crm_wd = $crm_active ? "CRM watchdog active" : "CRM watchdog standby";
+        push @$res,
+            {
+                id => 'fencing',
+                type => 'fencing',
+                node => $status->{master_node} // $nodename,
+                status => "$armed_state ($crm_wd)",
+                armed_state => $armed_state,
+            };
+
         foreach my $node (sort keys %{ $status->{node_status} }) {
             my $active_count =
                 PVE::HA::Tools::count_active_services($status->{service_status}, $node);
@@ -209,10 +233,17 @@ __PACKAGE__->register_method({
             } else {
                 my $status_str = &$timestamp_to_status($ctime, $lrm_status->{timestamp});
                 my $lrm_mode = $lrm_status->{mode};
+                my $lrm_state = $lrm_status->{state} || 'unknown';
+
+                # LRM holds its watchdog while it has the agent lock
+                my $lrm_wd =
+                    ($status_str eq 'active'
+                        && ($lrm_state eq 'active' || $lrm_state eq 'maintenance'))
+                    ? 'watchdog active'
+                    : 'watchdog standby';
 
                 if ($status_str eq 'active') {
                     $lrm_mode ||= 'active';
-                    my $lrm_state = $lrm_status->{state} || 'unknown';
                     if ($lrm_mode ne 'active') {
                         $status_str = "$lrm_mode mode";
                     } else {
@@ -227,7 +258,7 @@ __PACKAGE__->register_method({
                 }
 
                 my $time_str = localtime($lrm_status->{timestamp});
-                my $status_text = "$node ($status_str, $time_str)";
+                my $status_text = "$node ($status_str, $lrm_wd, $time_str)";
                 push @$res,
                     {
                         id => $id,
-- 
2.47.3





  reply	other threads:[~2026-03-09 22:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 21:57 [PATCH ha-manager 0/3] fix #2751: implement disarm/arm HA for safer cluster maintenance Thomas Lamprecht
2026-03-09 21:57 ` Thomas Lamprecht [this message]
2026-03-09 21:57 ` [PATCH ha-manager 2/3] fix #2751: implement disarm-ha and arm-ha for safe " Thomas Lamprecht
2026-03-09 21:57 ` [PATCH ha-manager 3/3] api: status: add disarm-ha and arm-ha endpoints and CLI wiring 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=20260309220128.973793-2-t.lamprecht@proxmox.com \
    --to=t.lamprecht@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