File pacemaker-attrd-node-name-broadcast-at-start-up.patch of Package pacemaker.openSUSE_Leap_42.3_Update

commit 3518544d8ad8d6f0410aecc0e7cb67a3e018dbdf
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Wed Nov 29 17:21:29 2017 -0600

    Fix: attrd: ensure node name is broadcast at start-up (CLBZ#5330)
    
    This fixes a regression introduced in 1.1.18.
    
    Since c9d1c3cd, the crmd no longer explicitly clears the terminate and shutdown
    node attributes at first join. An unwanted side effect of this was that the
    attrd writer no longer reliably learned a joining node's name. If a node is
    known only by its ID, the writer can not write its attributes to the CIB.
    
    The worst outcome is that the joining node would be unable to shut down,
    since the shutdown attribute would never trigger the policy engine. The window
    was limited because the writer learns the node's name if a new attrd
    election was required, or a node attribute was set locally on the joining node.
    
    The fix is to set a new private attribute, #attrd-protocol, at attrd start-up,
    with the supported attrd protocol version. This has the additional benefit of
    allowing any node to determine the minimum supported protocol version across
    all active cluster nodes.

Index: pacemaker-1.1.16+20170320.77ea74d/attrd/commands.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/attrd/commands.c
+++ pacemaker-1.1.16+20170320.77ea74d/attrd/commands.c
@@ -35,8 +35,9 @@
  * heartbeat, CMAN, or corosync-plugin stacks) is unversioned.
  *
  * With atomic attrd, each attrd will send ATTRD_PROTOCOL_VERSION with every
- * peer request and reply. Currently, there is no way to know the minimum
- * version supported by all peers, which limits its usefulness.
+ * peer request and reply. As of Pacemaker 2.0.0, at start-up each attrd will
+ * also set a private attribute for itself with its version, so any attrd can
+ * determine the minimum version supported by all peers.
  *
  * Protocol  Pacemaker  Significant changes
  * --------  ---------  -------------------
@@ -319,11 +320,10 @@ void
 attrd_client_clear_failure(xmlNode *xml)
 {
 #if 0
-    /* @TODO This would be most efficient, but there is currently no way to
-     * verify that all peers support the op. If that ever changes, we could
-     * enable this code.
+    /* @TODO Track the minimum supported protocol version across all nodes,
+     * then enable this more-efficient code.
      */
-    if (all_peers_support_clear_failure) {
+    if (compare_version("2", minimum_protocol_version) <= 0) {
         /* Propagate to all peers (including ourselves).
          * This ends up at attrd_peer_message().
          */
@@ -553,6 +553,24 @@ attrd_peer_clear_failure(crm_node_t *pee
     regfree(&regex);
 }
 
+/*!
+    \internal
+    \brief Broadcast private attribute for local node with protocol version
+*/
+void
+attrd_broadcast_protocol()
+{
+    xmlNode *attrd_op = create_xml_node(NULL, __FUNCTION__);
+
+    crm_xml_add(attrd_op, F_TYPE, T_ATTRD);
+    crm_xml_add(attrd_op, F_ORIG, crm_system_name);
+    crm_xml_add(attrd_op, F_ATTRD_TASK, ATTRD_OP_UPDATE);
+    crm_xml_add(attrd_op, F_ATTRD_ATTRIBUTE, "#attrd-protocol");
+    crm_xml_add(attrd_op, F_ATTRD_VALUE, ATTRD_PROTOCOL_VERSION);
+    crm_xml_add_int(attrd_op, F_ATTRD_IS_PRIVATE, 1);
+    attrd_client_update(attrd_op);
+}
+
 void
 attrd_peer_message(crm_node_t *peer, xmlNode *xml)
 {
Index: pacemaker-1.1.16+20170320.77ea74d/attrd/internal.h
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/attrd/internal.h
+++ pacemaker-1.1.16+20170320.77ea74d/attrd/internal.h
@@ -28,6 +28,7 @@ int attrd_error;
     crm_ipcs_send_ack((client), (id), (flags), "ack", __FUNCTION__, __LINE__)
 
 void write_attributes(bool all, bool peer_discovered);
+void attrd_broadcast_protocol(void);
 void attrd_peer_message(crm_node_t *client, xmlNode *msg);
 void attrd_client_peer_remove(const char *client_name, xmlNode *xml);
 void attrd_client_clear_failure(xmlNode *xml);
Index: pacemaker-1.1.16+20170320.77ea74d/attrd/main.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/attrd/main.c
+++ pacemaker-1.1.16+20170320.77ea74d/attrd/main.c
@@ -205,6 +205,13 @@ attrd_cib_connect(int max_retry)
     // We have no attribute values in memory, wipe the CIB to match
     attrd_erase_attrs();
 
+    /* Set a private attribute for ourselves with the protocol version we
+     * support. This lets all nodes determine the minimum supported version
+     * across all nodes. It also ensures that the writer learns our node name,
+     * so it can send our attributes to the CIB.
+     */
+    attrd_broadcast_protocol();
+
     return pcmk_ok;
 
   cleanup:
openSUSE Build Service is sponsored by