Blame SOURCES/bz1069284-pcmk-prevent_resources_in_an_anti_colocation_from_even_temporarily_running_on_a_same_node.patch

7100e8
commit 79759709fd71a2d0b9f4d0167ba9697257a9653c
7100e8
Author: Gao,Yan <ygao@suse.com>
7100e8
Date:   Thu Feb 20 01:24:46 2014 +0800
7100e8
7100e8
    Fix: pengine: cl#5187 - Prevent resources in an anti-colocation from even temporarily running on a same node
7100e8
    
7100e8
    (cherry picked from commit 9f9ed87e01bfafec0ddeee6592eb07e81bef963e)
7100e8
7100e8
diff --git a/include/crm/pengine/status.h b/include/crm/pengine/status.h
7100e8
index eb52464..158a562 100644
7100e8
--- a/include/crm/pengine/status.h
7100e8
+++ b/include/crm/pengine/status.h
7100e8
@@ -338,6 +338,7 @@ enum pe_ordering {
7100e8
     pe_order_asymmetrical          = 0x100000,    /* Indicates asymmetrical one way ordering constraint. */
7100e8
     pe_order_load                  = 0x200000,    /* Only relevant if... */
7100e8
     pe_order_one_or_more           = 0x400000,    /* 'then' is only runnable if one or more of it's dependancies are too */
7100e8
+    pe_order_anti_colocation       = 0x800000,
7100e8
 
7100e8
     pe_order_trace                 = 0x4000000  /* test marker */
7100e8
 };
7100e8
diff --git a/pengine/constraints.c b/pengine/constraints.c
7100e8
index 594d630..3b4370d 100644
7100e8
--- a/pengine/constraints.c
7100e8
+++ b/pengine/constraints.c
7100e8
@@ -689,6 +689,13 @@ rsc_colocation_new(const char *id, const char *node_attr, int score,
7100e8
 
7100e8
     data_set->colocation_constraints = g_list_append(data_set->colocation_constraints, new_con);
7100e8
 
7100e8
+    if (score <= -INFINITY) {
7100e8
+        new_rsc_order(rsc_lh, CRMD_ACTION_STOP, rsc_rh, CRMD_ACTION_START,
7100e8
+                      pe_order_anti_colocation, data_set);
7100e8
+        new_rsc_order(rsc_rh, CRMD_ACTION_STOP, rsc_lh, CRMD_ACTION_START,
7100e8
+                      pe_order_anti_colocation, data_set);
7100e8
+    }
7100e8
+
7100e8
     return TRUE;
7100e8
 }
7100e8
 
7100e8
diff --git a/pengine/graph.c b/pengine/graph.c
7100e8
index 9c1bc15..779f0e0 100644
7100e8
--- a/pengine/graph.c
7100e8
+++ b/pengine/graph.c
7100e8
@@ -991,6 +991,27 @@ should_dump_input(int last_action, action_t * action, action_wrapper_t * wrapper
7100e8
             return FALSE;
7100e8
         }
7100e8
 
7100e8
+    } else if (wrapper->type == pe_order_anti_colocation) {
7100e8
+        crm_trace("check anti-colocation filter %s.%s -> %s.%s",
7100e8
+                  wrapper->action->uuid,
7100e8
+                  wrapper->action->node ? wrapper->action->node->details->uname : "",
7100e8
+                  action->uuid,
7100e8
+                  action->node ? action->node->details->uname : "");
7100e8
+
7100e8
+        if (wrapper->action->node && action->node
7100e8
+            && wrapper->action->node->details != action->node->details) {
7100e8
+            /* Check if the actions are for the same node, ignore otherwise */
7100e8
+            crm_trace("anti-colocation filter - node");
7100e8
+            wrapper->type = pe_order_none;
7100e8
+            return FALSE;
7100e8
+
7100e8
+        } else if (is_set(wrapper->action->flags, pe_action_optional)) {
7100e8
+            /* Check if the pre-req is optional, ignore if so */
7100e8
+            crm_trace("anti-colocation filter - optional");
7100e8
+            wrapper->type = pe_order_none;
7100e8
+            return FALSE;
7100e8
+        }
7100e8
+
7100e8
     } else if (wrapper->action->rsc
7100e8
                && wrapper->action->rsc != action->rsc
7100e8
                && is_set(wrapper->action->rsc->flags, pe_rsc_failed)