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

Function color_instance

pengine/clone.c:390–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390static node_t *
391color_instance(resource_t * rsc, node_t * prefer, gboolean all_coloc, pe_working_set_t * data_set)
392{
393 node_t *chosen = NULL;
394 node_t *local_node = NULL;
395
396 pe_rsc_trace(rsc, "Processing %s", rsc->id);
397
398 if (is_not_set(rsc->flags, pe_rsc_provisional)) {
399 return rsc->fns->location(rsc, NULL, FALSE);
400
401 } else if (is_set(rsc->flags, pe_rsc_allocating)) {
402 pe_rsc_debug(rsc, "Dependency loop detected involving %s", rsc->id);
403 return NULL;
404 }
405
406 /* Only include positive colocation preferences of dependant resources
407 * if not every node will get a copy of the clone
408 */
409 append_parent_colocation(rsc->parent, rsc, all_coloc);
410
411 if (prefer) {
412 node_t *local_prefer = g_hash_table_lookup(rsc->allowed_nodes, prefer->details->id);
413
414 if (local_prefer == NULL || local_prefer->weight < 0) {
415 pe_rsc_trace(rsc, "Not pre-allocating %s to %s - unavailable", rsc->id, prefer->details->uname);
416 return NULL;
417 }
418 }
419
420 if (rsc->allowed_nodes) {
421 GHashTableIter iter;
422 node_t *try_node = NULL;
423
424 g_hash_table_iter_init(&iter, rsc->allowed_nodes);
425 while (g_hash_table_iter_next(&iter, NULL, (void **)&try_node)) {
426 can_run_instance(rsc, try_node);
427 }
428 }
429
430 chosen = rsc->cmds->allocate(rsc, prefer, data_set);
431 if (chosen) {
432 local_node = pe_hash_table_lookup(rsc->parent->allowed_nodes, chosen->details->id);
433
434 if (prefer && chosen && chosen->details != prefer->details) {
435 crm_err("Pre-allocation failed: got %s instead of %s",
436 chosen->details->uname, prefer->details->uname);
437 native_deallocate(rsc);
438 chosen = NULL;
439
440 } else if (local_node) {
441 local_node->count++;
442
443 } else if (is_set(rsc->flags, pe_rsc_managed)) {
444 /* what to do? we can't enforce per-node limits in this case */
445 crm_config_err("%s not found in %s (list=%d)",
446 chosen->details->id, rsc->parent->id,
447 g_hash_table_size(rsc->parent->allowed_nodes));

Callers 1

clone_colorFunction · 0.85

Calls 8

is_not_setFunction · 0.85
is_setFunction · 0.85
append_parent_colocationFunction · 0.85
g_hash_table_iter_initFunction · 0.85
g_hash_table_iter_nextFunction · 0.85
can_run_instanceFunction · 0.85
pe_hash_table_lookupFunction · 0.85
native_deallocateFunction · 0.85

Tested by

no test coverage detected