File bug-981489_pacemaker-attrd-remote-node-peer-cache.patch of Package pacemaker.3577

commit 942efa4e8edcfdbdce42505c30c18cacd1d8fff0
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Tue Jan 26 15:55:46 2016 -0600

    Fix: attrd: ensure remote nodes are in correct peer cache
    
    If attrd receives an update for an unknown node name, it assumes the unknown
    node is a cluster node, and adds it to the cluster peer cache.
    
    Previously, if the name was later used for a remote node, that would prevent
    its attributes from being written to the CIB. Now, when an attribute is
    received for a remote node, attrd will purge any inactive cluster peer cache
    entry before adding the node to the remote peer cache.

diff --git a/attrd/commands.c b/attrd/commands.c
index 28e4a81..b2cc83a 100644
--- a/attrd/commands.c
+++ b/attrd/commands.c
@@ -634,6 +634,22 @@ static attribute_value_t *
 attrd_lookup_or_create_value(GHashTable *values, const char *host, xmlNode *xml)
 {
     attribute_value_t *v = g_hash_table_lookup(values, host);
+    int is_remote = 0;
+
+    crm_element_value_int(xml, F_ATTRD_IS_REMOTE, &is_remote);
+    if (is_remote) {
+        /* If we previously assumed this node was an unseen cluster node,
+         * remove its entry from the cluster peer cache.
+         */
+        crm_node_t *dup = crm_find_peer(0, host);
+
+        if (dup && (dup->uuid == NULL)) {
+            reap_crm_member(0, host);
+        }
+
+        /* Ensure this host is in the remote peer cache */
+        crm_remote_peer_cache_add(host);
+    }
 
     if (v == NULL) {
         v = calloc(1, sizeof(attribute_value_t));
@@ -642,11 +658,7 @@ attrd_lookup_or_create_value(GHashTable *values, const char *host, xmlNode *xml)
         v->nodename = strdup(host);
         CRM_ASSERT(v->nodename != NULL);
 
-        crm_element_value_int(xml, F_ATTRD_IS_REMOTE, &v->is_remote);
-        if (v->is_remote == TRUE) {
-            crm_remote_peer_cache_add(host);
-        }
-
+        v->is_remote = is_remote;
         g_hash_table_replace(values, v->nodename, v);
     }
     return(v);
openSUSE Build Service is sponsored by