15 #define PE__VARIANT_BUNDLE 1 19 is_bundle_node(pe__bundle_variant_data_t *
data,
pe_node_t *node)
21 for (GList *gIter =
data->replicas; gIter != NULL; gIter = gIter->next) {
22 pe__bundle_replica_t *replica = gIter->data;
24 if (node->
details == replica->node->details) {
38 GList *containers = NULL;
41 pe__bundle_variant_data_t *
data = NULL;
43 get_bundle_variant_data(
data, rsc);
44 for (GList *gIter =
data->replicas; gIter != NULL;
45 gIter = gIter->next) {
46 pe__bundle_replica_t *replica = gIter->data;
48 containers = g_list_append(containers, replica->container);
58 get_container_list(rsc) : rsc->children;
65 int fail_count, countdown;
81 if (fail_count <= 0) {
89 crm_warn(
"Forcing %s away from %s after %d failures (max=%d)",
95 crm_info(
"%s can fail %d more times on %s before being forced off",
106 pe__bundle_variant_data_t *bundle_data = NULL;
110 get_bundle_variant_data(bundle_data, rsc);
113 containers = get_container_list(rsc);
121 bundle_data->nreplicas_per_host, data_set);
123 g_list_free(containers);
125 for (GList *gIter = bundle_data->replicas; gIter != NULL;
126 gIter = gIter->next) {
127 pe__bundle_replica_t *replica = gIter->data;
133 rsc->
id, replica->ip->id);
134 replica->ip->cmds->allocate(replica->ip, prefer, data_set);
137 container_host = replica->container->allocated_to;
149 if (replica->remote) {
151 rsc->
id, replica->remote->id);
152 replica->remote->cmds->allocate(replica->remote, prefer,
157 if (replica->child) {
161 g_hash_table_iter_init(&iter, replica->child->allowed_nodes);
162 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
163 if (node->details != replica->node->details) {
165 }
else if (!migration_threshold_reached(replica->child, node,
172 pe_rsc_trace(rsc,
"Allocating bundle %s replica child %s",
173 rsc->
id, replica->child->id);
174 replica->child->cmds->allocate(replica->child, replica->node,
181 if (bundle_data->child) {
184 g_hash_table_iter_init(&iter, bundle_data->child->allowed_nodes);
185 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
186 if (is_bundle_node(bundle_data, node)) {
193 rsc->
id, bundle_data->child->id);
194 bundle_data->child->cmds->allocate(bundle_data->child, prefer, data_set);
207 pe__bundle_variant_data_t *bundle_data = NULL;
211 containers = get_container_list(rsc);
212 get_bundle_variant_data(bundle_data, rsc);
213 for (GList *gIter = bundle_data->replicas; gIter != NULL;
214 gIter = gIter->next) {
215 pe__bundle_replica_t *replica = gIter->data;
219 replica->ip->cmds->create_actions(replica->ip, data_set);
221 if (replica->container) {
222 replica->container->cmds->create_actions(replica->container,
225 if (replica->remote) {
226 replica->remote->cmds->create_actions(replica->remote, data_set);
232 if (bundle_data->child) {
233 bundle_data->child->cmds->create_actions(bundle_data->child, data_set);
248 g_list_free(containers);
255 pe__bundle_variant_data_t *bundle_data = NULL;
259 get_bundle_variant_data(bundle_data, rsc);
261 if (bundle_data->child) {
267 if (bundle_data->child->children) {
280 for (GList *gIter = bundle_data->replicas; gIter != NULL;
281 gIter = gIter->next) {
282 pe__bundle_replica_t *replica = gIter->data;
287 replica->container->cmds->internal_constraints(replica->container,
293 if (replica->child) {
305 replica->ip->cmds->internal_constraints(replica->ip, data_set);
314 replica->container, NULL, NULL, data_set);
317 if (replica->remote) {
323 replica->remote->cmds->internal_constraints(replica->remote,
327 if (replica->child) {
335 if (bundle_data->child) {
336 bundle_data->child->cmds->internal_constraints(bundle_data->child, data_set);
369 pe__bundle_variant_data_t *bundle_data = NULL;
371 CRM_CHECK(candidate != NULL,
return NULL);
372 get_bundle_variant_data(bundle_data, rsc);
374 crm_trace(
"Looking for compatible child from %s for %s on %s",
377 for (GList *gIter = bundle_data->replicas; gIter != NULL;
378 gIter = gIter->next) {
379 pe__bundle_replica_t *replica = gIter->data;
383 rsc_lh->
id, replica->container->id,
385 return replica->container;
402 active_node_lh = rsc_lh->
fns->
location(rsc_lh, NULL, current);
403 if (active_node_lh) {
404 return compatible_replica_for_node(rsc_lh, active_node_lh, rsc, filter,
411 for (
GListPtr gIter = scratch; gIter != NULL; gIter = gIter->next) {
414 pair = compatible_replica_for_node(rsc_lh, node, rsc, filter, current);
420 pe_rsc_debug(rsc,
"Can't pair %s with %s", rsc_lh->
id, (rsc? rsc->
id :
"none"));
422 g_list_free(scratch);
462 pe__bundle_variant_data_t *
data = NULL;
463 get_bundle_variant_data(
data, rsc);
464 return data->nreplicas_per_host;
476 pe__bundle_variant_data_t *bundle_data = NULL;
479 CRM_CHECK(rsc_lh != NULL,
pe_err(
"rsc_lh was NULL for %s", constraint->
id);
return);
483 if (constraint->
score == 0) {
501 crm_notice(
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
505 pe_rsc_debug(rsc,
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
511 get_bundle_variant_data(bundle_data, rsc);
512 pe_rsc_trace(rsc,
"Processing constraint %s: %s -> %s %d",
513 constraint->
id, rsc_lh->
id, rsc->
id, constraint->
score);
515 for (GList *gIter = bundle_data->replicas; gIter != NULL;
516 gIter = gIter->next) {
517 pe__bundle_replica_t *replica = gIter->data;
520 replica->container->cmds->rsc_colocation_rh(rsc_lh,
522 constraint, data_set);
525 pe_node_t *chosen = replica->container->fns->location(replica->container,
533 && (replica->child == NULL)) {
542 allocated_rhs = g_list_prepend(allocated_rhs, chosen);
549 g_list_free(allocated_rhs);
557 pe__bundle_variant_data_t *
data = NULL;
576 containers = get_container_list(
action->rsc);
578 g_list_free(containers);
589 if (local_node == NULL) {
590 crm_err(
"Can't colocate unrunnable child %s with %s", local_child->
id, rsc->
id);
594 crm_trace(
"Looking for compatible child from %s for %s on %s",
597 children = get_containers_or_children(rsc);
598 for (gIter = children; gIter != NULL; gIter = gIter->next) {
608 crm_trace(
"Can't pair %s with %s", local_child->
id, rsc->
id);
610 g_list_free(children);
615 static pe__bundle_replica_t *
620 pe__bundle_variant_data_t *
data = NULL;
622 get_bundle_variant_data(
data, rsc);
623 for (GList *gIter =
data->replicas; gIter != NULL;
624 gIter = gIter->next) {
625 pe__bundle_replica_t *replica = gIter->data;
628 && (container == replica->container)
629 && (node->
details == replica->node->details)) {
646 gboolean current = FALSE;
655 children = get_containers_or_children(then->
rsc);
656 for (gIter = children; gIter != NULL; gIter = gIter->next) {
662 if (first_child == NULL && current) {
665 }
else if (first_child == NULL) {
666 crm_debug(
"No match found for %s (%d / %s / %s)", then_child->
id, current, first->
uuid, then->
uuid);
686 const char *first_task =
task2text(task);
688 pe__bundle_replica_t *first_replica = NULL;
689 pe__bundle_replica_t *then_replica = NULL;
691 first_replica = replica_for_container(first->
rsc, first_child,
693 if (strstr(first->
task,
"stop") && first_replica && first_replica->child) {
705 then_replica = replica_for_container(then->
rsc, then_child, node);
706 if (strstr(then->
task,
"mote")
707 && then_replica && then_replica->child) {
716 NULL, then->
task, node);
721 if (first_action == NULL) {
724 crm_err(
"Internal error: No action found for %s in %s (first)",
725 first_task, first_child->
id);
728 crm_trace(
"No action found for %s in %s%s (first)",
729 first_task, first_child->
id,
736 if (then_action == NULL) {
739 crm_err(
"Internal error: No action found for %s in %s (then)",
740 then->
task, then_child->
id);
743 crm_trace(
"No action found for %s in %s%s (then)",
744 then->
task, then_child->
id,
751 crm_debug(
"Created constraint for %s (%d) -> %s (%d) %.6x",
760 if(first_action && then_action) {
764 filter,
type, data_set);
766 crm_err(
"Nothing found either for %s (%p) or %s (%p) %s",
767 first_child->
id, first_action,
774 g_list_free(children);
782 bool interleave = FALSE;
784 const char *interleave_s = NULL;
786 if(first->
rsc == NULL || then->
rsc == NULL) {
787 crm_trace(
"Not interleaving %s with %s (both must be resources)", first->
uuid, then->
uuid);
789 }
else if(first->
rsc == then->
rsc) {
790 crm_trace(
"Not interleaving %s with %s (must belong to different resources)", first->
uuid, then->
uuid);
793 crm_trace(
"Not interleaving %s with %s (both sides must be clones or bundles)", first->
uuid, then->
uuid);
806 crm_trace(
"Interleave %s -> %s: %s (based on %s)",
807 first->
uuid, then->
uuid, interleave ?
"yes" :
"no", rsc->
id);
822 if(can_interleave_actions(first, then)) {
823 changed = multi_update_interleave_actions(first, then, node,
flags,
824 filter,
type, data_set);
826 }
else if(then->
rsc) {
835 children = get_containers_or_children(then->
rsc);
836 for (gIter = children; gIter != NULL; gIter = gIter->next) {
841 if (then_child_action) {
846 then_child_action, node,
flags, filter,
type, data_set);
848 changed |= then_child_changed;
850 for (
GListPtr 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;
928 if (calculated_addr) {
929 crm_trace(
"Set address for bundle connection %s to bundle host %s",
930 replica->remote->id, calculated_addr);
931 g_hash_table_replace(replica->remote->parameters,
933 strdup(calculated_addr));
942 crm_info(
"Unable to determine address for bundle %s remote connection",
947 replica->ip->cmds->expand(replica->ip, data_set);
949 if (replica->container) {
950 replica->container->cmds->expand(replica->container, data_set);
952 if (replica->remote) {
953 replica->remote->cmds->expand(replica->remote, data_set);
963 bool any_created = FALSE;
964 pe__bundle_variant_data_t *bundle_data = NULL;
968 get_bundle_variant_data(bundle_data, rsc);
969 for (GList *gIter = bundle_data->replicas; gIter != NULL;
970 gIter = gIter->next) {
971 pe__bundle_replica_t *replica = gIter->data;
975 any_created |= replica->ip->cmds->create_probe(replica->ip, node,
979 if (replica->child && (node->
details == replica->node->details)) {
980 any_created |= replica->child->cmds->create_probe(replica->child,
984 if (replica->container) {
985 bool created = replica->container->cmds->create_probe(replica->container,
1004 for (GList *tIter = bundle_data->replicas;
1005 tIter && (bundle_data->nreplicas_per_host == 1);
1006 tIter = tIter->next) {
1007 pe__bundle_replica_t *other = tIter->data;
1009 if ((other != replica) && (other != NULL)
1010 && (other->container != NULL)) {
1014 NULL, other->container,
1023 if (replica->container && replica->remote
1024 && replica->remote->cmds->create_probe(replica->remote, node,
1035 probe_uuid, NULL, node);
1044 NULL, replica->remote, NULL, probe,
1061 pe__bundle_variant_data_t *bundle_data = NULL;
1065 get_bundle_variant_data(bundle_data, rsc);
1066 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1067 gIter = gIter->next) {
1068 pe__bundle_replica_t *replica = gIter->data;
1074 if (replica->container) {
1075 LogActions(replica->container, data_set, terminal);
1077 if (replica->remote) {
1078 LogActions(replica->remote, data_set, terminal);
1080 if (replica->child) {
1081 LogActions(replica->child, data_set, terminal);
#define CRM_CHECK(expr, failure_action)
gboolean rsc_colocation_new(const char *id, const char *node_attr, int score, pe_resource_t *rsc_lh, pe_resource_t *rsc_rh, const char *state_lh, const char *state_rh, pe_working_set_t *data_set)
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)
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...)
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
enum pe_action_flags summary_action_flags(pe_action_t *action, GListPtr children, pe_node_t *node)
pe_resource_t * container
resource_alloc_functions_t * cmds
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)
#define pe__show_node_weights(level, rsc, text, nodes)
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
void pcmk__bundle_rsc_colocation_rh(pe_resource_t *rsc_lh, pe_resource_t *rsc, rsc_colocation_t *constraint, pe_working_set_t *data_set)
resource_object_functions_t * fns
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)
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
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)
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)
void native_rsc_location(pe_resource_t *rsc, pe__location_t *constraint)
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)
bool pe__bundle_needs_remote_name(pe_resource_t *rsc)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
#define XML_RSC_ATTR_REMOTE_RA_ADDR
#define pe__set_resource_flags(resource, flags_to_set)
#define pe_rsc_provisional
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define crm_warn(fmt, args...)
void LogActions(pe_resource_t *rsc, pe_working_set_t *data_set, gboolean terminal)
#define order_stop_stop(rsc1, rsc2, type)
pe_action_t * create_pseudo_resource_op(pe_resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
#define crm_debug(fmt, args...)
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)
const char * pe__add_bundle_remote_name(pe_resource_t *rsc, xmlNode *xml, const char *field)
gboolean update_action(pe_action_t *action, pe_working_set_t *data_set)
int custom_action_order(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)
#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
enum action_tasks clone_child_action(pe_action_t *action)
bool assign_node(pe_resource_t *rsc, pe_node_t *node, gboolean force)
#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
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int new_rsc_order(pe_resource_t *lh_rsc, const char *lh_task, pe_resource_t *rh_rsc, const char *rh_task, enum pe_ordering type, pe_working_set_t *data_set)
void pcmk__bundle_rsc_colocation_lh(pe_resource_t *rsc, pe_resource_t *rsc_rh, rsc_colocation_t *constraint, pe_working_set_t *data_set)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
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)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, rsc_colocation_t *, pe_working_set_t *)
void pcmk__bundle_expand(pe_resource_t *rsc, pe_working_set_t *data_set)
int copies_per_node(pe_resource_t *rsc)
#define crm_err(fmt, args...)
void node_list_exclude(GHashTable *list, GListPtr list2, gboolean merge_scores)
void pcmk__bundle_log_actions(pe_resource_t *rsc, pe_working_set_t *data_set, gboolean terminal)
void clone_create_pseudo_actions(pe_resource_t *rsc, GListPtr children, notify_data_t **start_notify, notify_data_t **stop_notify, pe_working_set_t *data_set)
void pcmk__bundle_append_meta(pe_resource_t *rsc, xmlNode *xml)
#define pe__clear_resource_flags(resource, flags_to_clear)
enum pe_action_flags flags
#define pe_rsc_failure_ignored
#define order_start_start(rsc1, rsc2, type)
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...)
pe_action_t * find_first_action(GListPtr input, const char *uuid, const char *task, pe_node_t *on_node)
#define XML_RSC_ATTR_INTERLEAVE
#define crm_info(fmt, args...)
int pe_get_failcount(pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, xmlNode *xml_op, pe_working_set_t *data_set)
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
void distribute_children(pe_resource_t *rsc, GListPtr children, GListPtr nodes, int max, int per_host_max, pe_working_set_t *data_set)
GHashTable * allowed_nodes