commit 80740307d1ab6d037c610adaa6fe3abb14acda79
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Wed Oct 18 11:56:21 2017 -0500

    Test: pengine: new regression test for rebalancing unique clone instances
    
    This is a variation of the bug-lf-2445 test where the clone has positive
    (rather than 0) location preferences for each node.
    
    As in bug-lf-2445, here a globally unique clone has more instances on one node
    than optimal, the clone's stickiness is 0, and another node is available to run
    the clone. The cluster should rebalance the clone instances across nodes.

Index: pacemaker-1.1.16+20170320.77ea74d/pengine/regression.sh
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/pengine/regression.sh
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/regression.sh
@@ -370,6 +370,7 @@ do_test clone-fail-block-colocation "Mov
 do_test clone-interleave-1 "Clone-3 cannot start on pcmk-1 due to interleaved ordering (no colocation)"
 do_test clone-interleave-2 "Clone-3 must stop on pcmk-1 due to interleaved ordering (no colocation)"
 do_test clone-interleave-3 "Clone-3 must be recovered on pcmk-1 due to interleaved ordering (no colocation)"
+do_test rebalance-unique-clones "Rebalance unique clone instances with no stickiness"
 
 echo ""
 do_test cloned_start_one  "order first clone then clone... first clone_min=2"
Index: pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.dot
===================================================================
--- /dev/null
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.dot
@@ -0,0 +1,20 @@
+digraph "g" {
+"C_running_0" [ style=bold color="green" fontcolor="orange"]
+"C_start_0" -> "C_running_0" [ style = bold]
+"C_start_0" -> "P:1_start_0 node2" [ style = bold]
+"C_start_0" [ style=bold color="green" fontcolor="orange"]
+"C_stop_0" -> "C_stopped_0" [ style = bold]
+"C_stop_0" -> "P:1_stop_0 node1" [ style = bold]
+"C_stop_0" [ style=bold color="green" fontcolor="orange"]
+"C_stopped_0" -> "C_start_0" [ style = bold]
+"C_stopped_0" [ style=bold color="green" fontcolor="orange"]
+"P:1_monitor_10000 node2" [ style=bold color="green" fontcolor="black"]
+"P:1_start_0 node2" -> "C_running_0" [ style = bold]
+"P:1_start_0 node2" -> "P:1_monitor_10000 node2" [ style = bold]
+"P:1_start_0 node2" [ style=bold color="green" fontcolor="black"]
+"P:1_stop_0 node1" -> "C_stopped_0" [ style = bold]
+"P:1_stop_0 node1" -> "P:1_start_0 node2" [ style = bold]
+"P:1_stop_0 node1" -> "all_stopped" [ style = bold]
+"P:1_stop_0 node1" [ style=bold color="green" fontcolor="black"]
+"all_stopped" [ style=bold color="green" fontcolor="orange"]
+}
Index: pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.exp
===================================================================
--- /dev/null
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.exp
@@ -0,0 +1,106 @@
+<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="8" operation="monitor" operation_key="P:1_monitor_10000" on_node="node2" on_node_uuid="169745990">
+        <primitive id="P:1" class="ocf" provider="heartbeat" type="IPaddr2"/>
+        <attributes CRM_meta_clone="1" CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_interval="10000" CRM_meta_name="monitor" CRM_meta_notify="false" CRM_meta_on_node="node2" CRM_meta_on_node_uuid="169745990" CRM_meta_timeout="20000" cidr_netmask="32" clusterip_hash="sourceip-sourceport"  iflabel="web" ip="192.168.195.110" mac="03:00:60:0D:F0:0D"/>
+      </rsc_op>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="7" operation="start" operation_key="P:1_start_0" on_node="node2" on_node_uuid="169745990"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="1">
+    <action_set>
+      <rsc_op id="7" operation="start" operation_key="P:1_start_0" on_node="node2" on_node_uuid="169745990">
+        <primitive id="P:1" class="ocf" provider="heartbeat" type="IPaddr2"/>
+        <attributes CRM_meta_clone="1" CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_name="start" CRM_meta_notify="false" CRM_meta_on_node="node2" CRM_meta_on_node_uuid="169745990" CRM_meta_timeout="20000" cidr_netmask="32" clusterip_hash="sourceip-sourceport"  iflabel="web" ip="192.168.195.110" mac="03:00:60:0D:F0:0D"/>
+      </rsc_op>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="6" operation="stop" operation_key="P:1_stop_0" on_node="node1" on_node_uuid="169745988"/>
+      </trigger>
+      <trigger>
+        <pseudo_event id="9" operation="start" operation_key="C_start_0"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="2">
+    <action_set>
+      <rsc_op id="6" operation="stop" operation_key="P:1_stop_0" on_node="node1" on_node_uuid="169745988">
+        <primitive id="P:1" class="ocf" provider="heartbeat" type="IPaddr2"/>
+        <attributes CRM_meta_clone="1" CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_name="stop" CRM_meta_notify="false" CRM_meta_on_node="node1" CRM_meta_on_node_uuid="169745988" CRM_meta_timeout="20000" cidr_netmask="32" clusterip_hash="sourceip-sourceport"  iflabel="web" ip="192.168.195.110" mac="03:00:60:0D:F0:0D"/>
+      </rsc_op>
+    </action_set>
+    <inputs>
+      <trigger>
+        <pseudo_event id="11" operation="stop" operation_key="C_stop_0"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="3" priority="1000000">
+    <action_set>
+      <pseudo_event id="12" operation="stopped" operation_key="C_stopped_0">
+        <attributes CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_notify="false" CRM_meta_timeout="20000" />
+      </pseudo_event>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="6" operation="stop" operation_key="P:1_stop_0" on_node="node1" on_node_uuid="169745988"/>
+      </trigger>
+      <trigger>
+        <pseudo_event id="11" operation="stop" operation_key="C_stop_0"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="4">
+    <action_set>
+      <pseudo_event id="11" operation="stop" operation_key="C_stop_0">
+        <attributes CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_notify="false" CRM_meta_timeout="20000" />
+      </pseudo_event>
+    </action_set>
+    <inputs/>
+  </synapse>
+  <synapse id="5" priority="1000000">
+    <action_set>
+      <pseudo_event id="10" operation="running" operation_key="C_running_0">
+        <attributes CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_notify="false" CRM_meta_timeout="20000" />
+      </pseudo_event>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="7" operation="start" operation_key="P:1_start_0" on_node="node2" on_node_uuid="169745990"/>
+      </trigger>
+      <trigger>
+        <pseudo_event id="9" operation="start" operation_key="C_start_0"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="6">
+    <action_set>
+      <pseudo_event id="9" operation="start" operation_key="C_start_0">
+        <attributes CRM_meta_clone_max="2" CRM_meta_clone_node_max="2" CRM_meta_globally_unique="true" CRM_meta_notify="false" CRM_meta_timeout="20000" />
+      </pseudo_event>
+    </action_set>
+    <inputs>
+      <trigger>
+        <pseudo_event id="12" operation="stopped" operation_key="C_stopped_0"/>
+      </trigger>
+    </inputs>
+  </synapse>
+  <synapse id="7">
+    <action_set>
+      <pseudo_event id="3" operation="all_stopped" operation_key="all_stopped">
+        <attributes />
+      </pseudo_event>
+    </action_set>
+    <inputs>
+      <trigger>
+        <rsc_op id="6" operation="stop" operation_key="P:1_stop_0" on_node="node1" on_node_uuid="169745988"/>
+      </trigger>
+    </inputs>
+  </synapse>
+</transition_graph>
Index: pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.scores
===================================================================
--- /dev/null
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.scores
@@ -0,0 +1,11 @@
+Allocation scores:
+clone_color: C allocation score on node1: 100
+clone_color: C allocation score on node2: 100
+clone_color: P:0 allocation score on node1: 100
+clone_color: P:0 allocation score on node2: 100
+clone_color: P:1 allocation score on node1: 100
+clone_color: P:1 allocation score on node2: 100
+native_color: P:0 allocation score on node1: 100
+native_color: P:0 allocation score on node2: 100
+native_color: P:1 allocation score on node1: 100
+native_color: P:1 allocation score on node2: 100
Index: pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.summary
===================================================================
--- /dev/null
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.summary
@@ -0,0 +1,28 @@
+
+Current cluster status:
+Online: [ node1 node2 ]
+
+ Clone Set: C [P] (unique)
+     P:0	(ocf::heartbeat:IPaddr2):	Started node1
+     P:1	(ocf::heartbeat:IPaddr2):	Started node1
+
+Transition Summary:
+ * Move    P:1	(Started node1 -> node2)
+
+Executing cluster transition:
+ * Pseudo action:   C_stop_0
+ * Resource action: P:1             stop on node1
+ * Pseudo action:   C_stopped_0
+ * Pseudo action:   C_start_0
+ * Pseudo action:   all_stopped
+ * Resource action: P:1             start on node2
+ * Pseudo action:   C_running_0
+ * Resource action: P:1             monitor=10000 on node2
+
+Revised cluster status:
+Online: [ node1 node2 ]
+
+ Clone Set: C [P] (unique)
+     P:0	(ocf::heartbeat:IPaddr2):	Started node1
+     P:1	(ocf::heartbeat:IPaddr2):	Started node2
+
Index: pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.xml
===================================================================
--- /dev/null
+++ pacemaker-1.1.16+20170320.77ea74d/pengine/test10/rebalance-unique-clones.xml
@@ -0,0 +1,85 @@
+<cib crm_feature_set="3.0.12" validate-with="pacemaker-2.7" epoch="152" num_updates="0" admin_epoch="2" cib-last-written="Thu Oct  5 15:32:00 2017" update-origin="node2" update-client="crm_resource" update-user="root" have-quorum="1" dc-uuid="169745988">
+  <configuration>
+    <crm_config>
+      <cluster_property_set id="cib-bootstrap-options">
+        <nvpair id="cib-bootstrap-options-stonith-enabled" name="stonith-enabled" value="false"/>
+        <nvpair id="cib-bootstrap-options-no-quorum-policy" name="no-quorum-policy" value="ignore"/>
+      </cluster_property_set>
+    </crm_config>
+    <nodes>
+      <node id="169745988" uname="node1"/>
+      <node id="169745990" uname="node2"/>
+    </nodes>
+    <resources>
+      <clone id="C">
+        <meta_attributes id="C-meta_attributes">
+          <nvpair name="globally-unique" value="true" id="C-meta_attributes-globally-unique"/>
+          <nvpair name="clone-max" value="2" id="C-meta_attributes-clone-max"/>
+          <nvpair name="clone-node-max" value="2" id="C-meta_attributes-clone-node-max"/>
+          <nvpair name="resource-stickiness" value="0" id="C-meta_attributes-resource-stickiness"/>
+        </meta_attributes>
+        <primitive id="P" class="ocf" provider="heartbeat" type="IPaddr2">
+          <instance_attributes id="P-instance_attributes">
+            <nvpair name="ip" value="192.168.195.110" id="P-instance_attributes-ip"/>
+            <nvpair name="cidr_netmask" value="32" id="P-instance_attributes-cidr_netmask"/>
+            <nvpair name="iflabel" value="web" id="P-instance_attributes-iflabel"/>
+            <nvpair name="clusterip_hash" value="sourceip-sourceport" id="P-instance_attributes-clusterip_hash"/>
+            <nvpair name="mac" value="03:00:60:0D:F0:0D" id="P-instance_attributes-mac"/>
+          </instance_attributes>
+          <operations>
+            <op name="monitor" interval="10s" timeout="20s" id="P-monitor-10s"/>
+            <op name="start" interval="0s" timeout="20s" id="P-start-0s"/>
+            <op name="stop" interval="0s" timeout="20s" id="P-stop-0s"/>
+          </operations>
+        </primitive>
+      </clone>
+    </resources>
+    <constraints>
+      <rsc_location id="C-node1" rsc="C" node="node1" score="100" />
+      <rsc_location id="C-node2" rsc="C" node="node2" score="100" />
+    </constraints>
+    <rsc_defaults>
+      <meta_attributes id="rsc_defaults-options"/>
+    </rsc_defaults>
+  </configuration>
+  <status>
+    <node_state id="169745990" uname="node2" in_ccm="true" crmd="online" crm-debug-origin="do_update_resource" join="member" expected="member">
+      <transient_attributes id="169745990">
+        <instance_attributes id="status-169745990">
+          <nvpair id="status-169745990-shutdown" name="shutdown" value="0"/>
+        </instance_attributes>
+      </transient_attributes>
+      <lrm id="169745990">
+        <lrm_resources>
+          <lrm_resource id="P:0" type="IPaddr2" class="ocf" provider="heartbeat">
+            <lrm_rsc_op id="P:0_last_0" operation_key="P:0_stop_0" operation="stop" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="5:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;5:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node2" call-id="281" rc-code="0" op-status="0" interval="0" last-run="1507217472" last-rc-change="1507217472" exec-time="550" queue-time="0" op-digest="e1414a1e567403e7965929cfe9a112a5"/>
+            <lrm_rsc_op id="P:0_monitor_10000" operation_key="P:0_monitor_10000" operation="monitor" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="7:50:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;7:50:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node2" call-id="271" rc-code="0" op-status="0" interval="10000" last-rc-change="1507217407" exec-time="74" queue-time="0" op-digest="4870e6b6b1f0b207d9638528fb8d86c8"/>
+          </lrm_resource>
+          <lrm_resource id="P:1" type="IPaddr2" class="ocf" provider="heartbeat">
+            <lrm_rsc_op id="P:1_last_0" operation_key="P:1_stop_0" operation="stop" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="8:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;8:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node2" call-id="279" rc-code="0" op-status="0" interval="0" last-run="1507217472" last-rc-change="1507217472" exec-time="229" queue-time="0" op-digest="e1414a1e567403e7965929cfe9a112a5"/>
+            <lrm_rsc_op id="P:1_monitor_10000" operation_key="P:1_monitor_10000" operation="monitor" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="10:50:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;10:50:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node2" call-id="273" rc-code="0" op-status="0" interval="10000" last-rc-change="1507217408" exec-time="68" queue-time="0" op-digest="4870e6b6b1f0b207d9638528fb8d86c8"/>
+          </lrm_resource>
+        </lrm_resources>
+      </lrm>
+    </node_state>
+    <node_state id="169745988" uname="node1" in_ccm="true" crmd="online" crm-debug-origin="do_update_resource" join="member" expected="member">
+      <transient_attributes id="169745988">
+        <instance_attributes id="status-169745988">
+          <nvpair id="status-169745988-shutdown" name="shutdown" value="0"/>
+        </instance_attributes>
+      </transient_attributes>
+      <lrm id="169745988">
+        <lrm_resources>
+          <lrm_resource id="P:0" type="IPaddr2" class="ocf" provider="heartbeat">
+            <lrm_rsc_op id="P:0_last_0" operation_key="P:0_start_0" operation="start" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="6:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;6:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node1" call-id="294" rc-code="0" op-status="0" interval="0" last-run="1507217472" last-rc-change="1507217472" exec-time="298" queue-time="0" op-digest="e1414a1e567403e7965929cfe9a112a5"/>
+            <lrm_rsc_op id="P:0_monitor_10000" operation_key="P:0_monitor_10000" operation="monitor" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="7:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;7:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node1" call-id="295" rc-code="0" op-status="0" interval="10000" last-rc-change="1507217473" exec-time="81" queue-time="0" op-digest="4870e6b6b1f0b207d9638528fb8d86c8"/>
+          </lrm_resource>
+          <lrm_resource id="P:1" type="IPaddr2" class="ocf" provider="heartbeat">
+            <lrm_rsc_op id="P:1_last_0" operation_key="P:1_start_0" operation="start" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="9:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;9:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node1" call-id="296" rc-code="0" op-status="0" interval="0" last-run="1507217473" last-rc-change="1507217473" exec-time="862" queue-time="1" op-digest="e1414a1e567403e7965929cfe9a112a5"/>
+            <lrm_rsc_op id="P:1_monitor_10000" operation_key="P:1_monitor_10000" operation="monitor" crm-debug-origin="do_update_resource" crm_feature_set="3.0.12" transition-key="10:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" transition-magic="0:0;10:51:0:5714f1f6-b8ce-40ae-a8da-4f927f39d82d" on_node="node1" call-id="297" rc-code="0" op-status="0" interval="10000" last-rc-change="1507217474" exec-time="94" queue-time="0" op-digest="4870e6b6b1f0b207d9638528fb8d86c8"/>
+          </lrm_resource>
+        </lrm_resources>
+      </lrm>
+    </node_state>
+  </status>
+</cib>
