[pve-devel] [PATCH ha-manager v2 1/2] status: mark CRM as idle if no service is configured

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Mar 14 14:34:44 CET 2016


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 <t.lamprecht at proxmox.com>
---

Also some whitespace cleanup in the diff context.

 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.1.4





More information about the pve-devel mailing list