14 #include <qb/qbdefs.h> 52 pcmk__rsc_debug(rsc,
"Assignment dependency loop detected involving %s",
71 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
77 node = member->
cmds->
assign(member, prefer, stop_if_fail);
78 if (first_assigned_node == NULL) {
79 first_assigned_node = node;
89 return first_assigned_node;
125 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
163 member_internal_constraints(gpointer
data, gpointer user_data)
166 struct member_data *member_data = (
struct member_data *) user_data;
177 if (member_data->previous_member == NULL) {
179 if (member_data->ordered) {
184 }
else if (member_data->colocated) {
193 member, member_data->previous_member, NULL, NULL,
197 if (member_data->promotable) {
231 if (!member_data->ordered) {
236 if (member_data->promotable) {
244 }
else if (member_data->previous_member == NULL) {
246 if (member_data->promotable) {
268 && (member_data->previous_member->running_on == NULL)) {
270 member_data->previous_member,
276 if (member_data->promotable) {
283 member_data->previous_member,
290 if (member_data->ordered && (member_data->previous_member != NULL)
291 && (member_data->previous_member->running_on == NULL)
292 && (member_data->last_active != NULL)
293 && (member_data->last_active->running_on != NULL)) {
297 member_data->last_active = member;
300 member_data->previous_member = member;
312 struct member_data member_data = {
false, };
335 g_list_foreach(rsc->
children, member_internal_constraints, &member_data);
356 int priority_delta = 0;
362 pcmk__rsc_trace(primary,
"Processing %s (group %s with %s) for dependent",
363 colocation->
id, dependent->
id, primary->
id);
375 "non-colocated group and %s",
376 dependent->
id, primary->
id);
381 for (GList *iter = dependent->
children; iter != NULL;
400 if (priority_delta != 0) {
405 "Applied %s to %s promotion priority " 406 "(now %s after %s %d)",
407 colocation->
id, dependent->
id,
409 ((priority_delta > 0)?
"adding" :
"subtracting"),
410 QB_ABS(priority_delta));
412 return priority_delta;
433 int priority_delta = 0;
437 "Processing colocation %s (%s with group %s) for primary",
438 colocation->
id, dependent->
id, primary->
id);
452 }
else if (primary->
children != NULL) {
459 if (member == NULL) {
469 " non-colocated group %s",
470 dependent->
id, primary->
id);
475 for (
const GList *iter = primary->
children; iter != NULL;
478 int instance_delta = 0;
485 return priority_delta;
509 CRM_ASSERT((dependent != NULL) && (primary != NULL)
510 && (colocation != NULL));
513 return colocate_group_with(dependent, primary, colocation);
519 return colocate_with_group(dependent, primary, colocation);
543 for (GList *iter =
action->rsc->children; iter != NULL; iter = iter->next) {
552 if (member_action != NULL) {
583 "%s is not runnable because %s will not %s",
618 uint32_t filter, uint32_t
type,
624 CRM_ASSERT((first != NULL) && (then != NULL) && (then->
rsc != NULL)
632 for (GList *iter = then->
rsc->
children; iter != NULL; iter = iter->next) {
638 if (member_action != NULL) {
658 GList *node_list_orig = NULL;
659 GList *node_list_copy = NULL;
661 CRM_ASSERT(pcmk__is_group(rsc) && (location != NULL));
664 node_list_orig = location->
nodes;
676 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
693 location->
nodes = node_list_copy;
699 location->
nodes = node_list_orig;
700 g_list_free_full(node_list_copy, free);
707 GList *colocated_rscs)
713 if (orig_rsc == NULL) {
718 || pcmk__is_clone(rsc->
parent)) {
723 colocated_rscs = g_list_prepend(colocated_rscs, (gpointer) rsc);
724 for (
const GList *iter = rsc->children;
725 iter != NULL; iter = iter->next) {
740 return colocated_rscs;
749 CRM_ASSERT((orig_rsc != NULL) && (list != NULL) && pcmk__is_group(rsc));
765 rsc->
id, orig_rsc->
id);
771 if (rsc->
parent != NULL) {
782 for (
const GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
785 if (member != orig_rsc) {
798 CRM_ASSERT((orig_rsc != NULL) && (list != NULL) && pcmk__is_group(rsc));
808 if ((rsc == orig_rsc)
811 rsc->
id, orig_rsc->
id);
817 if (rsc->
parent != NULL) {
828 for (
const GList *iter = rsc->
children;
829 iter != NULL; iter = iter->next) {
831 if (member != orig_rsc) {
843 for (
const GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
845 if (orig_rsc == member) {
850 crm_trace(
"Adding mandatory '%s with' colocations to list for " 851 "member %s because earlier member %s is unmanaged",
852 rsc->
id, orig_rsc->
id, member->
id);
853 for (
const GList *cons_iter = rsc->
rsc_cons; cons_iter != NULL;
854 cons_iter = cons_iter->next) {
901 const char *log_id, GHashTable **nodes,
903 float factor, uint32_t
flags)
907 CRM_ASSERT(pcmk__is_group(source_rsc) && (nodes != NULL)
908 && ((colocation != NULL)
909 || ((target_rsc == NULL) && (*nodes == NULL))));
911 if (log_id == NULL) {
912 log_id = source_rsc->
id;
918 log_id, source_rsc->
id);
938 if (*nodes == NULL) {
941 member = source_rsc->
children->data;
943 pcmk__rsc_trace(source_rsc,
"%s: Merging scores from group %s using member %s " 944 "(at %.6f)", log_id, source_rsc->
id, member->
id, factor);
946 colocation, factor,
flags);
954 GHashTable *utilization)
958 CRM_ASSERT((orig_rsc != NULL) && (utilization != NULL)
959 && pcmk__is_group(rsc));
965 pcmk__rsc_trace(orig_rsc,
"%s: Adding group %s as colocated utilization",
966 orig_rsc->
id, rsc->
id);
968 || pcmk__is_clone(rsc->
parent)) {
970 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
974 && (g_list_find(all_rscs, member) == NULL)) {
985 && (g_list_find(all_rscs, member) == NULL)) {
998 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
pcmk_assignment_methods_t * cmds
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
void pcmk__group_create_actions(pcmk_resource_t *rsc)
pcmk_node_t * pcmk__group_assign(pcmk_resource_t *rsc, const pcmk_node_t *prefer, bool stop_if_fail)
G_GNUC_INTERNAL GList * pcmk__colocated_resources(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *colocated_rscs)
#define pcmk__order_starts(rsc1, rsc2, flags)
void pcmk__group_add_colocated_node_scores(pcmk_resource_t *source_rsc, const pcmk_resource_t *target_rsc, const char *log_id, GHashTable **nodes, const pcmk__colocation_t *colocation, float factor, uint32_t flags)
'then' is runnable (and migratable) only if 'first' is runnable
G_GNUC_INTERNAL void pcmk__apply_location(pcmk_resource_t *rsc, pcmk__location_t *constraint)
pcmk_scheduler_t * cluster
#define PCMK_META_PROMOTABLE
void(* create_actions)(pcmk_resource_t *rsc)
int pcmk__group_apply_coloc_score(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
uint32_t(* action_flags)(pcmk_action_t *action, const pcmk_node_t *node)
#define pcmk__rsc_trace(rsc, fmt, args...)
#define pcmk__order_stops(rsc1, rsc2, flags)
#define pcmk__rsc_info(rsc, fmt, args...)
enum rsc_role_e next_role
#define pcmk__config_err(fmt...)
void(* add_colocated_node_scores)(pcmk_resource_t *source_rsc, const pcmk_resource_t *target_rsc, const char *log_id, GHashTable **nodes, const pcmk__colocation_t *colocation, float factor, uint32_t flags)
pcmk_node_t *(* assign)(pcmk_resource_t *rsc, const pcmk_node_t *prefer, bool stop_if_fail)
G_GNUC_INTERNAL uint32_t pcmk__update_ordered_actions(pcmk_action_t *first, pcmk_action_t *then, const pcmk_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pcmk_scheduler_t *scheduler)
enum crm_ais_msg_types type
#define pcmk__set_relation_flags(ar_flags, flags_to_set)
uint32_t pcmk__group_update_ordered_actions(pcmk_action_t *first, pcmk_action_t *then, const pcmk_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pcmk_scheduler_t *scheduler)
#define pcmk__rsc_debug(rsc, fmt, args...)
void(* with_this_colocations)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define PCMK_ACTION_DEMOTE
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
G_GNUC_INTERNAL void pcmk__add_with_this_list(GList **list, GList *addition, const pcmk_resource_t *rsc)
uint32_t pcmk__group_action_flags(pcmk_action_t *action, const pcmk_node_t *node)
Actions are ordered (optionally, if no other flags are set)
#define pcmk__clear_action_flags(action, flags_to_clear)
pcmk_resource_t * pe__last_group_member(const pcmk_resource_t *group)
G_GNUC_INTERNAL void pcmk__add_this_with(GList **list, const pcmk__colocation_t *colocation, const pcmk_resource_t *rsc)
void(* this_with_colocations)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK_ACTION_START
void(* shutdown_lock)(pcmk_resource_t *rsc)
Wrappers for and extensions to libxml2.
GList * pcmk__group_colocated_resources(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *colocated_rscs)
void(* apply_location)(pcmk_resource_t *rsc, pcmk__location_t *location)
GList *(* colocated_resources)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *colocated_rscs)
#define pcmk__set_rsc_flags(resource, flags_to_set)
void pcmk__group_with_colocations(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
int pcmk__add_scores(int score1, int score2)
const char * pcmk_action_text(enum action_tasks action)
Get string equivalent of an action type.
#define pcmk__order_resource_actions(first_rsc, first_task, then_rsc, then_task, flags)
pcmk_action_t * custom_action(pcmk_resource_t *rsc, char *key, const char *task, const pcmk_node_t *on_node, gboolean optional, pcmk_scheduler_t *scheduler)
Create or update an action object.
void pcmk__group_apply_location(pcmk_resource_t *rsc, pcmk__location_t *location)
If 'then' is required, 'first' must be added to the transition graph.
void(* internal_constraints)(pcmk_resource_t *rsc)
GList * pcmk__copy_node_list(const GList *list, bool reset)
pcmk_action_t * find_first_action(const GList *input, const char *uuid, const char *task, const pcmk_node_t *on_node)
pcmk_scheduler_t * scheduler
G_GNUC_INTERNAL void pcmk__add_this_with_list(GList **list, GList *addition, const pcmk_resource_t *rsc)
If 'first' is required and runnable, 'then' must be in graph.
#define PCMK_ACTION_STOPPED
void pcmk__group_add_utilization(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
pcmk_node_t * allocated_to
void pcmk__group_shutdown_lock(pcmk_resource_t *rsc)
#define PCMK_ACTION_PROMOTE
void pcmk__with_group_colocations(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList **list)
#define pe__show_node_scores(level, rsc, text, nodes, scheduler)
uint32_t(* update_ordered_actions)(pcmk_action_t *first, pcmk_action_t *then, const pcmk_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pcmk_scheduler_t *scheduler)
#define pcmk__set_action_flags(action, flags_to_set)
#define PCMK_ACTION_PROMOTED
gboolean crm_is_true(const char *s)
G_GNUC_INTERNAL void pcmk__new_colocation(const char *id, const char *node_attr, int score, pcmk_resource_t *dependent, pcmk_resource_t *primary, const char *dependent_role, const char *primary_role, uint32_t flags)
Location constraint object.
#define PCMK_ACTION_RUNNING
#define pcmk__clear_raw_action_flags(action_flags, action_name, to_clear)
bool pe__group_flag_is_set(const pcmk_resource_t *group, uint32_t flags)
#define PCMK_ACTION_DEMOTED
enum action_tasks get_complex_task(const pcmk_resource_t *rsc, const char *name)
void(* add_utilization)(const pcmk_resource_t *rsc, const pcmk_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
int(* apply_coloc_score)(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
void pcmk__group_internal_constraints(pcmk_resource_t *rsc)
No relation (compare with equality rather than bit set)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes