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 <[email protected]> --- 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
