File bsc#1180618-0002-Fix-controller-ensure-newly-joining-node-learns-the-.patch of Package pacemaker.21507

From a2191a46561356f674898a7a6ff9ddca4cfafe4c Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Tue, 10 Aug 2021 17:03:27 +0200
Subject: [PATCH] Fix: controller: ensure newly joining node learns the node
 names of none-DCs

Commit 0ec714adc covers the case where a node is rejoining. But for the
case where a node is newly joining controld cpg group, hence its node
name is not known by us yet, peer_update_callback() will directly bail
out with the logic:

```
    if (node->uname == NULL) {
        return;
    }
```
, so that non-DC nodes don't get to send out a hello message.

This commit fixes it by moving the hello messaging logic prior to that.
---
 daemons/controld/controld_callbacks.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/daemons/controld/controld_callbacks.c b/daemons/controld/controld_callbacks.c
index e564b3dcd..e9dbbdc6c 100644
--- a/daemons/controld/controld_callbacks.c
+++ b/daemons/controld/controld_callbacks.c
@@ -116,6 +116,22 @@ peer_update_callback(enum crm_status_type type, crm_node_t * node, const void *d
         controld_set_fsa_input_flags(R_PEER_DATA);
     }
 
+    if (type == crm_status_processes
+        && pcmk_is_set(node->processes, crm_get_cluster_proc())
+        && !AM_I_DC
+        && !is_remote) {
+        /*
+         * This is a hack until we can send to a nodeid and/or we fix node name lookups
+         * These messages are ignored in crmd_ha_msg_filter()
+         */
+        xmlNode *query = create_request(CRM_OP_HELLO, NULL, NULL, CRM_SYSTEM_CRMD, CRM_SYSTEM_CRMD, NULL);
+
+        crm_debug("Sending hello to node %u so that it learns our node name", node->id);
+        send_cluster_message(node, crm_msg_crmd, query, FALSE);
+
+        free_xml(query);
+    }
+
     if (node->uname == NULL) {
         return;
     }
@@ -173,17 +189,6 @@ peer_update_callback(enum crm_status_type type, crm_node_t * node, const void *d
 
             if (!appeared) {
                 controld_remove_voter(node->uname);
-            } else if (!AM_I_DC && !is_remote) {
-                /*
-                 * This is a hack until we can send to a nodeid and/or we fix node name lookups
-                 * These messages are ignored in crmd_ha_msg_filter()
-                 */
-                xmlNode *query = create_request(CRM_OP_HELLO, NULL, NULL, CRM_SYSTEM_CRMD, CRM_SYSTEM_CRMD, NULL);
-
-                crm_debug("Broadcasting our uname because of node %u", node->id);
-                send_cluster_message(node, crm_msg_crmd, query, FALSE);
-
-                free_xml(query);
             }
 
             if (!pcmk_is_set(fsa_input_register, R_CIB_CONNECTED)) {
-- 
2.31.1

openSUSE Build Service is sponsored by