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 v2 2/4] api: status: add fencing status entry with armed/standby state
Date: Sun, 22 Mar 2026 00:42:51 +0100	[thread overview]
Message-ID: <20260321234350.2158438-3-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20260321234350.2158438-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>
---

No changes since v1.

 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





  parent reply	other threads:[~2026-03-21 23:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21 23:42 [PATCH ha-manager v2 0/4] fix #2751: implement disarm/arm HA for safer cluster maintenance Thomas Lamprecht
2026-03-21 23:42 ` [PATCH ha-manager v2 1/4] sim: hardware: add manual-migrate command for ignored services Thomas Lamprecht
2026-03-21 23:42 ` Thomas Lamprecht [this message]
2026-03-21 23:42 ` [PATCH ha-manager v2 3/4] fix #2751: implement disarm-ha and arm-ha for safe cluster maintenance Thomas Lamprecht
2026-03-23 13:04   ` Dominik Rusovac
2026-03-25 15:50   ` Fiona Ebner
2026-03-27  1:17     ` Thomas Lamprecht
2026-03-26 16:02   ` Daniel Kral
2026-03-26 23:15     ` Thomas Lamprecht
2026-03-27 10:21       ` Daniel Kral
2026-03-21 23:42 ` [PATCH ha-manager v2 4/4] api: status: add disarm-ha and arm-ha endpoints and CLI wiring Thomas Lamprecht
2026-03-23 13:05 ` [PATCH ha-manager v2 0/4] fix #2751: implement disarm/arm HA for safer cluster maintenance Dominik Rusovac
2026-03-25 12:06 ` applied: " 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=20260321234350.2158438-3-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