File pacemaker-attrd-node-name-broadcast-at-start-up.patch of Package pacemaker.14737
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/attrd/commands.c
===================================================================
--- pacemaker.orig/attrd/commands.c
+++ pacemaker/attrd/commands.c
@@ -454,6 +454,24 @@ attrd_client_query(crm_client_t *client,
free_xml(reply);
}
+/*!
+ \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/attrd/internal.h
===================================================================
--- pacemaker.orig/attrd/internal.h
+++ pacemaker/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_update(xmlNode *xml);
Index: pacemaker/attrd/main.c
===================================================================
--- pacemaker.orig/attrd/main.c
+++ pacemaker/attrd/main.c
@@ -220,6 +220,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: