MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / master_promotion_order

Function master_promotion_order

pengine/master.c:274–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static void
275master_promotion_order(resource_t * rsc, pe_working_set_t * data_set)
276{
277 GListPtr gIter = NULL;
278 node_t *node = NULL;
279 node_t *chosen = NULL;
280 clone_variant_data_t *clone_data = NULL;
281
282 get_clone_variant_data(clone_data, rsc);
283
284 if (clone_data->merged_master_weights) {
285 return;
286 }
287 clone_data->merged_master_weights = TRUE;
288 pe_rsc_trace(rsc, "Merging weights for %s", rsc->id);
289 set_bit(rsc->flags, pe_rsc_merging);
290
291 gIter = rsc->children;
292 for (; gIter != NULL; gIter = gIter->next) {
293 resource_t *child = (resource_t *) gIter->data;
294
295 pe_rsc_trace(rsc, "Sort index: %s = %d", child->id, child->sort_index);
296 }
297 dump_node_scores(LOG_DEBUG_3, rsc, "Before", rsc->allowed_nodes);
298
299 gIter = rsc->children;
300 for (; gIter != NULL; gIter = gIter->next) {
301 resource_t *child = (resource_t *) gIter->data;
302
303 chosen = child->fns->location(child, NULL, FALSE);
304 if (chosen == NULL || child->sort_index < 0) {
305 pe_rsc_trace(rsc, "Skipping %s", child->id);
306 continue;
307 }
308
309 node = (node_t *) pe_hash_table_lookup(rsc->allowed_nodes, chosen->details->id);
310 CRM_ASSERT(node != NULL);
311 /* adds in master preferences and rsc_location.role=Master */
312 pe_rsc_trace(rsc, "Adding %s to %s from %s", score2char(child->sort_index), node->details->uname,
313 child->id);
314 node->weight = merge_weights(child->sort_index, node->weight);
315 }
316
317 dump_node_scores(LOG_DEBUG_3, rsc, "Middle", rsc->allowed_nodes);
318
319 gIter = rsc->rsc_cons;
320 for (; gIter != NULL; gIter = gIter->next) {
321 rsc_colocation_t *constraint = (rsc_colocation_t *) gIter->data;
322
323 /* (re-)adds location preferences of resources that the
324 * master instance should/must be colocated with
325 */
326 if (constraint->role_lh == RSC_ROLE_MASTER) {
327 enum pe_weights flags = constraint->score == INFINITY ? 0 : pe_weights_rollback;
328
329 pe_rsc_trace(rsc, "RHS: %s with %s: %d", constraint->rsc_lh->id, constraint->rsc_rh->id,
330 constraint->score);
331 rsc->allowed_nodes =

Callers 1

master_colorFunction · 0.85

Calls 5

pe_hash_table_lookupFunction · 0.85
score2charFunction · 0.85
merge_weightsFunction · 0.85
resource_locationFunction · 0.85
is_not_setFunction · 0.85

Tested by

no test coverage detected