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

Function native_assign_node

pengine/utils.c:331–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331gboolean
332native_assign_node(resource_t * rsc, GListPtr nodes, node_t * chosen, gboolean force)
333{
334 CRM_ASSERT(rsc->variant == pe_native);
335
336 if (force == FALSE
337 && chosen != NULL && (can_run_resources(chosen) == FALSE || chosen->weight < 0)) {
338 crm_debug("All nodes for resource %s are unavailable"
339 ", unclean or shutting down (%s: %d, %d)",
340 rsc->id, chosen->details->uname, can_run_resources(chosen), chosen->weight);
341 rsc->next_role = RSC_ROLE_STOPPED;
342 chosen = NULL;
343 }
344
345 /* todo: update the old node for each resource to reflect its
346 * new resource count
347 */
348
349 native_deallocate(rsc);
350 clear_bit(rsc->flags, pe_rsc_provisional);
351
352 if (chosen == NULL) {
353 char *key = NULL;
354 GListPtr gIter = NULL;
355 GListPtr possible_matches = NULL;
356
357 crm_debug("Could not allocate a node for %s", rsc->id);
358 rsc->next_role = RSC_ROLE_STOPPED;
359
360 key = generate_op_key(rsc->id, RSC_STOP, 0);
361 possible_matches = find_actions(rsc->actions, key, NULL);
362
363 for (gIter = possible_matches; gIter != NULL; gIter = gIter->next) {
364 action_t *stop = (action_t *) gIter->data;
365
366 update_action_flags(stop, pe_action_optional | pe_action_clear);
367 }
368
369 g_list_free(possible_matches);
370 free(key);
371
372 key = generate_op_key(rsc->id, RSC_START, 0);
373 possible_matches = find_actions(rsc->actions, key, NULL);
374
375 for (gIter = possible_matches; gIter != NULL; gIter = gIter->next) {
376 action_t *start = (action_t *) gIter->data;
377
378 update_action_flags(start, pe_action_runnable | pe_action_clear);
379 }
380
381 g_list_free(possible_matches);
382 free(key);
383
384 return FALSE;
385 }
386
387 crm_debug("Assigning %s to %s", chosen->details->uname, rsc->id);
388 rsc->allocated_to = node_copy(chosen);

Callers 3

assign_nodeFunction · 0.85
native_choose_nodeFunction · 0.85
native_colorFunction · 0.85

Calls 7

can_run_resourcesFunction · 0.85
native_deallocateFunction · 0.85
generate_op_keyFunction · 0.85
find_actionsFunction · 0.85
update_action_flagsFunction · 0.85
node_copyFunction · 0.85
calculate_utilizationFunction · 0.85

Tested by

no test coverage detected