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