From 942efa4e8edcfdbdce42505c30c18cacd1d8fff0 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 26 Jan 2016 15:55:46 -0600
Subject: [PATCH] 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.
---
attrd/commands.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
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);
--
1.8.3.1