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;
132 replica->ip->cmds->allocate(replica->ip, prefer, data_set);
135 container_host = replica->container->allocated_to;
147 if (replica->remote) {
148 replica->remote->cmds->allocate(replica->remote, prefer,
153 if (replica->child) {
157 g_hash_table_iter_init(&iter, replica->child->allowed_nodes);
158 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
159 if (node->details != replica->node->details) {
161 }
else if (!migration_threshold_reached(replica->child, node,
168 replica->child->cmds->allocate(replica->child, replica->node,
174 if (bundle_data->child) {
177 g_hash_table_iter_init(&iter, bundle_data->child->allowed_nodes);
178 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) & node)) {
179 if (is_bundle_node(bundle_data, node)) {
185 bundle_data->child->cmds->allocate(bundle_data->child, prefer, data_set);
199 pe__bundle_variant_data_t *bundle_data = NULL;
203 containers = get_container_list(rsc);
204 get_bundle_variant_data(bundle_data, rsc);
205 for (GList *gIter = bundle_data->replicas; gIter != NULL;
206 gIter = gIter->next) {
207 pe__bundle_replica_t *replica = gIter->data;
211 replica->ip->cmds->create_actions(replica->ip, data_set);
213 if (replica->container) {
214 replica->container->cmds->create_actions(replica->container,
217 if (replica->remote) {
218 replica->remote->cmds->create_actions(replica->remote, data_set);
224 if (bundle_data->child) {
225 bundle_data->child->cmds->create_actions(bundle_data->child, data_set);
240 g_list_free(containers);
247 pe__bundle_variant_data_t *bundle_data = NULL;
251 get_bundle_variant_data(bundle_data, rsc);
253 if (bundle_data->child) {
259 if (bundle_data->child->children) {
272 for (GList *gIter = bundle_data->replicas; gIter != NULL;
273 gIter = gIter->next) {
274 pe__bundle_replica_t *replica = gIter->data;
279 replica->container->cmds->internal_constraints(replica->container,
285 if (replica->child) {
297 replica->ip->cmds->internal_constraints(replica->ip, data_set);
306 replica->container, NULL, NULL, data_set);
309 if (replica->remote) {
315 replica->remote->cmds->internal_constraints(replica->remote,
319 if (replica->child) {
327 if (bundle_data->child) {
328 bundle_data->child->cmds->internal_constraints(bundle_data->child, data_set);
361 pe__bundle_variant_data_t *bundle_data = NULL;
363 CRM_CHECK(candidate != NULL,
return NULL);
364 get_bundle_variant_data(bundle_data, rsc);
366 crm_trace(
"Looking for compatible child from %s for %s on %s",
369 for (GList *gIter = bundle_data->replicas; gIter != NULL;
370 gIter = gIter->next) {
371 pe__bundle_replica_t *replica = gIter->data;
375 rsc_lh->
id, replica->container->id,
377 return replica->container;
392 node_t *active_node_lh = NULL;
394 active_node_lh = rsc_lh->
fns->
location(rsc_lh, NULL, current);
395 if (active_node_lh) {
396 return compatible_replica_for_node(rsc_lh, active_node_lh, rsc, filter,
403 for (
GListPtr gIter = scratch; gIter != NULL; gIter = gIter->next) {
406 pair = compatible_replica_for_node(rsc_lh, node, rsc, filter, current);
412 pe_rsc_debug(rsc,
"Can't pair %s with %s", rsc_lh->
id, (rsc? rsc->
id :
"none"));
414 g_list_free(scratch);
454 pe__bundle_variant_data_t *
data = NULL;
455 get_bundle_variant_data(
data, rsc);
456 return data->nreplicas_per_host;
468 pe__bundle_variant_data_t *bundle_data = NULL;
471 CRM_CHECK(rsc_lh != NULL,
pe_err(
"rsc_lh was NULL for %s", constraint->
id);
return);
480 resource_t *rh_child = compatible_replica(rsc_lh, rsc,
490 crm_notice(
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
494 pe_rsc_debug(rsc,
"Cannot pair %s with instance of %s", rsc_lh->
id, rsc->
id);
500 get_bundle_variant_data(bundle_data, rsc);
501 pe_rsc_trace(rsc,
"Processing constraint %s: %s -> %s %d",
502 constraint->
id, rsc_lh->
id, rsc->
id, constraint->
score);
504 for (GList *gIter = bundle_data->replicas; gIter != NULL;
505 gIter = gIter->next) {
506 pe__bundle_replica_t *replica = gIter->data;
509 replica->container->cmds->rsc_colocation_rh(rsc_lh,
511 constraint, data_set);
514 node_t *chosen = replica->container->fns->location(replica->container,
522 && (replica->child == NULL)) {
531 allocated_rhs = g_list_prepend(allocated_rhs, chosen);
538 g_list_free(allocated_rhs);
546 pe__bundle_variant_data_t *
data = NULL;
548 get_bundle_variant_data(
data, action->
rsc);
565 containers = get_container_list(action->
rsc);
567 g_list_free(containers);
578 if (local_node == NULL) {
579 crm_err(
"Can't colocate unrunnable child %s with %s", local_child->
id, rsc->
id);
583 crm_trace(
"Looking for compatible child from %s for %s on %s",
586 children = get_containers_or_children(rsc);
587 for (gIter = children; gIter != NULL; gIter = gIter->next) {
597 crm_trace(
"Can't pair %s with %s", local_child->
id, rsc->
id);
599 g_list_free(children);
604 static pe__bundle_replica_t *
609 pe__bundle_variant_data_t *
data = NULL;
611 get_bundle_variant_data(
data, rsc);
612 for (GList *gIter =
data->replicas; gIter != NULL;
613 gIter = gIter->next) {
614 pe__bundle_replica_t *replica = gIter->data;
617 && (container == replica->container)
618 && (node->
details == replica->node->details)) {
635 gboolean current = FALSE;
644 children = get_containers_or_children(then->
rsc);
645 for (gIter = children; gIter != NULL; gIter = gIter->next) {
651 if (first_child == NULL && current) {
654 }
else if (first_child == NULL) {
655 crm_debug(
"No match found for %s (%d / %s / %s)", then_child->
id, current, first->
uuid, then->
uuid);
675 const char *first_task =
task2text(task);
677 pe__bundle_replica_t *first_replica = NULL;
678 pe__bundle_replica_t *then_replica = NULL;
680 first_replica = replica_for_container(first->
rsc, first_child,
682 if (strstr(first->
task,
"stop") && first_replica && first_replica->child) {
694 then_replica = replica_for_container(then->
rsc, then_child, node);
695 if (strstr(then->
task,
"mote")
696 && then_replica && then_replica->child) {
705 NULL, then->
task, node);
710 if (first_action == NULL) {
714 crm_err(
"Internal error: No action found for %s in %s (first)",
715 first_task, first_child->
id);
718 crm_trace(
"No action found for %s in %s%s (first)",
719 first_task, first_child->
id,
726 if (then_action == NULL) {
730 crm_err(
"Internal error: No action found for %s in %s (then)",
731 then->
task, then_child->
id);
734 crm_trace(
"No action found for %s in %s%s (then)",
735 then->
task, then_child->
id,
742 crm_debug(
"Created constraint for %s (%d) -> %s (%d) %.6x",
747 if(first_action && then_action) {
751 filter,
type, data_set);
753 crm_err(
"Nothing found either for %s (%p) or %s (%p) %s",
754 first_child->
id, first_action,
761 g_list_free(children);
769 bool interleave = FALSE;
771 const char *interleave_s = NULL;
773 if(first->
rsc == NULL || then->
rsc == NULL) {
774 crm_trace(
"Not interleaving %s with %s (both must be resources)", first->
uuid, then->
uuid);
776 }
else if(first->
rsc == then->
rsc) {
777 crm_trace(
"Not interleaving %s with %s (must belong to different resources)", first->
uuid, then->
uuid);
780 crm_trace(
"Not interleaving %s with %s (both sides must be clones or bundles)", first->
uuid, then->
uuid);
792 crm_trace(
"Interleave %s -> %s: %s (based on %s)",
793 first->
uuid, then->
uuid, interleave ?
"yes" :
"no", rsc->
id);
808 if(can_interleave_actions(first, then)) {
809 changed = multi_update_interleave_actions(first, then, node,
flags,
810 filter,
type, data_set);
812 }
else if(then->
rsc) {
821 children = get_containers_or_children(then->
rsc);
822 for (gIter = children; gIter != NULL; gIter = gIter->next) {
827 if (then_child_action) {
832 then_child_action, node,
flags, filter,
type, data_set);
834 changed |= then_child_changed;
836 for (
GListPtr lpc = then_child_action->actions_after; lpc != NULL; lpc = lpc->next) {
845 g_list_free(children);
854 pe__bundle_variant_data_t *bundle_data = NULL;
855 get_bundle_variant_data(bundle_data, rsc);
857 pe_rsc_trace(rsc,
"Processing location constraint %s for %s", constraint->
id, rsc->
id);
861 for (GList *gIter = bundle_data->replicas; gIter != NULL;
862 gIter = gIter->next) {
863 pe__bundle_replica_t *replica = gIter->data;
865 if (replica->container) {
866 replica->container->cmds->rsc_location(replica->container,
870 replica->ip->cmds->rsc_location(replica->ip, constraint);
874 if (bundle_data->child
877 bundle_data->child->cmds->rsc_location(bundle_data->child, constraint);
878 bundle_data->child->rsc_location = g_list_prepend(bundle_data->child->rsc_location,
886 pe__bundle_variant_data_t *bundle_data = NULL;
890 get_bundle_variant_data(bundle_data, rsc);
892 if (bundle_data->child) {
893 bundle_data->child->cmds->expand(bundle_data->child, data_set);
896 for (GList *gIter = bundle_data->replicas; gIter != NULL;
897 gIter = gIter->next) {
898 pe__bundle_replica_t *replica = gIter->data;
901 if (replica->remote && replica->container
911 replica->remote->xml, LOG_ERR);
912 const char *calculated_addr = NULL;
916 if (calculated_addr) {
917 crm_trace(
"Set address for bundle connection %s to bundle host %s",
918 replica->remote->id, calculated_addr);
919 g_hash_table_replace(replica->remote->parameters,
921 strdup(calculated_addr));
930 crm_info(
"Unable to determine address for bundle %s remote connection",
935 replica->ip->cmds->expand(replica->ip, data_set);
937 if (replica->container) {
938 replica->container->cmds->expand(replica->container, data_set);
940 if (replica->remote) {
941 replica->remote->cmds->expand(replica->remote, data_set);
951 bool any_created = FALSE;
952 pe__bundle_variant_data_t *bundle_data = NULL;
956 get_bundle_variant_data(bundle_data, rsc);
957 for (GList *gIter = bundle_data->replicas; gIter != NULL;
958 gIter = gIter->next) {
959 pe__bundle_replica_t *replica = gIter->data;
963 any_created |= replica->ip->cmds->create_probe(replica->ip, node,
967 if (replica->child && (node->
details == replica->node->details)) {
968 any_created |= replica->child->cmds->create_probe(replica->child,
972 if (replica->container) {
973 bool created = replica->container->cmds->create_probe(replica->container,
992 for (GList *tIter = bundle_data->replicas;
993 tIter && (bundle_data->nreplicas_per_host == 1);
994 tIter = tIter->next) {
995 pe__bundle_replica_t *other = tIter->data;
997 if ((other != replica) && (other != NULL)
998 && (other->container != NULL)) {
1002 NULL, other->container,
1011 if (replica->container && replica->remote
1012 && replica->remote->cmds->create_probe(replica->remote, node,
1023 probe_uuid, NULL, node);
1032 NULL, replica->remote, NULL, probe,
1047 GHashTable *nodes,
const char *attr,
1057 pe__bundle_variant_data_t *bundle_data = NULL;
1061 get_bundle_variant_data(bundle_data, rsc);
1062 for (GList *gIter = bundle_data->replicas; gIter != NULL;
1063 gIter = gIter->next) {
1064 pe__bundle_replica_t *replica = gIter->data;
1070 if (replica->container) {
1071 LogActions(replica->container, data_set, terminal);
1073 if (replica->remote) {
1074 LogActions(replica->remote, data_set, terminal);
1076 if (replica->child) {
1077 LogActions(replica->child, data_set, terminal);