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