commit 97629ded958f76652350569a54303b3cd25d1d7e
Author: Andrew Beekhof <andrew@beekhof.net>
Date:   Fri Jun 13 14:04:29 2014 +1000

    Bug cl#5219 - PE: Allow unrelated resources with a common colocation target to remain promoted

Index: pacemaker/pengine/native.c
===================================================================
--- pacemaker.orig/pengine/native.c
+++ pacemaker/pengine/native.c
@@ -565,7 +565,7 @@ rsc_merge_weights(resource_t * rsc, cons
 
             pe_rsc_trace(rsc, "Applying %s (%s)", constraint->id, other->id);
             work = rsc_merge_weights(other, rhs, work, constraint->node_attribute,
-                                     multiplier * (float)constraint->score / INFINITY, flags);
+                                     multiplier * (float)constraint->score / INFINITY, flags|pe_weights_rollback);
             dump_node_scores(LOG_TRACE, NULL, rhs, work);
         }
 
Index: pacemaker/pengine/regression.sh
===================================================================
--- pacemaker.orig/pengine/regression.sh
+++ pacemaker/pengine/regression.sh
@@ -384,6 +384,7 @@ do_test master-demote-block "Block promo
 do_test master-dependant-ban "Don't stop instances from being active because a dependant is banned from that host"
 do_test master-stop "Stop instances due to location constraint with role=Started"
 do_test master-partially-demoted-group "Allow partially demoted group to finish demoting"
+do_test bug-cl-5219 "Allow unrelated resources with a common colocation target to remain promoted"
 
 echo ""
 do_test history-1 "Correctly parse stateful-1 resource state"
