From 322d3550d740628ca50c8129e171a950f69350c0 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 14 Mar 2016 14:34:44 +0100 Subject: [PATCH] status: mark CRM as idle if no service is configured This should avoid confusion if we remove all service from the CRM, as else we would always see "old timestamp -dead?" in the status. Signed-off-by: Thomas Lamprecht --- src/PVE/API2/HA/Status.pm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm index 3ce8d23..252cd78 100644 --- a/src/PVE/API2/HA/Status.pm +++ b/src/PVE/API2/HA/Status.pm @@ -76,29 +76,36 @@ __PACKAGE__->register_method ({ my ($param) = @_; my $res = []; - - if (PVE::Cluster::check_cfs_quorum(1)) { - push @$res, { id => 'quorum', type => 'quorum', + + my $quorate = PVE::Cluster::check_cfs_quorum(1); + if ($quorate) { + push @$res, { id => 'quorum', type => 'quorum', node => $nodename, status => "OK", quorate => 1 }; } else { - push @$res, { id => 'quorum', type => 'quorum', node => $nodename, + push @$res, { id => 'quorum', type => 'quorum', node => $nodename, status => "No quorum on node '$nodename'!", quorate => 0 }; } - + my $haenv = PVE::HA::Env::PVE2->new($nodename); - + my $status = $haenv->read_manager_status(); + my $service_config = $haenv->read_service_config(); + my $ctime = $haenv->get_time(); if (defined($status->{master_node}) && defined($status->{timestamp})) { my $master = $status->{master_node}; my $status_str = &$timestamp_to_status($ctime, $status->{timestamp}); + # mark crm idle if it has no service configured and is not active + if ($quorate && $status_str ne 'active' && !keys %{$service_config}) { + $status_str = 'idle'; + } my $time_str = localtime($status->{timestamp}); my $status_text = "$master ($status_str, $time_str)"; - push @$res, { id => 'master', type => 'master', node => $master, + push @$res, { id => 'master', type => 'master', node => $master, status => $status_text, timestamp => $status->{timestamp} }; - } + } # compute active services for all nodes my $active_count = {}; -- 2.39.2