File bsc#1217259-0001-Fix-controld-leave-xml-src-attribute-empty-when-no-D.patch of Package pacemaker.36799
From 9243124df1d22107403148ad9c0a573d7a8cec06 Mon Sep 17 00:00:00 2001
From: Aleksei Burlakov <aburlakov@suse.com>
Date: Thu, 17 Oct 2024 11:31:02 +0200
Subject: [PATCH] Fix: controld: leave xml-src attribute empty when no DC
selected #2902
Right after starting the cluster the DC is offline for short time,
and if you call 'crmadmin --dc_lookup' during this time, it would hang.
This change leaves the xml-src attribute that the crmadmin receives from
the pacemaker-controld empty, so that crmadmin knows the DC was not
selected.
ref: https://projects.clusterlabs.org/T735
---
daemons/controld/controld_messages.c | 35 +++++++++++++++++++++-------
1 file changed, 27 insertions(+), 8 deletions(-)
Index: pacemaker-2.1.7+20231219.0f7f88312/daemons/controld/controld_messages.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/daemons/controld/controld_messages.c
+++ pacemaker-2.1.7+20231219.0f7f88312/daemons/controld/controld_messages.c
@@ -26,11 +26,12 @@ extern void crm_shutdown(int nsig);
static enum crmd_fsa_input handle_message(xmlNode *msg,
enum crmd_fsa_cause cause);
+static xmlNode* create_ping_reply(const xmlNode *msg);
static void handle_response(xmlNode *stored_msg);
static enum crmd_fsa_input handle_request(xmlNode *stored_msg,
enum crmd_fsa_cause cause);
static enum crmd_fsa_input handle_shutdown_request(xmlNode *stored_msg);
-static void send_msg_via_ipc(xmlNode * msg, const char *sys);
+static void send_msg_via_ipc(xmlNode * msg, const char *sys, const char *src);
/* debug only, can wrap all it likes */
static int last_data_id = 0;
@@ -436,6 +437,18 @@ relay_message(xmlNode * msg, gboolean or
}
}
+ // If is for DC and DC is not yet selected
+ if (is_for_dc && pcmk__str_eq(task, CRM_OP_PING, pcmk__str_casei)
+ && (controld_globals.dc_name == NULL)) {
+
+ xmlNode *reply = create_ping_reply(msg);
+ sys_to = crm_element_value(reply, F_CRM_SYS_TO);
+ // Explicitly leave src empty. It indicates that dc is "not yet selected"
+ send_msg_via_ipc(reply, sys_to, NULL);
+ free_xml(reply);
+ return TRUE;
+ }
+
// Check whether message should be relayed
if (is_for_dc || is_for_dcib || is_for_te) {
@@ -444,7 +457,7 @@ relay_message(xmlNode * msg, gboolean or
crm_trace("Route message %s locally as transition request",
ref);
crm_log_xml_trace(msg, sys_to);
- send_msg_via_ipc(msg, sys_to);
+ send_msg_via_ipc(msg, sys_to, controld_globals.our_nodename);
return TRUE; // No further processing of message is needed
}
crm_trace("Route message %s locally as DC request", ref);
@@ -479,7 +492,7 @@ relay_message(xmlNode * msg, gboolean or
}
crm_trace("Relay message %s locally to %s", ref, sys_to);
crm_log_xml_trace(msg, "IPC-relay");
- send_msg_via_ipc(msg, sys_to);
+ send_msg_via_ipc(msg, sys_to, controld_globals.our_nodename);
return TRUE;
}
@@ -793,8 +806,8 @@ handle_remote_state(const xmlNode *msg)
*
* \return Next FSA input
*/
-static enum crmd_fsa_input
-handle_ping(const xmlNode *msg)
+static xmlNode*
+create_ping_reply(const xmlNode *msg)
{
const char *value = NULL;
xmlNode *ping = NULL;
@@ -815,9 +828,15 @@ handle_ping(const xmlNode *msg)
// @TODO maybe do some checks to determine meaningful status
crm_xml_add(ping, XML_PING_ATTR_STATUS, "ok");
- // Send reply
reply = create_reply(msg, ping);
free_xml(ping);
+ return reply;
+}
+
+static enum crmd_fsa_input
+handle_ping(const xmlNode *msg)
+{
+ xmlNode *reply = create_ping_reply(msg);
if (reply != NULL) {
(void) relay_message(reply, TRUE);
free_xml(reply);
@@ -1250,7 +1269,7 @@ handle_shutdown_request(xmlNode * stored
}
static void
-send_msg_via_ipc(xmlNode * msg, const char *sys)
+send_msg_via_ipc(xmlNode * msg, const char *sys, const char *src)
{
pcmk__client_t *client_channel = NULL;
@@ -1259,7 +1278,7 @@ send_msg_via_ipc(xmlNode * msg, const ch
client_channel = pcmk__find_client_by_id(sys);
if (crm_element_value(msg, F_CRM_HOST_FROM) == NULL) {
- crm_xml_add(msg, F_CRM_HOST_FROM, controld_globals.our_nodename);
+ crm_xml_add(msg, F_CRM_HOST_FROM, src);
}
if (client_channel != NULL) {