19 #define PE__VARIANT_BUNDLE 1 23 is_bundle_node(pe__bundle_variant_data_t *
data,
pe_node_t *node)
25 for (GList *gIter =
data->replicas; gIter != NULL; gIter = gIter->next) {
26 pe__bundle_replica_t *replica = gIter->data;
28 if (node->
details == replica->node->details) {
42 GList *containers = NULL;
45 pe__bundle_variant_data_t *
data = NULL;
47 get_bundle_variant_data(
data, rsc);
48 for (GList *gIter =
data->replicas; gIter != NULL;
49 gIter = gIter->next) {
50 pe__bundle_replica_t *replica = gIter->data;
52 containers = g_list_append(containers, replica->container);
62 get_container_list(rsc) : rsc->children;
69 GList *containers = NULL;
71 pe__bundle_variant_data_t *bundle_data = NULL;
75 get_bundle_variant_data(bundle_data, rsc);
78 containers = get_container_list(rsc);
87 bundle_data->nreplicas_per_host,
data_set);
89 g_list_free(containers);
91 for (GList *gIter = bundle_data->replicas; gIter != NULL;
92 gIter = gIter->next) {
93 pe__bundle_replica_t *replica = gIter->data;
99 rsc->
id, replica->ip->id);
100 replica->ip->cmds->allocate(replica->ip, prefer,
data_set);
103 container_host = replica->container->allocated_to;
115 if (replica->remote) {
117 rsc->
id, replica->remote->id);
118 replica->remote->cmds->allocate(replica->remote, prefer,
123 if (replica->child) {
127 g_hash_table_iter_init(&iter, replica->child->allowed_nodes);
128 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
129 if (node->details != replica->node->details) {
138 pe_rsc_trace(rsc,
"Allocating bundle %s replica child %s",
139 rsc->
id, replica->child->id);
140 replica->child->cmds->allocate(replica->child, replica->node,
147 if (bundle_data->child) {
150 g_hash_table_iter_init(&iter, bundle_data->child->allowed_nodes);
151 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
152 if (is_bundle_node(bundle_data, node)) {
159 rsc->
id, bundle_data->child->id);
160 bundle_data->child->cmds->allocate(bundle_data->child, prefer,
data_set);
172 GList *containers = NULL;
173 pe__bundle_variant_data_t *bundle_data = NULL;
177 containers = get_container_list(rsc);
178 get_bundle_variant_data(bundle_data, rsc);
179 for (GList *gIter = bundle_data->replicas; gIter != NULL;
180 gIter = gIter->next) {
181 pe__bundle_replica_t *replica = gIter->data;
185 replica->ip->cmds->create_actions(replica->ip,
data_set);
187 if (replica->container) {
188 replica->container->cmds->create_actions(replica->container,
191 if (replica->remote) {
192 replica->remote->cmds->create_actions(replica->remote,
data_set);
198 if (bundle_data->child) {
199 bundle_data->child->cmds->create_actions(bundle_data->child,
data_set);
214 g_list_free(containers);
221 pe__bundle_variant_data_t *bundle_data = NULL;
225 get_bundle_variant_data(bundle_data, rsc);
227 if (bundle_data->child) {
235 if (bundle_data->child->children) {
256 for (GList *gIter = bundle_data->replicas; gIter != NULL;
257 gIter = gIter->next) {
258 pe__bundle_replica_t *replica = gIter->data;
263 replica->container->cmds->internal_constraints(replica->container,
270 if (replica->child) {
284 replica->ip->cmds->internal_constraints(replica->ip,
data_set);
295 replica->container, NULL, NULL,
true,
299 if (replica->remote) {
305 replica->remote->cmds->internal_constraints(replica->remote,
309 if (replica->child) {
317 if (bundle_data->child) {
318 bundle_data->child->cmds->internal_constraints(bundle_data->child,
data_set);
354 pe__bundle_variant_data_t *bundle_data = NULL;
356 CRM_CHECK(candidate != NULL,
return NULL);
357 get_bundle_variant_data(bundle_data, rsc);
359 crm_trace(
"Looking for compatible child from %s for %s on %s",
362 for (GList *gIter = bundle_data->replicas; gIter != NULL;
363 gIter = gIter->next) {
364 pe__bundle_replica_t *replica = gIter->data;
368 rsc_lh->
id, replica->container->id,
370 return replica->container;
383 GList *scratch = NULL;
387 active_node_lh = rsc_lh->
fns->
location(rsc_lh, NULL, current);
388 if (active_node_lh) {
389 return compatible_replica_for_node(rsc_lh, active_node_lh, rsc, filter,
396 for (GList *gIter = scratch; gIter != NULL; gIter = gIter->next) {
399 pair = compatible_replica_for_node(rsc_lh, node, rsc, filter, current);
405 pe_rsc_debug(rsc,
"Can't pair %s with %s", rsc_lh->
id, (rsc? rsc->
id :
"none"));
407 g_list_free(scratch);
444 if (max_clones_node == NULL) {
456 pe__bundle_variant_data_t *
data = NULL;
457 get_bundle_variant_data(
data, rsc);
458 return data->nreplicas_per_host;
469 GList *allocated_primaries = NULL;
470 pe__bundle_variant_data_t *bundle_data = NULL;
474 pe_err(
"dependent was NULL for %s", constraint->
id);
return);
476 pe_err(
"primary was NULL for %s", constraint->
id);
return);
484 pe_resource_t *primary_replica = compatible_replica(dependent, primary,
488 if (primary_replica) {
490 dependent->
id, primary_replica->
id);
495 crm_notice(
"Cannot pair %s with instance of %s",
496 dependent->
id, primary->
id);
500 pe_rsc_debug(primary,
"Cannot pair %s with instance of %s",
501 dependent->
id, primary->
id);
507 get_bundle_variant_data(bundle_data, primary);
508 pe_rsc_trace(primary,
"Processing constraint %s: %s -> %s %d",
509 constraint->
id, dependent->
id, primary->
id, constraint->
score);
511 for (GList *gIter = bundle_data->replicas; gIter != NULL;
512 gIter = gIter->next) {
513 pe__bundle_replica_t *replica = gIter->data;
516 replica->container->cmds->rsc_colocation_rh(dependent,
521 pe_node_t *chosen = replica->container->fns->location(replica->container,
529 && (replica->child == NULL)) {
540 allocated_primaries = g_list_prepend(allocated_primaries, chosen);
547 g_list_free(allocated_primaries);
553 GList *containers = NULL;
555 pe__bundle_variant_data_t *
data = NULL;
574 containers = get_container_list(
action->rsc);
576 g_list_free(containers);
585 GList *children = NULL;
587 if (local_node == NULL) {
588 crm_err(
"Can't colocate unrunnable child %s with %s", local_child->
id, rsc->
id);
592 crm_trace(
"Looking for compatible child from %s for %s on %s",
595 children = get_containers_or_children(rsc);
596 for (gIter = children; gIter != NULL; gIter = gIter->next) {
606 crm_trace(
"Can't pair %s with %s", local_child->
id, rsc->
id);
608 g_list_free(children);
613 static pe__bundle_replica_t *
618 pe__bundle_variant_data_t *
data = NULL;
620 get_bundle_variant_data(
data, rsc);
621 for (GList *gIter =
data->replicas; gIter != NULL;
622 gIter = gIter->next) {
623 pe__bundle_replica_t *replica = gIter->data;
626 && (container == replica->container)
627 && (node->
details == replica->node->details)) {
643 GList *children = NULL;
644 gboolean current = FALSE;
653 children = get_containers_or_children(then->
rsc);
654 for (gIter = children; gIter != NULL; gIter = gIter->next) {
660 if (first_child == NULL && current) {
663 }
else if (first_child == NULL) {
664 crm_debug(
"No match found for %s (%d / %s / %s)", then_child->
id, current, first->
uuid, then->
uuid);
684 const char *first_task =
task2text(task);
686 pe__bundle_replica_t *first_replica = NULL;
687 pe__bundle_replica_t *then_replica = NULL;
689 first_replica = replica_for_container(first->
rsc, first_child,
691 if (strstr(first->
task,
"stop") && first_replica && first_replica->child) {
703 then_replica = replica_for_container(then->
rsc, then_child, node);
704 if (strstr(then->
task,
"mote")
705 && then_replica && then_replica->child) {
714 NULL, then->
task, node);
719 if (first_action == NULL) {
722 crm_err(
"Internal error: No action found for %s in %s (first)",
723 first_task, first_child->
id);
726 crm_trace(
"No action found for %s in %s%s (first)",
727 first_task, first_child->
id,
734 if (then_action == NULL) {
737 crm_err(
"Internal error: No action found for %s in %s (then)",
738 then->
task, then_child->
id);
741 crm_trace(
"No action found for %s in %s%s (then)",
742 then->
task, then_child->
id,
749 crm_debug(
"Created constraint for %s (%d) -> %s (%d) %.6x",
758 if(first_action && then_action) {
764 crm_err(
"Nothing found either for %s (%p) or %s (%p) %s",
765 first_child->
id, first_action,
772 g_list_free(children);
780 bool interleave = FALSE;
782 const char *interleave_s = NULL;
784 if(first->
rsc == NULL || then->
rsc == NULL) {
785 crm_trace(
"Not interleaving %s with %s (both must be resources)", first->
uuid, then->
uuid);
787 }
else if(first->
rsc == then->
rsc) {
788 crm_trace(
"Not interleaving %s with %s (must belong to different resources)", first->
uuid, then->
uuid);
791 crm_trace(
"Not interleaving %s with %s (both sides must be clones or bundles)", first->
uuid, then->
uuid);
804 crm_trace(
"Interleave %s -> %s: %s (based on %s)",
805 first->
uuid, then->
uuid, interleave ?
"yes" :
"no", rsc->
id);
820 if(can_interleave_actions(first, then)) {
821 changed = multi_update_interleave_actions(first, then, node,
flags,
824 }
else if(then->
rsc) {
826 GList *children = NULL;
833 children = get_containers_or_children(then->
rsc);
834 for (gIter = children; gIter != NULL; gIter = gIter->next) {
839 if (then_child_action) {
846 changed |= then_child_changed;
848 for (GList *lpc = then_child_action->actions_after; lpc != NULL; lpc = lpc->next) {
859 g_list_free(children);
868 pe__bundle_variant_data_t *bundle_data = NULL;
869 get_bundle_variant_data(bundle_data, rsc);
873 for (GList *gIter = bundle_data->replicas; gIter != NULL;
874 gIter = gIter->next) {
875 pe__bundle_replica_t *replica = gIter->data;
877 if (replica->container) {
878 replica->container->cmds->rsc_location(replica->container,
882 replica->ip->cmds->rsc_location(replica->ip, constraint);
886 if (bundle_data->child
889 bundle_data->child->cmds->rsc_location(bundle_data->child, constraint);
890 bundle_data->child->rsc_location = g_list_prepend(bundle_data->child->rsc_location,
898 pe__bundle_variant_data_t *bundle_data = NULL;
902 get_bundle_variant_data(bundle_data, rsc);
904 if (bundle_data->child) {
905 bundle_data->child->cmds->expand(bundle_data->child,
data_set);
908 for (GList *gIter = bundle_data->replicas; gIter != NULL;
909 gIter = gIter->next) {
910 pe__bundle_replica_t *replica = gIter->data;
913 if (replica->remote && replica->container
923 replica->remote->xml, LOG_ERR);
924 const char *calculated_addr = NULL;
930 if (calculated_addr) {
940 crm_trace(
"Set address for bundle connection %s to bundle host %s",
941 replica->remote->id, calculated_addr);
942 g_hash_table_replace(params,
944 strdup(calculated_addr));
953 crm_info(
"Unable to determine address for bundle %s remote connection",
958 replica->ip->cmds->expand(replica->ip,
data_set);
960 if (replica->container) {
961 replica->container->cmds->expand(replica->container,
data_set);
963 if (replica->remote) {
964 replica->remote->cmds->expand(replica->remote,
data_set);
974 bool any_created = FALSE;
975 pe__bundle_variant_data_t *bundle_data = NULL;
979 get_bundle_variant_data(bundle_data, rsc);
980 for (GList *gIter = bundle_data->replicas; gIter != NULL;
981 gIter = gIter->next) {
982 pe__bundle_replica_t *replica = gIter->data;
986 any_created |= replica->ip->cmds->create_probe(replica->ip, node,
990 if (replica->child && (node->
details == replica->node->details)) {
991 any_created |= replica->child->cmds->create_probe(replica->child,
995 if (replica->container) {
996 bool created = replica->container->cmds->create_probe(replica->container,
1015 for (GList *tIter = bundle_data->replicas;
1016 tIter && (bundle_data->nreplicas_per_host == 1);
1017 tIter = tIter->next) {
1018 pe__bundle_replica_t *other = tIter->data;
1020 if ((other != replica) && (other != NULL)
1021 && (other->container != NULL)) {
1025 NULL, other->container,
1034 if (replica->container && replica->remote
1035 && replica->remote->cmds->create_probe(replica->remote, node,
1046 probe_uuid, NULL, node);
1055 NULL, replica->remote, NULL, probe,
1071 pe__bundle_variant_data_t *bundle_data = NULL;
1075 get_bundle_variant_data(bundle_data, rsc);
1076 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1077 gIter = gIter->next) {
1078 pe__bundle_replica_t *replica = gIter->data;
1081 if (replica->ip != NULL) {
1082 replica->ip->cmds->output_actions(replica->ip);
1084 if (replica->container != NULL) {
1085 replica->container->cmds->output_actions(replica->container);
1087 if (replica->remote != NULL) {
1088 replica->remote->cmds->output_actions(replica->remote);
1090 if (replica->child != NULL) {
1091 replica->child->cmds->output_actions(replica->child);
1099 GList *all_rscs, GHashTable *utilization)
1101 pe__bundle_variant_data_t *bundle_data = NULL;
1102 pe__bundle_replica_t *replica = NULL;
1108 get_bundle_variant_data(bundle_data, rsc);
1109 if (bundle_data->replicas == NULL) {
1117 replica = (pe__bundle_replica_t *) bundle_data->replicas->data;
1118 if (replica->container != NULL) {
1119 replica->container->cmds->add_utilization(replica->container, orig_rsc,
1120 all_rscs, utilization);
#define CRM_CHECK(expr, failure_action)
pe_node_t * pcmk__bundle_allocate(pe_resource_t *rsc, pe_node_t *prefer, pe_working_set_t *data_set)
enum rsc_role_e role_filter
const char * task2text(enum action_tasks task)
void pcmk__output_bundle_actions(pe_resource_t *rsc)
void pcmk__bundle_add_utilization(pe_resource_t *rsc, pe_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
bool is_set_recursive(pe_resource_t *rsc, long long flag, bool any)
#define crm_notice(fmt, args...)
bool pe__is_guest_or_remote_node(const pe_node_t *node)
#define pe_rsc_debug(rsc, fmt, args...)
#define pe__show_node_weights(level, rsc, text, nodes, data_set)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
#define pcmk__order_starts(rsc1, rsc2, type, data_set)
pe_resource_t * container
resource_alloc_functions_t * cmds
G_GNUC_INTERNAL void pcmk__new_ordering(pe_resource_t *lh_rsc, char *lh_task, pe_action_t *lh_action, pe_resource_t *rh_rsc, char *rh_task, pe_action_t *rh_action, enum pe_ordering type, pe_working_set_t *data_set)
enum pe_graph_flags(* update_actions)(pe_action_t *, pe_action_t *, pe_node_t *, enum pe_action_flags, enum pe_action_flags, enum pe_ordering, pe_working_set_t *data_set)
G_GNUC_INTERNAL bool pcmk__threshold_reached(pe_resource_t *rsc, pe_node_t *node, pe_resource_t **failed)
gint sort_clone_instance(gconstpointer a, gconstpointer b, gpointer data_set)
void pcmk__bundle_create_actions(pe_resource_t *rsc, pe_working_set_t *data_set)
pe_resource_t * remote_rsc
resource_object_functions_t * fns
enum pe_action_flags summary_action_flags(pe_action_t *action, GList *children, pe_node_t *node)
bool pe__bundle_needs_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set)
pe_resource_t * dependent
enum pe_graph_flags pcmk__multi_update_actions(pe_action_t *first, pe_action_t *then, pe_node_t *node, enum pe_action_flags flags, enum pe_action_flags filter, enum pe_ordering type, pe_working_set_t *data_set)
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
#define pcmk__order_stops(rsc1, rsc2, type, data_set)
enum pe_graph_flags native_update_actions(pe_action_t *first, pe_action_t *then, pe_node_t *node, enum pe_action_flags flags, enum pe_action_flags filter, enum pe_ordering type, pe_working_set_t *data_set)
enum crm_ais_msg_types type
gboolean pcmk__bundle_create_probe(pe_resource_t *rsc, pe_node_t *node, pe_action_t *complete, gboolean force, pe_working_set_t *data_set)
enum pe_action_flags pcmk__bundle_action_flags(pe_action_t *action, pe_node_t *node)
bool pcmk__ends_with(const char *s, const char *match)
gboolean is_child_compatible(pe_resource_t *child_rsc, pe_node_t *local_node, enum rsc_role_e filter, gboolean current)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
#define XML_RSC_ATTR_REMOTE_RA_ADDR
G_GNUC_INTERNAL void pcmk__new_colocation(const char *id, const char *node_attr, int score, pe_resource_t *dependent, pe_resource_t *primary, const char *dependent_role, const char *primary_role, bool influence, pe_working_set_t *data_set)
#define pe__set_resource_flags(resource, flags_to_set)
void distribute_children(pe_resource_t *rsc, GList *children, GList *nodes, int max, int per_host_max, pe_working_set_t *data_set)
#define pe_rsc_provisional
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define crm_debug(fmt, args...)
G_GNUC_INTERNAL GList * pcmk__sort_nodes(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
void pcmk__bundle_rsc_colocation_lh(pe_resource_t *dependent, pe_resource_t *primary, pcmk__colocation_t *constraint, pe_working_set_t *data_set)
pe_resource_t * find_compatible_child_by_node(pe_resource_t *local_child, pe_node_t *local_node, pe_resource_t *rsc, enum rsc_role_e filter, gboolean current)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, pcmk__colocation_t *, pe_working_set_t *)
#define crm_trace(fmt, args...)
enum action_tasks get_complex_task(pe_resource_t *rsc, const char *name, gboolean allow_non_atomic)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
void promote_demote_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
struct pe_node_shared_s * details
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
#define pe_rsc_promotable
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
pe_working_set_t * data_set
#define pcmk__order_resource_actions(lh_rsc, lh_task, rh_rsc, rh_task, flags, data_set)
enum action_tasks clone_child_action(pe_action_t *action)
#define pe__set_graph_flags(graph_flags, gr_action, flags_to_set)
void pcmk__bundle_rsc_location(pe_resource_t *rsc, pe__location_t *constraint)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
enum pe_action_flags(* action_flags)(pe_action_t *, pe_node_t *)
#define pe_rsc_allocating
enum pe_obj_types variant
void pcmk__bundle_shutdown_lock(pe_resource_t *rsc)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set, xmlNode *xml, const char *field)
void clone_create_pseudo_actions(pe_resource_t *rsc, GList *children, notify_data_t **start_notify, notify_data_t **stop_notify, pe_working_set_t *data_set)
pe_resource_t * find_compatible_child(pe_resource_t *local_child, pe_resource_t *rsc, enum rsc_role_e filter, gboolean current, pe_working_set_t *data_set)
G_GNUC_INTERNAL pe_action_t * pcmk__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task, bool optional, bool runnable)
void pcmk__bundle_expand(pe_resource_t *rsc, pe_working_set_t *data_set)
G_GNUC_INTERNAL void pcmk__update_action_for_orderings(pe_action_t *action, pe_working_set_t *data_set)
int copies_per_node(pe_resource_t *rsc)
#define crm_err(fmt, args...)
G_GNUC_INTERNAL bool pcmk__assign_resource(pe_resource_t *rsc, pe_node_t *node, bool force)
void pcmk__bundle_append_meta(pe_resource_t *rsc, xmlNode *xml)
#define pe__clear_resource_flags(resource, flags_to_clear)
rsc_role_e
Possible roles that a resource can be in.
enum pe_action_flags flags
void pcmk__bundle_internal_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
gboolean crm_is_true(const char *s)
#define pe_rsc_trace(rsc, fmt, args...)
#define XML_RSC_ATTR_INTERLEAVE
void pcmk__bundle_rsc_colocation_rh(pe_resource_t *dependent, pe_resource_t *primary, pcmk__colocation_t *constraint, pe_working_set_t *data_set)
#define pe_flag_show_scores
#define crm_info(fmt, args...)
pe_action_t * find_first_action(GList *input, const char *uuid, const char *task, pe_node_t *on_node)
G_GNUC_INTERNAL void pcmk__apply_location(pe__location_t *constraint, pe_resource_t *rsc)
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes