From: Andrew Beekhof <andrew@beekhof.net>
Date: Thu, 3 Sep 2015 12:27:59 +1000
Subject: [PATCH] Fix: corosync: Display node state and quorum data if
available
(cherry picked from commit 4d4c92e515bbaf74917a311e19d5995b30c29430)
---
mcp/pacemaker.c | 7 +++++++
tools/crm_node.c | 17 ++++++++++-------
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/mcp/pacemaker.c b/mcp/pacemaker.c
index f9fc015..9c3195e 100644
--- a/mcp/pacemaker.c
+++ b/mcp/pacemaker.c
@@ -35,6 +35,8 @@
#include <dirent.h>
#include <ctype.h>
+
+gboolean pcmk_quorate = FALSE;
gboolean fatal_error = FALSE;
GMainLoop *mainloop = NULL;
@@ -560,6 +562,10 @@ update_process_clients(crm_client_t *client)
crm_node_t *node = NULL;
xmlNode *update = create_xml_node(NULL, "nodes");
+ if (is_corosync_cluster()) {
+ crm_xml_add_int(update, "quorate", pcmk_quorate);
+ }
+
g_hash_table_iter_init(&iter, crm_peer_cache);
while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
xmlNode *xml = create_xml_node(update, "node");
@@ -896,6 +902,7 @@ static gboolean
mcp_quorum_callback(unsigned long long seq, gboolean quorate)
{
/* Nothing to do */
+ pcmk_quorate = quorate;
return TRUE;
}
diff --git a/tools/crm_node.c b/tools/crm_node.c
index 308d4f9..9626120 100644
--- a/tools/crm_node.c
+++ b/tools/crm_node.c
@@ -243,8 +243,16 @@ node_mcp_dispatch(const char *buffer, ssize_t length, gpointer userdata)
xmlNode *node = NULL;
GListPtr nodes = NULL;
GListPtr iter = NULL;
+ const char *quorate = crm_element_value(msg, "quorate");
crm_log_xml_trace(msg, "message");
+ if (command == 'q' && quorate != NULL) {
+ fprintf(stdout, "%s\n", quorate);
+ crm_exit(pcmk_ok);
+
+ } else if(command == 'q') {
+ crm_exit(1);
+ }
for (node = __xml_first_child(msg); node != NULL; node = __xml_next(node)) {
crm_node_t *peer = calloc(1, sizeof(crm_node_t));
@@ -258,7 +266,7 @@ node_mcp_dispatch(const char *buffer, ssize_t length, gpointer userdata)
for(iter = nodes; iter; iter = iter->next) {
crm_node_t *peer = iter->data;
if (command == 'l') {
- fprintf(stdout, "%u %s %s\n", peer->id, peer->uname, peer->state);
+ fprintf(stdout, "%u %s %s\n", peer->id, peer->uname, peer->state?peer->state:"");
} else if (command == 'p') {
if(safe_str_eq(peer->state, CRM_NODE_MEMBER)) {
@@ -310,12 +318,6 @@ try_pacemaker(int command, enum cluster_type_e stack)
fprintf(stdout, "1\n");
crm_exit(pcmk_ok);
- case 'q':
- /* Implement one day?
- * Wouldn't be much for pacemakerd to track it and include in the poke reply
- */
- return FALSE;
-
case 'R':
{
int lpc = 0;
@@ -338,6 +340,7 @@ try_pacemaker(int command, enum cluster_type_e stack)
case 'i':
case 'l':
+ case 'q':
case 'p':
/* Go to pacemakerd */
{