Index: pacemaker/pengine/test10/bug-cl-5219.dot
===================================================================
--- /dev/null
+++ pacemaker/pengine/test10/bug-cl-5219.dot
@@ -0,0 +1,5 @@
+digraph "g" {
+"all_stopped" [ style=bold color="green" fontcolor="orange"]
+"child1-service_stop_0 ha2.test.anchor.net.au" -> "all_stopped" [ style = bold]
+"child1-service_stop_0 ha2.test.anchor.net.au" [ style=bold color="green" fontcolor="black"]
+}
Index: pacemaker/pengine/test10/bug-cl-5219.exp
===================================================================
--- /dev/null
+++ pacemaker/pengine/test10/bug-cl-5219.exp
@@ -0,0 +1,23 @@
+<transition_graph cluster-delay="60s" stonith-timeout="60s" failed-stop-offset="INFINITY" failed-start-offset="INFINITY"  transition_id="0">
+  <synapse id="0">
+    <action_set>
+      <rsc_op id="5" operation="stop" operation_key="child1-service_stop_0" on_node="ha2.test.anchor.net.au" on_node_uuid="3232235522">
+        <primitive id="child1-service" class="ocf" provider="pacemaker" type="Dummy"/>
+        <attributes CRM_meta_timeout="20000" />
+      </rsc_op>
+    </action_set>
+    <inputs/>
+  </synapse>
+  <synapse id="1">
+    <action_set>
+      <pseudo_event id="1" operation="all_stopped" operation_key="all_stopped">
+        <attributes />
+      </pseudo_event>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="5" operation="stop" operation_key="child1-service_stop_0" on_node="ha2.test.anchor.net.au" on_node_uuid="3232235522"/>
+      </trigger>
+    </inputs>
+  </synapse>
+</transition_graph>
Index: pacemaker/pengine/test10/bug-cl-5219.scores
===================================================================
--- /dev/null
+++ pacemaker/pengine/test10/bug-cl-5219.scores
@@ -0,0 +1,43 @@
+Allocation scores:
+clone_color: child1 allocation score on ha1.test.anchor.net.au: 0
+clone_color: child1 allocation score on ha2.test.anchor.net.au: 0
+clone_color: child2 allocation score on ha1.test.anchor.net.au: 0
+clone_color: child2 allocation score on ha2.test.anchor.net.au: 0
+clone_color: parent allocation score on ha1.test.anchor.net.au: 0
+clone_color: parent allocation score on ha2.test.anchor.net.au: 0
+clone_color: stateful-child1:0 allocation score on ha1.test.anchor.net.au: 0
+clone_color: stateful-child1:0 allocation score on ha2.test.anchor.net.au: 11
+clone_color: stateful-child1:1 allocation score on ha1.test.anchor.net.au: 6
+clone_color: stateful-child1:1 allocation score on ha2.test.anchor.net.au: 0
+clone_color: stateful-child2:0 allocation score on ha1.test.anchor.net.au: 0
+clone_color: stateful-child2:0 allocation score on ha2.test.anchor.net.au: 11
+clone_color: stateful-child2:1 allocation score on ha1.test.anchor.net.au: 6
+clone_color: stateful-child2:1 allocation score on ha2.test.anchor.net.au: 0
+clone_color: stateful-parent:0 allocation score on ha1.test.anchor.net.au: 0
+clone_color: stateful-parent:0 allocation score on ha2.test.anchor.net.au: 11
+clone_color: stateful-parent:1 allocation score on ha1.test.anchor.net.au: 6
+clone_color: stateful-parent:1 allocation score on ha2.test.anchor.net.au: 0
+native_color: child1-service allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: child1-service allocation score on ha2.test.anchor.net.au: -INFINITY
+native_color: child2-service allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: child2-service allocation score on ha2.test.anchor.net.au: 11
+native_color: parent-service allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: parent-service allocation score on ha2.test.anchor.net.au: 11
+native_color: stateful-child1:0 allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: stateful-child1:0 allocation score on ha2.test.anchor.net.au: 11
+native_color: stateful-child1:1 allocation score on ha1.test.anchor.net.au: 6
+native_color: stateful-child1:1 allocation score on ha2.test.anchor.net.au: 0
+native_color: stateful-child2:0 allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: stateful-child2:0 allocation score on ha2.test.anchor.net.au: 11
+native_color: stateful-child2:1 allocation score on ha1.test.anchor.net.au: 6
+native_color: stateful-child2:1 allocation score on ha2.test.anchor.net.au: 0
+native_color: stateful-parent:0 allocation score on ha1.test.anchor.net.au: -INFINITY
+native_color: stateful-parent:0 allocation score on ha2.test.anchor.net.au: 11
+native_color: stateful-parent:1 allocation score on ha1.test.anchor.net.au: 6
+native_color: stateful-parent:1 allocation score on ha2.test.anchor.net.au: 0
+stateful-child1:0 promotion score on ha2.test.anchor.net.au: INFINITY
+stateful-child1:1 promotion score on ha1.test.anchor.net.au: -INFINITY
+stateful-child2:0 promotion score on ha2.test.anchor.net.au: INFINITY
+stateful-child2:1 promotion score on ha1.test.anchor.net.au: -INFINITY
+stateful-parent:0 promotion score on ha2.test.anchor.net.au: 10
+stateful-parent:1 promotion score on ha1.test.anchor.net.au: 5
Index: pacemaker/pengine/test10/bug-cl-5219.summary
===================================================================
--- /dev/null
+++ pacemaker/pengine/test10/bug-cl-5219.summary
@@ -0,0 +1,40 @@
+
+Current cluster status:
+Online: [ ha1.test.anchor.net.au ha2.test.anchor.net.au ]
+
+ child1-service	(ocf::pacemaker:Dummy):	Started ha2.test.anchor.net.au 
+ child2-service	(ocf::pacemaker:Dummy):	Started ha2.test.anchor.net.au 
+ parent-service	(ocf::pacemaker:Dummy):	Started ha2.test.anchor.net.au 
+ Master/Slave Set: child1 [stateful-child1]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+ Master/Slave Set: child2 [stateful-child2]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+ Master/Slave Set: parent [stateful-parent]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+
+Transition Summary:
+ * Stop    child1-service	(ha2.test.anchor.net.au)
+
+Executing cluster transition:
+ * Resource action: child1-service  stop on ha2.test.anchor.net.au
+ * Pseudo action:   all_stopped
+
+Revised cluster status:
+Online: [ ha1.test.anchor.net.au ha2.test.anchor.net.au ]
+
+ child1-service	(ocf::pacemaker:Dummy):	Stopped 
+ child2-service	(ocf::pacemaker:Dummy):	Started ha2.test.anchor.net.au 
+ parent-service	(ocf::pacemaker:Dummy):	Started ha2.test.anchor.net.au 
+ Master/Slave Set: child1 [stateful-child1]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+ Master/Slave Set: child2 [stateful-child2]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+ Master/Slave Set: parent [stateful-parent]
+     Masters: [ ha2.test.anchor.net.au ]
+     Slaves: [ ha1.test.anchor.net.au ]
+
Index: pacemaker/pengine/test10/bug-cl-5219.xml
===================================================================
--- /dev/null
+++ pacemaker/pengine/test10/bug-cl-5219.xml
@@ -0,0 +1,114 @@
+<cib epoch="16" num_updates="7" admin_epoch="0" validate-with="pacemaker-1.2" crm_feature_set="3.0.8" cib-last-written="Fri Jun  6 15:08:14 2014" update-origin="ha1.test.anchor.net.au" update-client="cibadmin" have-quorum="1" dc-uuid="3232235521">
+  <configuration>
+    <crm_config>
+      <cluster_property_set id="cib-bootstrap-options">
+        <nvpair name="dc-version" value="1.1.11-1.0anchor1.el6-9d39a6b" id="cib-bootstrap-options-dc-version"/>
+        <nvpair name="cluster-infrastructure" value="corosync" id="cib-bootstrap-options-cluster-infrastructure"/>
+        <nvpair name="stonith-enabled" value="false" id="cib-bootstrap-options-stonith-enabled"/>
+        <nvpair name="stonith-action" value="poweroff" id="cib-bootstrap-options-stonith-action"/>
+        <nvpair name="pe-error-series-max" value="100" id="cib-bootstrap-options-pe-error-series-max"/>
+        <nvpair name="pe-input-series-max" value="100" id="cib-bootstrap-options-pe-input-series-max"/>
+        <nvpair name="pe-warn-series-max" value="100" id="cib-bootstrap-options-pe-warn-series-max"/>
+        <nvpair name="no-quorum-policy" value="freeze" id="cib-bootstrap-options-no-quorum-policy"/>
+      </cluster_property_set>
+    </crm_config>
+    <nodes>
+      <node id="3232235521" uname="ha1.test.anchor.net.au"/>
+      <node id="3232235522" uname="ha2.test.anchor.net.au"/>
+    </nodes>
+    <resources>
+      <primitive id="child1-service" class="ocf" provider="pacemaker" type="Dummy">
+        <meta_attributes id="child1-service-meta_attributes">
+          <nvpair id="child1-service-meta_attributes-target-role" name="target-role" value="Stopped"/>
+        </meta_attributes>
+      </primitive>
+      <primitive id="child2-service" class="ocf" provider="pacemaker" type="Dummy"/>
+      <primitive id="parent-service" class="ocf" provider="pacemaker" type="Dummy"/>
+      <master id="child1">
+        <primitive id="stateful-child1" class="ocf" provider="pacemaker" type="Stateful"/>
+      </master>
+      <master id="child2">
+        <primitive id="stateful-child2" class="ocf" provider="pacemaker" type="Stateful"/>
+      </master>
+      <master id="parent">
+        <primitive id="stateful-parent" class="ocf" provider="pacemaker" type="Stateful"/>
+      </master>
+    </resources>
+    <constraints>
+      <rsc_colocation id="child1-master-with-parent-master" score="INFINITY" rsc="child1" rsc-role="Master" with-rsc="parent" with-rsc-role="Master"/>
+      <rsc_colocation id="child1-service-with-child1-master" score="INFINITY" rsc="child1-service" with-rsc="child1" with-rsc-role="Master"/>
+      <rsc_colocation id="child2-master-with-parent-master" score="INFINITY" rsc="child2" rsc-role="Master" with-rsc="parent" with-rsc-role="Master"/>
+      <rsc_colocation id="child2-service-with-child2-master" score="INFINITY" rsc="child2-service" with-rsc="child2" with-rsc-role="Master"/>
+      <rsc_colocation id="parent-service-with-parent-master" score="INFINITY" rsc="parent-service" with-rsc="parent" with-rsc-role="Master"/>
+    </constraints>
+  </configuration>
+  <status>
+    <node_state id="3232235522" uname="ha2.test.anchor.net.au" in_ccm="true" crmd="online" crm-debug-origin="do_state_transition" join="member" expected="member">
+      <transient_attributes id="3232235522">
+        <instance_attributes id="status-3232235522">
+          <nvpair id="status-3232235522-shutdown" name="shutdown" value="0"/>
+          <nvpair id="status-3232235522-probe_complete" name="probe_complete" value="true"/>
+          <nvpair id="status-3232235522-master-stateful-child2" name="master-stateful-child2" value="10"/>
+          <nvpair id="status-3232235522-master-stateful-child1" name="master-stateful-child1" value="10"/>
+          <nvpair id="status-3232235522-master-stateful-parent" name="master-stateful-parent" value="10"/>
+        </instance_attributes>
+      </transient_attributes>
+      <lrm id="3232235522">
+        <lrm_resources>
+          <lrm_resource id="stateful-child1" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-child1_last_0" operation_key="stateful-child1_promote_0" operation="promote" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="14:2:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;14:2:0:abab8430-bb1b-499d-8426-a086255170be" call-id="45" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="63" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="child2-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="child2-service_last_0" operation_key="child2-service_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="6:18:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;6:18:0:abab8430-bb1b-499d-8426-a086255170be" call-id="60" rc-code="0" op-status="0" interval="0" last-run="1402031203" last-rc-change="1402031203" exec-time="30" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="stateful-child2" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-child2_last_0" operation_key="stateful-child2_promote_0" operation="promote" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="25:18:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;25:18:0:abab8430-bb1b-499d-8426-a086255170be" call-id="61" rc-code="0" op-status="0" interval="0" last-run="1402031203" last-rc-change="1402031203" exec-time="52" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="stateful-parent" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-parent_last_0" operation_key="stateful-parent_promote_0" operation="promote" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="40:2:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;40:2:0:abab8430-bb1b-499d-8426-a086255170be" call-id="47" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="83" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="child1-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="child1-service_last_0" operation_key="child1-service_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="5:18:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;5:18:0:abab8430-bb1b-499d-8426-a086255170be" call-id="59" rc-code="0" op-status="0" interval="0" last-run="1402031203" last-rc-change="1402031203" exec-time="32" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="parent-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="parent-service_last_0" operation_key="parent-service_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="11:2:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;11:2:0:abab8430-bb1b-499d-8426-a086255170be" call-id="44" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="30" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+        </lrm_resources>
+      </lrm>
+    </node_state>
+    <node_state id="3232235521" uname="ha1.test.anchor.net.au" in_ccm="true" crmd="online" crm-debug-origin="do_state_transition" join="member" expected="member">
+      <transient_attributes id="3232235521">
+        <instance_attributes id="status-3232235521">
+          <nvpair id="status-3232235521-shutdown" name="shutdown" value="0"/>
+          <nvpair id="status-3232235521-probe_complete" name="probe_complete" value="true"/>
+          <nvpair id="status-3232235521-master-stateful-child2" name="master-stateful-child2" value="5"/>
+          <nvpair id="status-3232235521-master-stateful-child1" name="master-stateful-child1" value="5"/>
+          <nvpair id="status-3232235521-master-stateful-parent" name="master-stateful-parent" value="5"/>
+        </instance_attributes>
+      </transient_attributes>
+      <lrm id="3232235521">
+        <lrm_resources>
+          <lrm_resource id="stateful-child1" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-child1_last_0" operation_key="stateful-child1_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="23:1:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;23:1:0:abab8430-bb1b-499d-8426-a086255170be" call-id="38" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="74" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="child2-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="child2-service_last_0" operation_key="child2-service_monitor_0" operation="monitor" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="5:1:7:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:7;5:1:7:abab8430-bb1b-499d-8426-a086255170be" call-id="9" rc-code="7" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="26" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="stateful-child2" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-child2_last_0" operation_key="stateful-child2_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="33:1:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;33:1:0:abab8430-bb1b-499d-8426-a086255170be" call-id="39" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="60" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="stateful-parent" type="Stateful" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="stateful-parent_last_0" operation_key="stateful-parent_start_0" operation="start" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="43:1:0:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:0;43:1:0:abab8430-bb1b-499d-8426-a086255170be" call-id="40" rc-code="0" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="74" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="child1-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="child1-service_last_0" operation_key="child1-service_monitor_0" operation="monitor" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="4:1:7:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:7;4:1:7:abab8430-bb1b-499d-8426-a086255170be" call-id="5" rc-code="7" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="33" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+          <lrm_resource id="parent-service" type="Dummy" class="ocf" provider="pacemaker">
+            <lrm_rsc_op id="parent-service_last_0" operation_key="parent-service_monitor_0" operation="monitor" crm-debug-origin="build_active_RAs" crm_feature_set="3.0.8" transition-key="8:1:7:abab8430-bb1b-499d-8426-a086255170be" transition-magic="0:7;8:1:7:abab8430-bb1b-499d-8426-a086255170be" call-id="21" rc-code="7" op-status="0" interval="0" last-run="1402031117" last-rc-change="1402031117" exec-time="13" queue-time="0" op-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8" op-force-restart=" state  op_sleep " op-restart-digest="f2317cad3d54cec5d7d7aa7d0bf35cf8"/>
+          </lrm_resource>
+        </lrm_resources>
+      </lrm>
+    </node_state>
+    <node_state id="3232235523" in_ccm="true" crmd="offline" join="down" crm-debug-origin="do_state_transition"/>
+  </status>
+</cib>
