17 #define PE__VARIANT_BUNDLE 1
21 is_bundle_node(pe__bundle_variant_data_t *
data,
pe_node_t *node)
23 for (GList *gIter = data->replicas; gIter != NULL; gIter = gIter->next) {
24 pe__bundle_replica_t *replica = gIter->data;
26 if (node->
details == replica->node->details) {
40 GList *containers = NULL;
43 pe__bundle_variant_data_t *
data = NULL;
45 get_bundle_variant_data(data, rsc);
46 for (GList *gIter = data->replicas; gIter != NULL;
47 gIter = gIter->next) {
48 pe__bundle_replica_t *replica = gIter->data;
50 containers = g_list_append(containers, replica->container);
60 get_container_list(rsc) : rsc->children;
67 int fail_count, countdown;
83 if (fail_count <= 0) {
91 crm_warn(
"Forcing %s away from %s after %d failures (max=%d)",
97 crm_info(
"%s can fail %d more times on %s before being forced off",
106 GList *containers = NULL;
108 pe__bundle_variant_data_t *bundle_data = NULL;
112 get_bundle_variant_data(bundle_data, rsc);
115 containers = get_container_list(rsc);
124 bundle_data->nreplicas_per_host, data_set);
126 g_list_free(containers);
128 for (GList *gIter = bundle_data->replicas; gIter != NULL;
129 gIter = gIter->next) {
130 pe__bundle_replica_t *replica = gIter->data;
136 rsc->
id, replica->ip->id);
137 replica->ip->cmds->allocate(replica->ip, prefer, data_set);
140 container_host = replica->container->allocated_to;
149 NULL,
true, data_set);
152 if (replica->remote) {
154 rsc->
id, replica->remote->id);
155 replica->remote->cmds->allocate(replica->remote, prefer,
160 if (replica->child) {
164 g_hash_table_iter_init(&iter, replica->child->allowed_nodes);
165 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
166 if (node->
details != replica->node->details) {
168 }
else if (!migration_threshold_reached(replica->child, node,
175 pe_rsc_trace(rsc,
"Allocating bundle %s replica child %s",
176 rsc->
id, replica->child->id);
177 replica->child->cmds->allocate(replica->child, replica->node,
184 if (bundle_data->child) {
187 g_hash_table_iter_init(&iter, bundle_data->child->allowed_nodes);
188 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
189 if (is_bundle_node(bundle_data, node)) {
196 rsc->
id, bundle_data->child->id);
197 bundle_data->child->cmds->allocate(bundle_data->child, prefer, data_set);
209 GList *containers = NULL;
210 pe__bundle_variant_data_t *bundle_data = NULL;
214 containers = get_container_list(rsc);
215 get_bundle_variant_data(bundle_data, rsc);
216 for (GList *gIter = bundle_data->replicas; gIter != NULL;
217 gIter = gIter->next) {
218 pe__bundle_replica_t *replica = gIter->data;
222 replica->ip->cmds->create_actions(replica->ip, data_set);
224 if (replica->container) {
225 replica->container->cmds->create_actions(replica->container,
228 if (replica->remote) {
229 replica->remote->cmds->create_actions(replica->remote, data_set);
235 if (bundle_data->child) {
236 bundle_data->child->cmds->create_actions(bundle_data->child, data_set);
251 g_list_free(containers);
258 pe__bundle_variant_data_t *bundle_data = NULL;
262 get_bundle_variant_data(bundle_data, rsc);
264 if (bundle_data->child) {
270 if (bundle_data->child->children) {
283 for (GList *gIter = bundle_data->replicas; gIter != NULL;
284 gIter = gIter->next) {
285 pe__bundle_replica_t *replica = gIter->data;
290 replica->container->cmds->internal_constraints(replica->container,
296 if (replica->child) {
308 replica->ip->cmds->internal_constraints(replica->ip, data_set);
317 replica->container, NULL, NULL,
true,
321 if (replica->remote) {
327 replica->remote->cmds->internal_constraints(replica->remote,
331 if (replica->child) {
339 if (bundle_data->child) {
340 bundle_data->child->cmds->internal_constraints(bundle_data->child, data_set);
373 pe__bundle_variant_data_t *bundle_data = NULL;
375 CRM_CHECK(candidate != NULL,
return NULL);
376 get_bundle_variant_data(bundle_data, rsc);
378 crm_trace(
"Looking for compatible child from %s for %s on %s",
381 for (GList *gIter = bundle_data->replicas; gIter != NULL;
382 gIter = gIter->next) {
383 pe__bundle_replica_t *replica = gIter->data;
387 rsc_lh->
id, replica->container->id,
389 return replica->container;
402 GList *scratch = NULL;
406 active_node_lh = rsc_lh->
fns->
location(rsc_lh, NULL, current);
407 if (active_node_lh) {
408 return compatible_replica_for_node(rsc_lh, active_node_lh, rsc, filter,
415 for (GList *gIter = scratch; gIter != NULL; gIter = gIter->next) {
418 pair = compatible_replica_for_node(rsc_lh, node, rsc, filter, current);
424 pe_rsc_debug(rsc,
"Can't pair %s with %s", rsc_lh->
id, (rsc? rsc->
id :
"none"));
426 g_list_free(scratch);
463 if (max_clones_node == NULL) {
475 pe__bundle_variant_data_t *
data = NULL;
476 get_bundle_variant_data(data, rsc);
477 return data->nreplicas_per_host;
488 GList *allocated_rhs = NULL;
489 pe__bundle_variant_data_t *bundle_data = NULL;
492 CRM_CHECK(rsc_lh != NULL,
pe_err(
"rsc_lh was NULL for %s", constraint->
id);
return);
511 crm_notice(
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
515 pe_rsc_debug(rsc,
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
521 get_bundle_variant_data(bundle_data, rsc);
522 pe_rsc_trace(rsc,
"Processing constraint %s: %s -> %s %d",
523 constraint->
id, rsc_lh->
id, rsc->
id, constraint->
score);
525 for (GList *gIter = bundle_data->replicas; gIter != NULL;
526 gIter = gIter->next) {
527 pe__bundle_replica_t *replica = gIter->data;
530 replica->container->cmds->rsc_colocation_rh(rsc_lh,
532 constraint, data_set);
535 pe_node_t *chosen = replica->container->fns->location(replica->container,
543 && (replica->child == NULL)) {
552 allocated_rhs = g_list_prepend(allocated_rhs, chosen);
559 g_list_free(allocated_rhs);
565 GList *containers = NULL;
567 pe__bundle_variant_data_t *
data = NULL;
569 get_bundle_variant_data(data, action->
rsc);
586 containers = get_container_list(action->
rsc);
588 g_list_free(containers);
597 GList *children = NULL;
599 if (local_node == NULL) {
600 crm_err(
"Can't colocate unrunnable child %s with %s", local_child->
id, rsc->
id);
604 crm_trace(
"Looking for compatible child from %s for %s on %s",
607 children = get_containers_or_children(rsc);
608 for (gIter = children; gIter != NULL; gIter = gIter->next) {
618 crm_trace(
"Can't pair %s with %s", local_child->
id, rsc->
id);
620 g_list_free(children);
625 static pe__bundle_replica_t *
630 pe__bundle_variant_data_t *
data = NULL;
632 get_bundle_variant_data(data, rsc);
633 for (GList *gIter = data->replicas; gIter != NULL;
634 gIter = gIter->next) {
635 pe__bundle_replica_t *replica = gIter->data;
639 && (node->
details == replica->node->details)) {
655 GList *children = NULL;
656 gboolean current = FALSE;
665 children = get_containers_or_children(then->
rsc);
666 for (gIter = children; gIter != NULL; gIter = gIter->next) {
672 if (first_child == NULL && current) {
675 }
else if (first_child == NULL) {
676 crm_debug(
"No match found for %s (%d / %s / %s)", then_child->
id, current, first->
uuid, then->
uuid);
696 const char *first_task =
task2text(task);
698 pe__bundle_replica_t *first_replica = NULL;
699 pe__bundle_replica_t *then_replica = NULL;
701 first_replica = replica_for_container(first->
rsc, first_child,
703 if (strstr(first->
task,
"stop") && first_replica && first_replica->child) {
715 then_replica = replica_for_container(then->
rsc, then_child, node);
716 if (strstr(then->
task,
"mote")
717 && then_replica && then_replica->child) {
726 NULL, then->
task, node);
731 if (first_action == NULL) {
734 crm_err(
"Internal error: No action found for %s in %s (first)",
735 first_task, first_child->
id);
738 crm_trace(
"No action found for %s in %s%s (first)",
739 first_task, first_child->
id,
746 if (then_action == NULL) {
749 crm_err(
"Internal error: No action found for %s in %s (then)",
750 then->
task, then_child->
id);
753 crm_trace(
"No action found for %s in %s%s (then)",
754 then->
task, then_child->
id,
761 crm_debug(
"Created constraint for %s (%d) -> %s (%d) %.6x",
770 if(first_action && then_action) {
774 filter,
type, data_set);
776 crm_err(
"Nothing found either for %s (%p) or %s (%p) %s",
777 first_child->
id, first_action,
784 g_list_free(children);
792 bool interleave = FALSE;
794 const char *interleave_s = NULL;
796 if(first->
rsc == NULL || then->
rsc == NULL) {
797 crm_trace(
"Not interleaving %s with %s (both must be resources)", first->
uuid, then->
uuid);
799 }
else if(first->
rsc == then->
rsc) {
800 crm_trace(
"Not interleaving %s with %s (must belong to different resources)", first->
uuid, then->
uuid);
803 crm_trace(
"Not interleaving %s with %s (both sides must be clones or bundles)", first->
uuid, then->
uuid);
816 crm_trace(
"Interleave %s -> %s: %s (based on %s)",
817 first->
uuid, then->
uuid, interleave ?
"yes" :
"no", rsc->
id);
832 if(can_interleave_actions(first, then)) {
833 changed = multi_update_interleave_actions(first, then, node, flags,
834 filter, type, data_set);
836 }
else if(then->
rsc) {
838 GList *children = NULL;
845 children = get_containers_or_children(then->
rsc);
846 for (gIter = children; gIter != NULL; gIter = gIter->next) {
851 if (then_child_action) {
856 then_child_action, node, flags, filter, type, data_set);
858 changed |= then_child_changed;
860 for (GList *lpc = then_child_action->actions_after; lpc != NULL; lpc = lpc->next) {
869 g_list_free(children);
878 pe__bundle_variant_data_t *bundle_data = NULL;
879 get_bundle_variant_data(bundle_data, rsc);
883 for (GList *gIter = bundle_data->replicas; gIter != NULL;
884 gIter = gIter->next) {
885 pe__bundle_replica_t *replica = gIter->data;
887 if (replica->container) {
888 replica->container->cmds->rsc_location(replica->container,
892 replica->ip->cmds->rsc_location(replica->ip, constraint);
896 if (bundle_data->child
899 bundle_data->child->cmds->rsc_location(bundle_data->child, constraint);
900 bundle_data->child->rsc_location = g_list_prepend(bundle_data->child->rsc_location,
908 pe__bundle_variant_data_t *bundle_data = NULL;
912 get_bundle_variant_data(bundle_data, rsc);
914 if (bundle_data->child) {
915 bundle_data->child->cmds->expand(bundle_data->child, data_set);
918 for (GList *gIter = bundle_data->replicas; gIter != NULL;
919 gIter = gIter->next) {
920 pe__bundle_replica_t *replica = gIter->data;
923 if (replica->remote && replica->container
933 replica->remote->xml, LOG_ERR);
934 const char *calculated_addr = NULL;
940 if (calculated_addr) {
949 crm_trace(
"Set address for bundle connection %s to bundle host %s",
950 replica->remote->id, calculated_addr);
951 g_hash_table_replace(params,
953 strdup(calculated_addr));
962 crm_info(
"Unable to determine address for bundle %s remote connection",
967 replica->ip->cmds->expand(replica->ip, data_set);
969 if (replica->container) {
970 replica->container->cmds->expand(replica->container, data_set);
972 if (replica->remote) {
973 replica->remote->cmds->expand(replica->remote, data_set);
983 bool any_created = FALSE;
984 pe__bundle_variant_data_t *bundle_data = NULL;
988 get_bundle_variant_data(bundle_data, rsc);
989 for (GList *gIter = bundle_data->replicas; gIter != NULL;
990 gIter = gIter->next) {
991 pe__bundle_replica_t *replica = gIter->data;
995 any_created |= replica->ip->cmds->create_probe(replica->ip, node,
999 if (replica->child && (node->
details == replica->node->details)) {
1000 any_created |= replica->child->cmds->create_probe(replica->child,
1004 if (replica->container) {
1005 bool created = replica->container->cmds->create_probe(replica->container,
1024 for (GList *tIter = bundle_data->replicas;
1025 tIter && (bundle_data->nreplicas_per_host == 1);
1026 tIter = tIter->next) {
1027 pe__bundle_replica_t *other = tIter->data;
1029 if ((other != replica) && (other != NULL)
1030 && (other->container != NULL)) {
1034 NULL, other->container,
1043 if (replica->container && replica->remote
1044 && replica->remote->cmds->create_probe(replica->remote, node,
1055 probe_uuid, NULL, node);
1064 NULL, replica->remote, NULL, probe,
1080 pe__bundle_variant_data_t *bundle_data = NULL;
1084 get_bundle_variant_data(bundle_data, rsc);
1085 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1086 gIter = gIter->next) {
1087 pe__bundle_replica_t *replica = gIter->data;
1093 if (replica->container) {
1096 if (replica->remote) {
1099 if (replica->child) {
#define CRM_CHECK(expr, failure_action)
enum rsc_role_e role_filter
void pcmk__bundle_log_actions(pe_resource_t *rsc, pe_working_set_t *data_set)
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)
enum pe_action_flags pcmk__bundle_action_flags(pe_action_t *action, 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)
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
pe_resource_t * container
resource_alloc_functions_t * cmds
void pcmk__new_colocation(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, bool influence, pe_working_set_t *data_set)
enum pe_action_flags(* action_flags)(pe_action_t *, pe_node_t *)
gint sort_clone_instance(gconstpointer a, gconstpointer b, gpointer 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)
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)
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
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
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)
void pcmk__bundle_rsc_colocation_lh(pe_resource_t *lh_rsc, pe_resource_t *rh_rsc, pcmk__colocation_t *constraint, pe_working_set_t *data_set)
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)
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
#define crm_warn(fmt, args...)
#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...)
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
GHashTable * pe_rsc_params(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
Get a table of resource parameters.
enum action_tasks clone_child_action(pe_action_t *action)
void LogActions(pe_resource_t *rsc, pe_working_set_t *data_set)
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)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
#define pe_rsc_allocating
pe_node_t * pcmk__bundle_allocate(pe_resource_t *rsc, pe_node_t *preferred, pe_working_set_t *data_set)
enum pe_obj_types variant
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
void pcmk__bundle_rsc_colocation_rh(pe_resource_t *lh_rsc, pe_resource_t *rh_rsc, pcmk__colocation_t *constraint, pe_working_set_t *data_set)
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)
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)
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)
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)
void pcmk__bundle_rsc_location(pe_resource_t *rsc, pe__location_t *constraint)
#define crm_err(fmt, args...)
#define pe__clear_resource_flags(resource, flags_to_clear)
void pcmk__bundle_expand(pe_resource_t *rsc, pe_working_set_t *data_set)
rsc_role_e
Possible roles that a resource can be in.
enum pe_action_flags flags
#define pe_rsc_failure_ignored
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define order_start_start(rsc1, rsc2, type)
gboolean crm_is_true(const char *s)
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)
#define pe_rsc_trace(rsc, fmt, args...)
#define XML_RSC_ATTR_INTERLEAVE
#define pe_flag_show_scores
void pcmk__bundle_create_actions(pe_resource_t *rsc, pe_working_set_t *data_set)
#define crm_info(fmt, args...)
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)
pe_action_t * find_first_action(GList *input, const char *uuid, const char *task, pe_node_t *on_node)
void pcmk__bundle_internal_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
void pcmk__bundle_append_meta(pe_resource_t *rsc, xmlNode *xml)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, pcmk__colocation_t *, pe_working_set_t *)
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)
int copies_per_node(pe_resource_t *rsc)
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes