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) {
41 GList *containers = NULL;
44 pe__bundle_variant_data_t *
data = NULL;
46 get_bundle_variant_data(
data, rsc);
47 for (GList *gIter =
data->replicas; gIter != NULL;
48 gIter = gIter->next) {
49 pe__bundle_replica_t *replica = gIter->data;
51 containers = g_list_append(containers, replica->container);
61 get_container_list(rsc) : rsc->children;
76 GList *containers = NULL;
78 pe__bundle_variant_data_t *bundle_data = NULL;
82 get_bundle_variant_data(bundle_data, rsc);
85 containers = get_container_list(rsc);
94 bundle_data->nreplicas_per_host, rsc->
cluster);
96 g_list_free(containers);
98 for (GList *gIter = bundle_data->replicas; gIter != NULL;
99 gIter = gIter->next) {
100 pe__bundle_replica_t *replica = gIter->data;
106 rsc->
id, replica->ip->id);
107 replica->ip->cmds->assign(replica->ip, prefer);
110 container_host = replica->container->allocated_to;
122 if (replica->remote) {
124 rsc->
id, replica->remote->id);
125 replica->remote->cmds->assign(replica->remote, prefer);
129 if (replica->child) {
133 g_hash_table_iter_init(&iter, replica->child->allowed_nodes);
134 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
135 if (node->details != replica->node->details) {
144 pe_rsc_trace(rsc,
"Allocating bundle %s replica child %s",
145 rsc->
id, replica->child->id);
146 replica->child->cmds->assign(replica->child, replica->node);
152 if (bundle_data->child) {
155 g_hash_table_iter_init(&iter, bundle_data->child->allowed_nodes);
156 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
157 if (is_bundle_node(bundle_data, node)) {
164 rsc->
id, bundle_data->child->id);
165 bundle_data->child->cmds->assign(bundle_data->child, prefer);
177 GList *containers = NULL;
178 pe__bundle_variant_data_t *bundle_data = NULL;
182 containers = get_container_list(rsc);
183 get_bundle_variant_data(bundle_data, rsc);
184 for (GList *gIter = bundle_data->replicas; gIter != NULL;
185 gIter = gIter->next) {
186 pe__bundle_replica_t *replica = gIter->data;
190 replica->ip->cmds->create_actions(replica->ip);
192 if (replica->container) {
193 replica->container->cmds->create_actions(replica->container);
195 if (replica->remote) {
196 replica->remote->cmds->create_actions(replica->remote);
202 if (bundle_data->child) {
203 bundle_data->child->cmds->create_actions(bundle_data->child);
218 g_list_free(containers);
224 pe__bundle_variant_data_t *bundle_data = NULL;
228 get_bundle_variant_data(bundle_data, rsc);
230 if (bundle_data->child) {
236 if (bundle_data->child->children) {
253 for (GList *gIter = bundle_data->replicas; gIter != NULL;
254 gIter = gIter->next) {
255 pe__bundle_replica_t *replica = gIter->data;
260 replica->container->cmds->internal_constraints(replica->container);
265 if (replica->child) {
279 replica->ip->cmds->internal_constraints(replica->ip);
288 replica->container, NULL, NULL,
true,
292 if (replica->remote) {
298 replica->remote->cmds->internal_constraints(replica->remote);
301 if (replica->child) {
309 if (bundle_data->child) {
310 bundle_data->child->cmds->internal_constraints(bundle_data->child);
343 pe__bundle_variant_data_t *bundle_data = NULL;
345 CRM_CHECK(candidate != NULL,
return NULL);
346 get_bundle_variant_data(bundle_data, rsc);
348 crm_trace(
"Looking for compatible child from %s for %s on %s",
349 rsc_lh->
id, rsc->
id, pe__node_name(candidate));
351 for (GList *gIter = bundle_data->replicas; gIter != NULL;
352 gIter = gIter->next) {
353 pe__bundle_replica_t *replica = gIter->data;
357 rsc_lh->
id, replica->container->id,
358 pe__node_name(candidate));
359 return replica->container;
372 GList *scratch = NULL;
376 active_node_lh = rsc_lh->
fns->
location(rsc_lh, NULL, current);
377 if (active_node_lh) {
378 return compatible_replica_for_node(rsc_lh, active_node_lh, rsc, filter,
385 for (GList *gIter = scratch; gIter != NULL; gIter = gIter->next) {
388 pair = compatible_replica_for_node(rsc_lh, node, rsc, filter, current);
394 pe_rsc_debug(rsc,
"Can't pair %s with %s", rsc_lh->
id, (rsc? rsc->
id :
"none"));
396 g_list_free(scratch);
421 if (max_clones_node == NULL) {
433 pe__bundle_variant_data_t *
data = NULL;
434 get_bundle_variant_data(
data, rsc);
435 return data->nreplicas_per_host;
460 GList *allocated_primaries = NULL;
461 pe__bundle_variant_data_t *bundle_data = NULL;
469 CRM_CHECK((colocation != NULL) && (dependent != NULL) && (primary != NULL),
478 pe_resource_t *primary_replica = compatible_replica(dependent, primary,
483 if (primary_replica) {
485 dependent->
id, primary_replica->
id);
490 crm_notice(
"Cannot pair %s with instance of %s",
491 dependent->
id, primary->
id);
495 pe_rsc_debug(primary,
"Cannot pair %s with instance of %s",
496 dependent->
id, primary->
id);
502 get_bundle_variant_data(bundle_data, primary);
503 pe_rsc_trace(primary,
"Processing constraint %s: %s -> %s %d",
504 colocation->
id, dependent->
id, primary->
id, colocation->
score);
506 for (GList *gIter = bundle_data->replicas; gIter != NULL;
507 gIter = gIter->next) {
508 pe__bundle_replica_t *replica = gIter->data;
511 replica->container->cmds->apply_coloc_score(dependent,
516 pe_node_t *chosen = replica->container->fns->location(replica->container,
524 && (replica->child == NULL)) {
533 colocation->
id, pe__node_name(chosen), chosen->
weight);
534 allocated_primaries = g_list_prepend(allocated_primaries, chosen);
541 g_list_free(allocated_primaries);
547 GList *containers = NULL;
549 pe__bundle_variant_data_t *
data = NULL;
568 containers = get_container_list(
action->rsc);
570 g_list_free(containers);
581 GList *children = NULL;
583 if (local_node == NULL) {
584 crm_err(
"Can't colocate unrunnable child %s with %s", local_child->
id, rsc->
id);
588 crm_trace(
"Looking for compatible child from %s for %s on %s",
589 local_child->
id, rsc->
id, pe__node_name(local_node));
591 children = get_containers_or_children(rsc);
592 for (gIter = children; gIter != NULL; gIter = gIter->next) {
597 local_child->
id, child_rsc->
id, pe__node_name(local_node));
602 crm_trace(
"Can't pair %s with %s", local_child->
id, rsc->
id);
604 g_list_free(children);
609 static pe__bundle_replica_t *
614 const pe__bundle_variant_data_t *
data = NULL;
616 get_bundle_variant_data(
data, rsc);
617 for (GList *gIter =
data->replicas; gIter != NULL;
618 gIter = gIter->next) {
619 pe__bundle_replica_t *replica = gIter->data;
622 && (container == replica->container)
623 && pe__same_node(node, replica->node)) {
637 GList *children = NULL;
638 gboolean current = FALSE;
647 children = get_containers_or_children(then->
rsc);
648 for (gIter = children; gIter != NULL; gIter = gIter->next) {
654 if (first_child == NULL && current) {
657 }
else if (first_child == NULL) {
658 crm_debug(
"No match found for %s (%d / %s / %s)", then_child->
id, current, first->
uuid, then->
uuid);
678 const char *first_task =
task2text(task);
680 pe__bundle_replica_t *first_replica = NULL;
681 pe__bundle_replica_t *then_replica = NULL;
683 first_replica = replica_for_container(first->
rsc, first_child,
685 if (strstr(first->
task,
"stop") && first_replica && first_replica->child) {
697 then_replica = replica_for_container(then->
rsc, then_child, node);
698 if (strstr(then->
task,
"mote")
699 && then_replica && then_replica->child) {
708 NULL, then->
task, node);
713 if (first_action == NULL) {
716 crm_err(
"Internal error: No action found for %s in %s (first)",
717 first_task, first_child->
id);
720 crm_trace(
"No action found for %s in %s%s (first)",
721 first_task, first_child->
id,
728 if (then_action == NULL) {
731 crm_err(
"Internal error: No action found for %s in %s (then)",
732 then->
task, then_child->
id);
735 crm_trace(
"No action found for %s in %s%s (then)",
736 then->
task, then_child->
id,
743 crm_debug(
"Created constraint for %s (%d) -> %s (%d) %.6x",
752 if(first_action && then_action) {
761 crm_err(
"Nothing found either for %s (%p) or %s (%p) %s",
762 first_child->
id, first_action,
769 g_list_free(children);
777 bool interleave = FALSE;
779 const char *interleave_s = NULL;
781 if(first->
rsc == NULL || then->
rsc == NULL) {
782 crm_trace(
"Not interleaving %s with %s (both must be resources)", first->
uuid, then->
uuid);
784 }
else if(first->
rsc == then->
rsc) {
785 crm_trace(
"Not interleaving %s with %s (must belong to different resources)", first->
uuid, then->
uuid);
788 crm_trace(
"Not interleaving %s with %s (both sides must be clones or bundles)", first->
uuid, then->
uuid);
801 crm_trace(
"Interleave %s -> %s: %s (based on %s)",
802 first->
uuid, then->
uuid, interleave ?
"yes" :
"no", rsc->
id);
832 uint32_t filter, uint32_t
type,
839 if(can_interleave_actions(first, then)) {
840 changed = multi_update_interleave_actions(first, then, node, filter,
843 }
else if(then->
rsc) {
845 GList *children = NULL;
852 children = get_containers_or_children(then->
rsc);
853 for (gIter = children; gIter != NULL; gIter = gIter->next) {
858 if (then_child_action) {
859 uint32_t then_child_flags = then_child->
cmds->
action_flags(then_child_action,
871 changed |= then_child_changed;
873 for (GList *lpc = then_child_action->actions_after; lpc != NULL; lpc = lpc->next) {
884 g_list_free(children);
893 pe__bundle_variant_data_t *bundle_data = NULL;
894 get_bundle_variant_data(bundle_data, rsc);
898 for (GList *gIter = bundle_data->replicas; gIter != NULL;
899 gIter = gIter->next) {
900 pe__bundle_replica_t *replica = gIter->data;
902 if (replica->container) {
903 replica->container->cmds->apply_location(replica->container,
907 replica->ip->cmds->apply_location(replica->ip, constraint);
911 if (bundle_data->child
914 bundle_data->child->cmds->apply_location(bundle_data->child,
916 bundle_data->child->rsc_location = g_list_prepend(bundle_data->child->rsc_location,
930 pe__bundle_variant_data_t *bundle_data = NULL;
934 get_bundle_variant_data(bundle_data, rsc);
936 if (bundle_data->child) {
937 bundle_data->child->cmds->add_actions_to_graph(bundle_data->child);
940 for (GList *gIter = bundle_data->replicas; gIter != NULL;
941 gIter = gIter->next) {
942 pe__bundle_replica_t *replica = gIter->data;
945 if (replica->remote && replica->container
955 replica->remote->xml, LOG_ERR);
956 const char *calculated_addr = NULL;
962 if (calculated_addr) {
972 g_hash_table_replace(params,
974 strdup(calculated_addr));
983 crm_info(
"Unable to determine address for bundle %s remote connection",
988 replica->ip->cmds->add_actions_to_graph(replica->ip);
990 if (replica->container) {
991 replica->container->cmds->add_actions_to_graph(replica->container);
993 if (replica->remote) {
994 replica->remote->cmds->add_actions_to_graph(replica->remote);
1012 bool any_created =
false;
1013 pe__bundle_variant_data_t *bundle_data = NULL;
1017 get_bundle_variant_data(bundle_data, rsc);
1018 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1019 gIter = gIter->next) {
1020 pe__bundle_replica_t *replica = gIter->data;
1023 if ((replica->ip != NULL)
1024 && replica->ip->cmds->create_probe(replica->ip, node)) {
1027 if ((replica->child != NULL) && (node->
details == replica->node->details)
1028 && replica->child->cmds->create_probe(replica->child, node)) {
1031 if ((replica->container != NULL)
1032 && replica->container->cmds->create_probe(replica->container,
1049 for (GList *tIter = bundle_data->replicas;
1050 tIter && (bundle_data->nreplicas_per_host == 1);
1051 tIter = tIter->next) {
1052 pe__bundle_replica_t *other = tIter->data;
1054 if ((other != replica) && (other != NULL)
1055 && (other->container != NULL)) {
1059 NULL, other->container,
1067 if ((replica->container != NULL) && (replica->remote != NULL)
1068 && replica->remote->cmds->create_probe(replica->remote, node)) {
1077 probe_uuid, NULL, node);
1080 if (probe != NULL) {
1083 replica->remote->id, pe__node_name(node));
1086 NULL, replica->remote, NULL, probe,
1097 pe__bundle_variant_data_t *bundle_data = NULL;
1101 get_bundle_variant_data(bundle_data, rsc);
1102 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1103 gIter = gIter->next) {
1104 pe__bundle_replica_t *replica = gIter->data;
1107 if (replica->ip != NULL) {
1108 replica->ip->cmds->output_actions(replica->ip);
1110 if (replica->container != NULL) {
1111 replica->container->cmds->output_actions(replica->container);
1113 if (replica->remote != NULL) {
1114 replica->remote->cmds->output_actions(replica->remote);
1116 if (replica->child != NULL) {
1117 replica->child->cmds->output_actions(replica->child);
1126 GHashTable *utilization)
1128 pe__bundle_variant_data_t *bundle_data = NULL;
1129 pe__bundle_replica_t *replica = NULL;
1135 get_bundle_variant_data(bundle_data, rsc);
1136 if (bundle_data->replicas == NULL) {
1144 replica = (pe__bundle_replica_t *) bundle_data->replicas->data;
1145 if (replica->container != NULL) {
1146 replica->container->cmds->add_utilization(replica->container, orig_rsc,
1147 all_rscs, utilization);
#define CRM_CHECK(expr, failure_action)
void pcmk__bundle_internal_constraints(pe_resource_t *rsc)
enum rsc_role_e role_filter
const char * task2text(enum action_tasks task)
void pcmk__output_bundle_actions(pe_resource_t *rsc)
#define pcmk__order_starts(rsc1, rsc2, flags)
#define crm_notice(fmt, args...)
bool pe__is_guest_or_remote_node(const pe_node_t *node)
#define pe_rsc_debug(rsc, fmt, args...)
enum pe_action_flags pcmk__bundle_action_flags(pe_action_t *action, const pe_node_t *node)
G_GNUC_INTERNAL uint32_t pcmk__update_ordered_actions(pe_action_t *first, pe_action_t *then, const pe_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pe_working_set_t *data_set)
#define pe__show_node_weights(level, rsc, text, nodes, data_set)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
pe_resource_t * container
resource_alloc_functions_t * cmds
#define pcmk__order_stops(rsc1, rsc2, flags)
G_GNUC_INTERNAL bool pcmk__threshold_reached(pe_resource_t *rsc, pe_node_t *node, pe_resource_t **failed)
void pcmk__bundle_add_utilization(const pe_resource_t *rsc, const pe_resource_t *orig_rsc, GList *all_rscs, GHashTable *utilization)
pe_action_t * find_first_action(const GList *input, const char *uuid, const char *task, const pe_node_t *on_node)
pe_resource_t * remote_rsc
void pcmk__bundle_apply_coloc_score(pe_resource_t *dependent, const pe_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
resource_object_functions_t * fns
bool pe__bundle_needs_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set)
pe_resource_t * dependent
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
G_GNUC_INTERNAL GList * pcmk__sort_nodes(GList *nodes, pe_node_t *active_node)
void clone_create_pseudo_actions(pe_resource_t *rsc, GList *children, notify_data_t **start_notify, notify_data_t **stop_notify)
pe_action_t * pe__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task, bool optional, bool runnable)
enum crm_ais_msg_types type
pe_resource_t * find_compatible_child_by_node(const pe_resource_t *local_child, const pe_node_t *local_node, const pe_resource_t *rsc, enum rsc_role_e filter, gboolean current)
bool pcmk__ends_with(const char *s, const char *match)
void pcmk__bundle_expand(pe_resource_t *rsc)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
#define XML_RSC_ATTR_REMOTE_RA_ADDR
gboolean is_child_compatible(const pe_resource_t *child_rsc, const pe_node_t *local_node, enum rsc_role_e filter, gboolean current)
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)
enum pe_action_flags(* action_flags)(pe_action_t *action, const pe_node_t *node)
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)
pe_resource_t * find_compatible_child(const pe_resource_t *local_child, const pe_resource_t *rsc, enum rsc_role_e filter, gboolean current)
#define crm_debug(fmt, args...)
#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.
uint32_t pcmk__multi_update_actions(pe_action_t *first, pe_action_t *then, const pe_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pe_working_set_t *data_set)
struct pe_node_shared_s * details
G_GNUC_INTERNAL gint pcmk__cmp_instance(gconstpointer a, gconstpointer b)
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
#define pe_rsc_promotable
pe_working_set_t * data_set
enum action_tasks clone_child_action(pe_action_t *action)
void pcmk__bundle_rsc_location(pe_resource_t *rsc, pe__location_t *constraint)
G_GNUC_INTERNAL void pcmk__new_ordering(pe_resource_t *first_rsc, char *first_task, pe_action_t *first_action, pe_resource_t *then_rsc, char *then_task, pe_action_t *then_action, uint32_t flags, pe_working_set_t *data_set)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
pe_node_t * pcmk__bundle_allocate(pe_resource_t *rsc, const pe_node_t *prefer)
bool is_set_recursive(const pe_resource_t *rsc, long long flag, bool any)
#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)
#define pcmk__order_resource_actions(first_rsc, first_task, then_rsc, then_task, flags)
void(* apply_coloc_score)(pe_resource_t *dependent, const pe_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, pe_working_set_t *data_set, xmlNode *xml, const char *field)
G_GNUC_INTERNAL void pcmk__apply_location(pe_resource_t *rsc, pe__location_t *constraint)
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 pcmk__set_updated_flags(au_flags, action, flags_to_set)
#define crm_err(fmt, args...)
G_GNUC_INTERNAL bool pcmk__assign_resource(pe_resource_t *rsc, pe_node_t *node, bool force)
GHashTable * pe_rsc_params(pe_resource_t *rsc, const pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
G_GNUC_INTERNAL void pcmk__promotable_restart_ordering(pe_resource_t *rsc)
#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
pe_working_set_t * cluster
gboolean crm_is_true(const char *s)
enum pe_action_flags summary_action_flags(pe_action_t *action, GList *children, const pe_node_t *node)
#define pe_rsc_trace(rsc, fmt, args...)
uint32_t(* update_ordered_actions)(pe_action_t *first, pe_action_t *then, const pe_node_t *node, uint32_t flags, uint32_t filter, uint32_t type, pe_working_set_t *data_set)
#define XML_RSC_ATTR_INTERLEAVE
#define pe_flag_show_scores
#define crm_info(fmt, args...)
bool pcmk__bundle_create_probe(pe_resource_t *rsc, pe_node_t *node)
void pcmk__bundle_create_actions(pe_resource_t *rsc)
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes