File bug-977800-pacemaker-pengine-Organize-order-of-actions-for-master-res.patch of Package pacemaker.9287
From 386eb49271fc54debf43cebada602d09d71ee0cd Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Fri, 29 Apr 2016 14:28:30 +0200
Subject: [PATCH 1/2] Fix: pengine: Organize order of actions for master
resources in anti-colocations
This is the extending of 9f9ed87.
---
pengine/constraints.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
Index: pacemaker/pengine/constraints.c
===================================================================
--- pacemaker.orig/pengine/constraints.c
+++ pacemaker/pengine/constraints.c
@@ -1052,6 +1052,32 @@ sort_cons_priority_rh(gconstpointer a, g
return strcmp(rsc_constraint1->rsc_rh->id, rsc_constraint2->rsc_rh->id);
}
+static void
+anti_colocation_order(resource_t * first_rsc, int first_role,
+ resource_t * then_rsc, int then_role,
+ pe_working_set_t * data_set)
+{
+ const char *first_task = NULL;
+ const char *then_task = NULL;
+
+ if (first_role == RSC_ROLE_MASTER) {
+ first_task = CRMD_ACTION_DEMOTE;
+
+ } else {
+ first_task = CRMD_ACTION_STOP;
+ }
+
+ if (then_role == RSC_ROLE_MASTER) {
+ then_task = CRMD_ACTION_PROMOTE;
+
+ } else {
+ then_task = CRMD_ACTION_START;
+ }
+
+ new_rsc_order(first_rsc, first_task, then_rsc, then_task,
+ pe_order_anti_colocation, data_set);
+}
+
gboolean
rsc_colocation_new(const char *id, const char *node_attr, int score,
resource_t * rsc_lh, resource_t * rsc_rh,
@@ -1103,10 +1129,8 @@ rsc_colocation_new(const char *id, const
data_set->colocation_constraints = g_list_append(data_set->colocation_constraints, new_con);
if (score <= -INFINITY) {
- new_rsc_order(rsc_lh, CRMD_ACTION_STOP, rsc_rh, CRMD_ACTION_START,
- pe_order_anti_colocation, data_set);
- new_rsc_order(rsc_rh, CRMD_ACTION_STOP, rsc_lh, CRMD_ACTION_START,
- pe_order_anti_colocation, data_set);
+ anti_colocation_order(rsc_lh, new_con->role_lh, rsc_rh, new_con->role_rh, data_set);
+ anti_colocation_order(rsc_rh, new_con->role_rh, rsc_lh, new_con->role_lh, data_set);
}
return TRUE;