File pacemaker-crmd-validate-CIB-diffs-better.patch of Package pacemaker.8397

commit 8c286edcef4e2b1dcaf4c2560574324903fa18ef
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Mon Feb 26 11:44:19 2018 -0600

    Low: crmd: validate CIB diffs better
    
    This contains refactoring and logging changes to make the diff processing code
    more readable, validate CIB diffs better, and log diff issues consistently.

Index: pacemaker-1.1.18+20180126.bfe4e8042/crmd/te_callbacks.c
===================================================================
--- pacemaker-1.1.18+20180126.bfe4e8042.orig/crmd/te_callbacks.c
+++ pacemaker-1.1.18+20180126.bfe4e8042/crmd/te_callbacks.c
@@ -241,38 +241,50 @@ te_legacy_update_diff(const char *event,
     freeXpathObject(xpathObj);
 }
 
-static void process_resource_updates(
-    const char *node, xmlNode *xml, xmlNode *change, const char *op, const char *xpath) 
+static void
+process_lrm_resource_diff(xmlNode *lrm_resource, const char *node)
+{
+    for (xmlNode *rsc_op = __xml_first_child(lrm_resource); rsc_op != NULL;
+         rsc_op = __xml_next(rsc_op)) {
+        process_graph_event(rsc_op, node);
+    }
+}
+
+static void
+process_resource_updates(const char *node, xmlNode *xml, xmlNode *change,
+                         const char *op, const char *xpath)
 {
     xmlNode *cIter = NULL;
     xmlNode *rsc = NULL;
-    xmlNode *rsc_op = NULL;
     int num_resources = 0;
 
-    if(xml == NULL) {
+    if (xml == NULL) {
         return;
 
-    } else if(strcmp((const char*)xml->name, XML_CIB_TAG_LRM) == 0) {
+    } else if (strcmp((const char*)xml->name, XML_CIB_TAG_LRM) == 0) {
         xml = first_named_child(xml, XML_LRM_TAG_RESOURCES);
         crm_trace("Got %p in %s", xml, XML_CIB_TAG_LRM);
     }
 
     CRM_ASSERT(strcmp((const char*)xml->name, XML_LRM_TAG_RESOURCES) == 0);
 
-    for(cIter = xml->children; cIter; cIter = cIter->next) {
+    for (cIter = xml->children; cIter; cIter = cIter->next) {
         num_resources++;
     }
 
-    if(num_resources > 1) {
+    if (num_resources > 1) {
         /*
-         * Check for and fast-track the processing of LRM refreshes
-         * In large clusters this can result in _huge_ speedups
+         * Updates by, or in response to, TE actions will never contain updates
+         * for more than one resource at a time, so such updates indicate an
+         * LRM refresh.
          *
-         * Unfortunately we can only do so when there are no pending actions
-         * Otherwise we could miss updates we're waiting for and stall
+         * In that case, start a new transition rather than check each result
+         * individually, which can result in _huge_ speedups in large clusters.
          *
+         * Unfortunately, we can only do so when there are no pending actions.
+         * Otherwise, we could mistakenly throw away those results here, and
+         * the cluster will stall waiting for them and time out the operation.
          */
-
         crm_debug("Detected LRM refresh - %d resources updated", num_resources);
         crm_log_xml_trace(change, "lrm-refresh");
         abort_transition(INFINITY, tg_restart, "LRM Refresh", NULL);
@@ -281,10 +293,7 @@ static void process_resource_updates(
 
     for (rsc = __xml_first_child(xml); rsc != NULL; rsc = __xml_next(rsc)) {
         crm_trace("Processing %s", ID(rsc));
-        for (rsc_op = __xml_first_child(rsc); rsc_op != NULL; rsc_op = __xml_next(rsc_op)) {
-            crm_trace("Processing %s", ID(rsc_op));
-            process_graph_event(rsc_op, node);
-        }
+        process_lrm_resource_diff(rsc, node);
     }
 }
 
openSUSE Build Service is sponsored by