From 28faf9cdd3cd79b0290b9b457c5192421fc5c52f Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Thu, 24 Oct 2024 14:46:36 -0500
Subject: [PATCH 04/16] Low: pacemaker-attrd: bail earlier if value won't be
 written

We only need the node XML ID for writing values to the CIB, so if a
value will never be written, skip looking for the XML ID.

This does mean that cluster nodes won't be added to the peer cache for
unwritten attributes, but that shouldn't matter for them.
---
 daemons/attrd/attrd_cib.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/daemons/attrd/attrd_cib.c b/daemons/attrd/attrd_cib.c
index 6129f54c75..808a7bc7e3 100644
--- a/daemons/attrd/attrd_cib.c
+++ b/daemons/attrd/attrd_cib.c
@@ -545,6 +545,12 @@ write_attribute(attribute_t *a, bool ignore_delay)
     while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &v)) {
         const char *node_xml_id = NULL;
 
+        // Private attributes (or any in standalone mode) are not written to CIB
+        if (stand_alone || pcmk_is_set(a->flags, attrd_attr_is_private)) {
+            private_updates++;
+            continue;
+        }
+
         // Try to get the XML ID used for the node in the CIB
         if (pcmk_is_set(v->flags, attrd_value_remote)) {
             // A Pacemaker Remote node's XML ID is the same as its name
@@ -568,12 +574,6 @@ write_attribute(attribute_t *a, bool ignore_delay)
             }
         }
 
-        /* If this is a private attribute, no update needs to be sent */
-        if (stand_alone || pcmk_is_set(a->flags, attrd_attr_is_private)) {
-            private_updates++;
-            continue;
-        }
-
         // Defer write if this is a cluster node that's never been seen
         if (node_xml_id == NULL) {
             attrd_set_attr_flags(a, attrd_attr_uuid_missing);
-- 
2.43.0

