34 #define set_config_flag(data_set, option, flag) do { \
35 const char *tmp = pe_pref(data_set->config_hash, option); \
37 if(crm_is_true(tmp)) { \
38 set_bit(data_set->flags, flag); \
40 clear_bit(data_set->flags, flag); \
50 is_dangling_container_remote_node(
node_t *node)
74 crm_warn(
"Guest node %s will be fenced (by recovering %s) %s",
80 }
else if (is_dangling_container_remote_node(node)) {
81 crm_info(
"Cleaning up dangling connection resource for guest node %s %s"
82 " (fencing is already done, guest resource no longer exists)",
110 const char *value = NULL;
111 GHashTable *config_hash =
114 xmlXPathObjectPtr xpathObj = NULL;
117 xpathObj =
xpath_search(data_set->
input,
"//nvpair[@name='provides' and @value='unfencing']");
118 if(xpathObj && numXpathResults(xpathObj) > 0) {
125 xpathObj =
xpath_search(data_set->
input,
"//nvpair[@name='requires' and @value='unfencing']");
126 if(xpathObj && numXpathResults(xpathObj) > 0) {
133 #ifdef REDHAT_COMPAT_6
136 if(xpathObj && numXpathResults(xpathObj) > 0) {
152 crm_info(
"Startup probes: disabled (dangerous)");
157 crm_notice(
"Relying on watchdog integration for fencing");
166 crm_debug(
"STONITH of failed nodes is %s",
177 crm_debug(
"Stop all active resources: %s",
182 crm_debug(
"Cluster is symmetric" " - resources can run anywhere by default");
198 gboolean do_panic = FALSE;
204 (
"Setting no-quorum-policy=suicide makes no sense if stonith-enabled=false");
211 crm_notice(
"Resetting no-quorum-policy to 'stop': The cluster has never had quorum");
221 crm_debug(
"On loss of CCM Quorum: Freeze resources");
224 crm_debug(
"On loss of CCM Quorum: Stop ALL resources");
227 crm_notice(
"On loss of CCM Quorum: Fence all remaining nodes");
239 crm_trace(
"Orphan resource actions are %s",
243 crm_trace(
"Stopped resources are removed from the status section: %s",
255 crm_trace(
"By default resources are %smanaged",
260 is_set(data_set->
flags,
267 crm_debug(
"Node scores: 'red' = %s, 'yellow' = %s, 'green' = %s",
279 destroy_digest_cache(gpointer ptr)
301 " - this is rarely intended", uname);
304 new_node = calloc(1,
sizeof(
node_t));
305 if (new_node == NULL) {
310 new_node->
fixed = FALSE;
313 if (new_node->
details == NULL) {
318 crm_trace(
"Creating node for entry %s/%s", uname,
id);
330 }
else if (type == NULL ||
safe_str_eq(type,
"member")
340 g_hash_table_insert(new_node->
details->
attrs, strdup(
"#kind"), strdup(
"remote"));
342 g_hash_table_insert(new_node->
details->
attrs, strdup(
"#kind"), strdup(
"cluster"));
351 destroy_digest_cache);
358 expand_remote_rsc_meta(xmlNode *xml_obj, xmlNode *parent, GHashTable **rsc_name_check)
360 xmlNode *xml_rsc = NULL;
361 xmlNode *xml_tmp = NULL;
362 xmlNode *attr_set = NULL;
363 xmlNode *attr = NULL;
365 const char *container_id =
ID(xml_obj);
366 const char *remote_name = NULL;
367 const char *remote_server = NULL;
368 const char *remote_port = NULL;
369 const char *connect_timeout =
"60s";
370 const char *remote_allow_migrate=NULL;
373 for (attr_set = __xml_first_child(xml_obj); attr_set != NULL; attr_set = __xml_next_element(attr_set)) {
378 for (attr = __xml_first_child(attr_set); attr != NULL; attr = __xml_next_element(attr)) {
385 remote_server = value;
388 }
else if (
safe_str_eq(name,
"remote-connect-timeout")) {
389 connect_timeout = value;
390 }
else if (
safe_str_eq(name,
"remote-allow-migrate")) {
391 remote_allow_migrate=value;
396 if (remote_name == NULL) {
400 if (*rsc_name_check == NULL) {
401 *rsc_name_check = g_hash_table_new(
crm_str_hash, g_str_equal);
402 for (xml_rsc = __xml_first_child(parent); xml_rsc != NULL; xml_rsc = __xml_next_element(xml_rsc)) {
403 const char *
id =
ID(xml_rsc);
406 g_hash_table_insert(*rsc_name_check, (
char *)
id, (
char *)
id);
410 if (g_hash_table_lookup(*rsc_name_check, remote_name)) {
412 crm_err(
"Naming conflict with remote-node=%s. remote-nodes can not have the same name as a resource.",
430 tmp_id =
crm_concat(remote_name,
"meta-attributes-container",
'_');
437 tmp_id =
crm_concat(remote_name,
"meta-attributes-internal",
'_');
443 if (remote_allow_migrate) {
445 tmp_id =
crm_concat(remote_name,
"meta-attributes-container",
'_');
454 tmp_id =
crm_concat(remote_name,
"monitor-interval-30s",
'_');
461 if (connect_timeout) {
463 tmp_id =
crm_concat(remote_name,
"start-interval-0",
'_');
471 if (remote_port || remote_server) {
479 tmp_id =
crm_concat(remote_name,
"instance-attributes-addr",
'_');
487 tmp_id =
crm_concat(remote_name,
"instance-attributes-port",
'_');
501 static const char *blind_faith = NULL;
502 static gboolean unseen_are_unclean = TRUE;
514 unseen_are_unclean = FALSE;
515 crm_warn(
"Blind faith: not fencing unseen nodes");
519 || unseen_are_unclean == FALSE) {
538 xmlNode *xml_obj = NULL;
540 const char *
id = NULL;
541 const char *uname = NULL;
542 const char *type = NULL;
543 const char *score = NULL;
545 for (xml_obj = __xml_first_child(xml_nodes); xml_obj != NULL; xml_obj = __xml_next_element(xml_obj)) {
553 crm_trace(
"Processing node %s/%s", uname,
id);
559 new_node = create_node(
id, uname, type, score, data_set);
561 if (new_node == NULL) {
571 handle_startup_fencing(data_set, new_node);
582 crm_info(
"Creating a fake local node");
592 const char *container_id = NULL;
597 for (; gIter != NULL; gIter = gIter->next) {
600 setup_container(child_rsc, data_set);
612 pe_rsc_trace(rsc,
"Resource %s's container is %s", rsc->
id, container_id);
614 pe_err(
"Resource %s: Unknown resource container (%s)", rsc->
id, container_id);
622 xmlNode *xml_obj = NULL;
623 GHashTable *rsc_name_check = NULL;
626 for (xml_obj = __xml_first_child(xml_resources); xml_obj != NULL; xml_obj = __xml_next_element(xml_obj)) {
627 const char *new_node_id = NULL;
632 new_node_id =
ID(xml_obj);
636 crm_trace(
"Found baremetal remote node %s in container resource %s", new_node_id,
ID(xml_obj));
637 create_node(new_node_id, new_node_id,
"remote", NULL, data_set);
652 new_node_id = expand_remote_rsc_meta(xml_obj, xml_resources, &rsc_name_check);
655 crm_trace(
"Found guest remote node %s in container resource %s", new_node_id,
ID(xml_obj));
656 create_node(new_node_id, new_node_id,
"remote", NULL, data_set);
661 xmlNode *xml_obj2 = NULL;
663 for (xml_obj2 = __xml_first_child(xml_obj); xml_obj2 != NULL; xml_obj2 = __xml_next_element(xml_obj2)) {
665 new_node_id = expand_remote_rsc_meta(xml_obj2, xml_resources, &rsc_name_check);
668 crm_trace(
"Found guest remote node %s in container resource %s which is in group %s", new_node_id,
ID(xml_obj2),
ID(xml_obj));
669 create_node(new_node_id, new_node_id,
"remote", NULL, data_set);
674 if (rsc_name_check) {
675 g_hash_table_destroy(rsc_name_check);
693 node_t *remote_node = NULL;
714 handle_startup_fencing(data_set, remote_node);
718 g_hash_table_replace(remote_node->
details->
attrs, strdup(
"#kind"), strdup(
"container"));
723 destroy_tag(gpointer
data)
729 g_list_free_full(tag->
refs, free);
737 xmlNode *xml_obj = NULL;
744 for (xml_obj = __xml_first_child(xml_resources); xml_obj != NULL; xml_obj = __xml_next_element(xml_obj)) {
748 const char *template_id =
ID(xml_obj);
751 template_id, NULL, NULL) == FALSE) {
758 crm_trace(
"Beginning unpack... <%s id=%s... >", crm_element_name(xml_obj),
ID(xml_obj));
770 if (new_rsc != NULL && new_rsc->
fns != NULL) {
776 for (gIter = data_set->
resources; gIter != NULL; gIter = gIter->next) {
779 setup_container(rsc, data_set);
780 link_rsc2remotenode(data_set, rsc);
790 crm_config_err(
"Resource start-up disabled since no STONITH resources have been defined");
791 crm_config_err(
"Either configure some or disable STONITH with the stonith-enabled option");
792 crm_config_err(
"NOTE: Clusters with shared data need STONITH to ensure data integrity");
801 xmlNode *xml_tag = NULL;
806 for (xml_tag = __xml_first_child(xml_tags); xml_tag != NULL; xml_tag = __xml_next_element(xml_tag)) {
807 xmlNode *xml_obj_ref = NULL;
808 const char *tag_id =
ID(xml_tag);
814 if (tag_id == NULL) {
820 for (xml_obj_ref = __xml_first_child(xml_tag); xml_obj_ref != NULL; xml_obj_ref = __xml_next_element(xml_obj_ref)) {
821 const char *obj_ref =
ID(xml_obj_ref);
827 if (obj_ref == NULL) {
828 crm_config_err(
"Failed unpacking %s for tag %s: %s should be specified",
829 crm_element_name(xml_obj_ref), tag_id,
XML_ATTR_ID);
847 const char *ticket_id = NULL;
848 const char *granted = NULL;
849 const char *last_granted = NULL;
850 const char *standby = NULL;
851 xmlAttrPtr xIter = NULL;
855 ticket_id =
ID(xml_ticket);
856 if (ticket_id == NULL || strlen(ticket_id) == 0) {
860 crm_trace(
"Processing ticket state for %s", ticket_id);
862 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
863 if (ticket == NULL) {
865 if (ticket == NULL) {
870 for (xIter = xml_ticket->properties; xIter; xIter = xIter->next) {
871 const char *prop_name = (
const char *)xIter->name;
877 g_hash_table_replace(ticket->
state, strdup(prop_name), strdup(prop_value));
880 granted = g_hash_table_lookup(ticket->
state,
"granted");
886 crm_info(
"We do not have ticket '%s'", ticket->
id);
889 last_granted = g_hash_table_lookup(ticket->
state,
"last-granted");
894 standby = g_hash_table_lookup(ticket->
state,
"standby");
898 crm_info(
"Granted ticket '%s' is in standby-mode", ticket->
id);
904 crm_trace(
"Done with ticket state for %s", ticket_id);
912 xmlNode *xml_obj = NULL;
914 for (xml_obj = __xml_first_child(xml_tickets); xml_obj != NULL; xml_obj = __xml_next_element(xml_obj)) {
918 unpack_ticket_state(xml_obj, data_set);
927 get_ticket_state_legacy(gpointer key, gpointer value, gpointer user_data)
929 const char *long_key = key;
930 char *state_key = NULL;
932 const char *granted_prefix =
"granted-ticket-";
933 const char *last_granted_prefix =
"last-granted-";
934 static int granted_prefix_strlen = 0;
935 static int last_granted_prefix_strlen = 0;
937 const char *ticket_id = NULL;
938 const char *is_granted = NULL;
939 const char *last_granted = NULL;
940 const char *sep = NULL;
945 if (granted_prefix_strlen == 0) {
946 granted_prefix_strlen = strlen(granted_prefix);
949 if (last_granted_prefix_strlen == 0) {
950 last_granted_prefix_strlen = strlen(last_granted_prefix);
953 if (strstr(long_key, granted_prefix) == long_key) {
954 ticket_id = long_key + granted_prefix_strlen;
955 if (strlen(ticket_id)) {
956 state_key = strdup(
"granted");
959 }
else if (strstr(long_key, last_granted_prefix) == long_key) {
960 ticket_id = long_key + last_granted_prefix_strlen;
961 if (strlen(ticket_id)) {
962 state_key = strdup(
"last-granted");
963 last_granted = value;
965 }
else if ((sep = strrchr(long_key,
'-'))) {
967 state_key =
strndup(long_key, strlen(long_key) - strlen(sep));
970 if (ticket_id == NULL || strlen(ticket_id) == 0) {
975 if (state_key == NULL || strlen(state_key) == 0) {
980 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
981 if (ticket == NULL) {
983 if (ticket == NULL) {
989 g_hash_table_replace(ticket->
state, state_key, strdup(value));
997 crm_info(
"We do not have ticket '%s'", ticket->
id);
1000 }
else if (last_granted) {
1011 const char *
id = NULL;
1012 const char *uname = NULL;
1014 xmlNode *state = NULL;
1015 xmlNode *lrm_rsc = NULL;
1016 node_t *this_node = NULL;
1020 if (data_set->
tickets == NULL) {
1025 for (state = __xml_first_child(status); state != NULL; state = __xml_next_element(state)) {
1027 xmlNode *xml_tickets = state;
1028 GHashTable *state_hash = NULL;
1037 state_hash, NULL, TRUE, data_set->
now);
1039 g_hash_table_foreach(state_hash, get_ticket_state_legacy, data_set);
1042 g_hash_table_destroy(state_hash);
1046 unpack_tickets_state(xml_tickets, data_set);
1050 xmlNode *attrs = NULL;
1051 const char *resource_discovery_enabled = NULL;
1057 if (uname == NULL) {
1061 }
else if (this_node == NULL) {
1075 crm_trace(
"Processing node id=%s, uname=%s",
id, uname);
1096 if (resource_discovery_enabled && !
crm_is_true(resource_discovery_enabled)) {
1097 crm_warn(
"ignoring %s attribute on node %s, disabling resource discovery is not allowed on cluster nodes",
1108 pe_fence_node(data_set, this_node,
"because the cluster does not have quorum");
1114 for (state = __xml_first_child(status); state != NULL; state = __xml_next_element(state)) {
1123 if (this_node == NULL) {
1124 crm_info(
"Node %s is unknown",
id);
1133 crm_trace(
"Processing lrm resource entries on healthy node: %s",
1151 const char *
id = NULL;
1152 const char *uname = NULL;
1153 const char *shutdown = NULL;
1157 xmlNode *state = NULL;
1158 xmlNode *lrm_rsc = NULL;
1159 node_t *this_node = NULL;
1167 for (gIter = data_set->
nodes; gIter != NULL; gIter = gIter->next) {
1168 this_node = gIter->data;
1170 if ((this_node == NULL) || (
is_remote_node(this_node) == FALSE)) {
1173 determine_remote_online_status(data_set, this_node);
1177 for (state = __xml_first_child(status); state != NULL; state = __xml_next_element(state)) {
1178 const char *resource_discovery_enabled = NULL;
1179 xmlNode *attrs = NULL;
1188 if ((this_node == NULL) || (
is_remote_node(this_node) == FALSE)) {
1191 crm_trace(
"Processing remote node id=%s, uname=%s",
id, uname);
1220 if (resource_discovery_enabled && !
crm_is_true(resource_discovery_enabled)) {
1222 crm_warn(
"ignoring %s attribute on baremetal remote node %s, disabling resource discovery requires stonith to be enabled.",
1236 for (state = __xml_first_child(status); state != NULL; state = __xml_next_element(state)) {
1245 if ((this_node == NULL) || (
is_remote_node(this_node) == FALSE)) {
1248 crm_trace(
"Processing lrm resource entries on healthy remote node: %s",
1259 determine_online_status_no_fencing(
pe_working_set_t * data_set, xmlNode * node_state,
1262 gboolean online = FALSE;
1275 crm_debug(
"Node is not ready to run resources: %s", join);
1280 crm_trace(
"\tis_peer=%s, join=%s, expected=%s",
1285 pe_fence_node(data_set, this_node,
"because node is unexpectedly down");
1286 crm_info(
"\tin_cluster=%s, is_peer=%s, join=%s, expected=%s",
1293 determine_online_status_fencing(
pe_working_set_t * data_set, xmlNode * node_state,
1296 gboolean online = FALSE;
1297 gboolean do_terminate = FALSE;
1302 const char *terminate = g_hash_table_lookup(this_node->
details->
attrs,
"terminate");
1312 do_terminate = TRUE;
1314 }
else if (terminate != NULL && strlen(terminate) > 0) {
1316 char t = terminate[0];
1318 if (t !=
'0' && isdigit(t)) {
1319 do_terminate = TRUE;
1323 crm_trace(
"%s: in_cluster=%s, is_peer=%s, join=%s, expected=%s, term=%d",
1331 if (exp_state == NULL) {
1341 }
else if (in_cluster == NULL) {
1342 pe_fence_node(data_set, this_node,
"because the peer has not been seen by the cluster");
1345 pe_fence_node(data_set, this_node,
"because it failed the pacemaker membership criteria");
1364 pe_fence_node(data_set, this_node,
"because the node is no longer part of the cluster");
1367 pe_fence_node(data_set, this_node,
"because our peer process is no longer available");
1370 }
else if (do_terminate) {
1371 pe_fence_node(data_set, this_node,
"because termination was requested");
1383 pe_fence_node(data_set, this_node,
"because the peer was in an unknown state");
1384 crm_warn(
"%s: in-cluster=%s, is-peer=%s, join=%s, expected=%s, term=%d, shutdown=%d",
1400 goto remote_online_done;
1409 crm_trace(
"Remote node %s is set to ONLINE. role == started", this_node->
details->
id);
1415 crm_trace(
"Remote node %s shutdown. transition from start to stop role", this_node->
details->
id);
1432 crm_trace(
"Remote node %s is set to OFFLINE. node is stopped.", this_node->
details->
id);
1446 gboolean online = FALSE;
1447 const char *shutdown = NULL;
1450 if (this_node == NULL) {
1474 online = determine_online_status_no_fencing(data_set, node_state, this_node);
1477 online = determine_online_status_fencing(data_set, node_state, this_node);
1485 this_node->
fixed = TRUE;
1491 this_node->
fixed = TRUE;
1521 CRM_CHECK(last_rsc_id != NULL,
return NULL);
1522 lpc = strlen(last_rsc_id);
1524 switch (last_rsc_id[lpc]) {
1526 crm_err(
"Empty string: %s", last_rsc_id);
1541 zero = calloc(1, lpc + 1);
1542 memcpy(zero, last_rsc_id, lpc);
1550 zero = strdup(last_rsc_id);
1560 CRM_CHECK(last_rsc_id != NULL,
return NULL);
1561 if (last_rsc_id != NULL) {
1562 lpc = strlen(last_rsc_id);
1566 switch (last_rsc_id[lpc]) {
1582 zero = calloc(1, lpc + 3);
1583 memcpy(zero, last_rsc_id, lpc);
1585 zero[lpc + 1] =
'0';
1593 lpc = strlen(last_rsc_id);
1594 zero = calloc(1, lpc + 3);
1595 memcpy(zero, last_rsc_id, lpc);
1597 zero[lpc + 1] =
'0';
1599 crm_trace(
"%s -> %s", last_rsc_id, zero);
1604 create_fake_resource(
const char *rsc_id, xmlNode * rsc_entry,
pe_working_set_t * data_set)
1620 crm_debug(
"Detected orphaned remote node %s", rsc_id);
1624 node = create_node(rsc_id, rsc_id,
"remote", NULL, data_set);
1626 link_rsc2remotenode(data_set, rsc);
1629 crm_trace(
"Setting node %s as shutting down due to orphaned connection resource", rsc_id);
1636 crm_trace(
"Detected orphaned container filler %s", rsc_id);
1652 gboolean skip_inactive = FALSE;
1660 for (rIter = parent->
children; rsc == NULL && rIter; rIter = rIter->next) {
1666 if (locations == NULL) {
1671 for (nIter = locations; nIter && rsc == NULL; nIter = nIter->next) {
1672 node_t *childnode = nIter->data;
1685 if (rsc && rsc->running_on) {
1686 crm_notice(
"/Anonymous/ clone %s is already running on %s",
1688 skip_inactive = TRUE;
1693 g_list_free(locations);
1697 if (skip_inactive == FALSE) {
1698 pe_rsc_trace(parent,
"Looking for %s anywhere", rsc_id);
1699 for (rIter = parent->
children; rsc == NULL && rIter; rIter = rIter->next) {
1709 if (locations == NULL) {
1714 g_list_free(locations);
1726 pe_rsc_debug(parent,
"Created orphan %s for %s: %s on %s", top->
id, parent->
id, rsc_id,
1731 pe_rsc_debug(rsc,
"Internally renamed %s on %s to %s%s",
1741 xmlNode * rsc_entry)
1758 crm_trace(
"%s is not known as %s either", rsc_id, tmp);
1764 crm_trace(
"%s not found: %s", rsc_id, parent ? parent->
id :
"orphan");
1767 crm_trace(
"%s is no longer a primitive resource, the lrm_resource entry is obsolete",
1779 rsc = find_anonymous_clone(data_set, node, parent, base);
1800 rsc = create_fake_resource(rsc_id, rsc_entry, data_set);
1821 pe_rsc_trace(rsc,
"Resource %s is %s on %s: on_fail=%s",
1847 char *reason = NULL;
1848 gboolean should_fence = FALSE;
1859 should_fence = TRUE;
1869 reason =
crm_strdup_printf(
"because %s is active there. Fencing will be revoked if remote-node connection can be re-established on another cluster-node.", rsc->
id);
1871 should_fence = TRUE;
1875 if (reason == NULL) {
1899 pe_fence_node(data_set, node,
"because of resource failure(s)");
1955 pe_fence_node(data_set, tmpnode,
"because of connection failure(s)");
1990 " %s must be stopped manually on %s",
2013 for (; gIter != NULL; gIter = gIter->next) {
2019 g_list_free(possible_matches);
2027 int start_index,
int stop_index,
2031 const char *task = NULL;
2032 const char *status = NULL;
2036 pe_rsc_trace(rsc,
"%s: Start index %d, stop index = %d", rsc->
id, start_index, stop_index);
2038 for (; gIter != NULL; gIter = gIter->next) {
2039 xmlNode *rsc_op = (xmlNode *) gIter->data;
2043 const char *
id =
ID(rsc_op);
2044 const char *interval_s = NULL;
2053 }
else if (start_index < stop_index && counter <= stop_index) {
2057 }
else if (counter < start_index) {
2064 if (interval == 0) {
2086 int implied_monitor_start = -1;
2087 int implied_master_start = -1;
2088 const char *task = NULL;
2089 const char *status = NULL;
2095 for (; gIter != NULL; gIter = gIter->next) {
2096 xmlNode *rsc_op = (xmlNode *) gIter->data;
2114 implied_monitor_start =
counter;
2117 implied_master_start =
counter;
2121 if (*start_index == -1) {
2122 if (implied_master_start != -1) {
2123 *start_index = implied_master_start;
2124 }
else if (implied_monitor_start != -1) {
2125 *start_index = implied_monitor_start;
2134 int stop_index = -1;
2135 int start_index = -1;
2138 const char *task = NULL;
2145 xmlNode *migrate_op = NULL;
2146 xmlNode *rsc_op = NULL;
2147 xmlNode *last_failure = NULL;
2153 crm_element_name(rsc_entry), rsc_id, node->
details->
uname);
2157 sorted_op_list = NULL;
2159 for (rsc_op = __xml_first_child(rsc_entry); rsc_op != NULL; rsc_op = __xml_next_element(rsc_op)) {
2161 op_list = g_list_prepend(op_list, rsc_op);
2165 if (op_list == NULL) {
2171 rsc = unpack_find_resource(data_set, node, rsc_id, rsc_entry);
2173 rsc = process_orphan_resource(rsc_entry, node, data_set);
2178 saved_role = rsc->
role;
2183 for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) {
2184 xmlNode *rsc_op = (xmlNode *) gIter->data;
2188 migrate_op = rsc_op;
2191 unpack_rsc_op(rsc, node, rsc_op, &last_failure, &on_fail, data_set);
2196 process_recurring(node, rsc, start_index, stop_index, sorted_op_list, data_set);
2199 g_list_free(sorted_op_list);
2201 process_rsc_state(rsc, node, on_fail, migrate_op, data_set);
2205 pe_rsc_debug(rsc,
"%s: Overwriting calculated next role %s"
2206 " with requested next role %s",
2211 pe_rsc_info(rsc,
"%s: Not overwriting calculated next role %s"
2212 " with requested next role %s",
2217 if (saved_role > rsc->
role) {
2218 rsc->
role = saved_role;
2225 handle_orphaned_container_fillers(xmlNode * lrm_rsc_list,
pe_working_set_t * data_set)
2227 xmlNode *rsc_entry = NULL;
2228 for (rsc_entry = __xml_first_child(lrm_rsc_list); rsc_entry != NULL;
2229 rsc_entry = __xml_next_element(rsc_entry)) {
2234 const char *container_id;
2242 if (container_id == NULL || rsc_id == NULL) {
2247 if (container == NULL) {
2258 pe_rsc_trace(rsc,
"Mapped orphaned rsc %s's container to %s", rsc->
id, container_id);
2267 xmlNode *rsc_entry = NULL;
2268 gboolean found_orphaned_container_filler = FALSE;
2269 GListPtr unexpected_containers = NULL;
2277 for (rsc_entry = __xml_first_child(lrm_rsc_list); rsc_entry != NULL;
2278 rsc_entry = __xml_next_element(rsc_entry)) {
2282 rsc = unpack_lrm_rsc_state(node, rsc_entry, data_set);
2287 found_orphaned_container_filler = TRUE;
2292 unexpected_containers = g_list_append(unexpected_containers, remote);
2301 for (gIter = unexpected_containers; gIter != NULL; gIter = gIter->next) {
2304 crm_warn(
"Recovering container resource %s. Resource is unexpectedly running and involves a remote-node.", remote->
container->
id);
2312 if (found_orphaned_container_filler) {
2313 handle_orphaned_container_fillers(lrm_rsc_list, data_set);
2315 g_list_free(unexpected_containers);
2332 set_node_score(gpointer key, gpointer value, gpointer user_data)
2335 int *score = user_data;
2340 #define STATUS_PATH_MAX 1024
2342 find_lrm_op(
const char *resource,
const char *op,
const char *node,
const char *source,
2348 offset += snprintf(xpath + offset,
STATUS_PATH_MAX - offset,
"//node_state[@uname='%s']", node);
2402 if (stop_op == NULL || stop_id < task_id) {
2403 int from_rc = 0, from_status = 0;
2404 const char *migrate_source =
2406 const char *migrate_target =
2411 xmlNode *migrate_from =
2419 pe_rsc_trace(rsc,
"%s op on %s exited with status=%d, rc=%d",
2420 ID(migrate_from), migrate_target, from_status, from_rc);
2425 pe_rsc_trace(rsc,
"Detected dangling migration op: %s on %s",
ID(xml_op),
2435 }
else if (migrate_from) {
2437 pe_rsc_trace(rsc,
"Marking active on %s %p %d", migrate_target, target,
2444 pe_rsc_trace(rsc,
"Marking active on %s %p %d", migrate_target, target,
2480 xmlNode *migrate_op =
2494 if (stop_op == NULL || stop_id < migrate_id) {
2510 xmlNode *migrate_op =
2524 if (stop_op == NULL || stop_id < migrate_id) {
2527 pe_rsc_trace(rsc,
"Stop: %p %d, Migrated: %p %d", stop_op, stop_id, migrate_op,
2533 }
else if (migrate_op == NULL) {
2543 xmlNode *xIter = NULL;
2550 for (xIter = data_set->
failed->children; xIter; xIter = xIter->next) {
2565 static const char *get_op_key(xmlNode *xml_op)
2575 unpack_rsc_op_failure(
resource_t * rsc,
node_t * node,
int rc, xmlNode * xml_op, xmlNode ** last_failure,
2579 bool is_probe = FALSE;
2582 const char *key = get_op_key(xml_op);
2588 *last_failure = xml_op;
2597 crm_warn(
"Processing failed op %s for %s on %s: %s (%d)",
2598 task, rsc->
id, node->
details->
uname, services_ocf_exitcode_str(rc),
2601 record_failed_op(xml_op, node, data_set);
2604 crm_trace(
"Processing failed op %s for %s on %s: %s (%d)",
2605 task, rsc->
id, node->
details->
uname, services_ocf_exitcode_str(rc),
2609 action =
custom_action(rsc, strdup(key), task, NULL, TRUE, FALSE, data_set);
2623 unpack_rsc_migration_failure(rsc, node, xml_op, data_set);
2639 crm_warn(
"Forcing %s to stop after a failed demote action", rsc->
id);
2658 pe_rsc_trace(rsc,
"Resource %s: role=%s, unclean=%s, on_fail=%s, fail_role=%s",
2683 crm_warn(
"Making sure %s doesn't come up again", fail_rsc->
id);
2687 g_hash_table_foreach(fail_rsc->
allowed_nodes, set_node_score, &score);
2694 determine_op_status(
2700 const char *key = get_op_key(xml_op);
2703 bool is_probe = FALSE;
2711 if (target_rc >= 0 && target_rc != rc) {
2713 pe_rsc_debug(rsc,
"%s on %s returned '%s' (%d) instead of the expected value: '%s' (%d)",
2715 services_ocf_exitcode_str(rc), rc,
2716 services_ocf_exitcode_str(target_rc), target_rc);
2724 if (is_probe && target_rc == 7) {
2727 pe_rsc_info(rsc,
"Operation %s found resource %s active on %s",
2756 pe_rsc_info(rsc,
"Operation %s found resource %s active in master mode on %s",
2759 }
else if (target_rc == rc) {
2762 }
else if (target_rc >= 0) {
2770 crm_err(
"%s reported %s in master mode on %s",
2798 pe_proc_err(
"No further recovery can be attempted for %s: %s action failed with '%s' (%d)",
2799 rsc->
id, task, services_ocf_exitcode_str(rc), rc);
2808 crm_info(
"Treating %s (rc=%d) on %s as an ERROR",
2819 bool expired = FALSE;
2820 time_t last_failure = 0;
2821 int clear_failcount = 0;
2824 const char *key = get_op_key(xml_op);
2846 if (strstr(
ID(xml_op),
"last_failure")) {
2847 crm_info(
"Waiting to clear monitor failure for remote node %s until fencing has occurred", rsc->
id);
2851 failure_timeout = 0;
2856 if (failure_timeout > 0) {
2862 if (now > (last_run + failure_timeout)) {
2869 if (failure_timeout > 0) {
2873 clear_failcount = 1;
2881 clear_failcount = 1;
2885 }
else if (strstr(
ID(xml_op),
"last_failure") &&
2886 ((strcmp(task,
"start") == 0) || (strcmp(task,
"monitor") == 0))) {
2893 crm_trace(
"rsc op %s/%s on node %s does not have a op digest to compare against", rsc->
id,
2896 clear_failcount = 1;
2898 (
"Clearing failcount for %s on %s, %s failed and now resource parameters have changed.",
2903 if (clear_failcount) {
2932 char *dummy_string = NULL;
2957 update_resource_state(
resource_t * rsc,
node_t * node, xmlNode * xml_op,
const char * task,
int rc,
2960 gboolean clear_past_failure = FALSE;
2966 clear_past_failure = TRUE;
2973 const char *op_key = get_op_key(xml_op);
2974 const char *last_failure_key = get_op_key(last_failure);
2977 clear_past_failure = TRUE;
2987 clear_past_failure = TRUE;
2991 clear_past_failure = TRUE;
2995 clear_past_failure = TRUE;
3003 clear_past_failure = TRUE;
3006 unpack_rsc_migration(rsc, node, xml_op, data_set);
3014 if (clear_past_failure) {
3020 pe_rsc_trace(rsc,
"%s.%s is not cleared by a completed stop",
3051 const char *key = NULL;
3052 const char *task = NULL;
3053 const char *task_key = NULL;
3060 gboolean expired = FALSE;
3066 CRM_CHECK(xml_op != NULL,
return FALSE);
3068 task_key = get_op_key(xml_op);
3091 pe_rsc_trace(rsc,
"Unpacking task %s/%s (call_id=%d, status=%d, rc=%d) on %s (role=%s)",
3095 pe_rsc_trace(rsc,
"Node %s (where %s is running) is unclean."
3096 " Further action depends on the value of the stop's on-fail attribue",
3106 expired = check_operation_expiry(rsc, node, rc, xml_op, data_set);
3116 record_failed_op(xml_op, node, data_set);
3125 record_failed_op(xml_op, node, data_set);
3129 if (expired && target_rc != rc) {
3132 pe_rsc_debug(rsc,
"Expired operation '%s' on %s returned '%s' (%d) instead of the expected value: '%s' (%d)",
3134 services_ocf_exitcode_str(rc), rc,
3135 services_ocf_exitcode_str(target_rc), target_rc);
3138 crm_notice(
"Ignoring expired calculated failure %s (rc=%d, magic=%s) on %s",
3143 crm_notice(
"Re-initiated expired calculated failure %s (rc=%d, magic=%s) on %s",
3152 status = determine_op_status(rsc, rc, target_rc, node, xml_op, on_fail, data_set);
3159 pe_err(
"Don't know what to do for cancelled ops yet");
3197 update_resource_state(rsc, node, xml_op, task, rc, *last_failure, on_fail, data_set);
3201 failure_strategy = get_action_on_fail(rsc, task_key, task, data_set);
3203 crm_warn(
"Cannot ignore failed %s (status=%d, rc=%d) on %s: "
3204 "Resource agent doesn't exist",
3210 unpack_rsc_op_failure(rsc, node, rc, xml_op, last_failure, on_fail, data_set);
3219 failure_strategy = get_action_on_fail(rsc, task_key, task, data_set);
3224 crm_warn(
"Pretending the failure of %s (rc=%d) on %s succeeded",
3227 update_resource_state(rsc, node, xml_op, task, target_rc, *last_failure, on_fail, data_set);
3231 record_failed_op(xml_op, node, data_set);
3234 *on_fail = failure_strategy;
3238 unpack_rsc_op_failure(rsc, node, rc, xml_op, last_failure, on_fail, data_set);
3242 "Preventing %s from re-starting on %s: operation %s failed '%s' (%d)",
3244 task, services_ocf_exitcode_str(rc), rc);
3249 crm_err(
"Preventing %s from re-starting anywhere: operation %s failed '%s' (%d)",
3250 parent->
id, task, services_ocf_exitcode_str(rc), rc);
3266 const char *cluster_name = NULL;
3282 cluster_name = g_hash_table_lookup(data_set->
config_hash,
"cluster-name");
3284 g_hash_table_insert(node->
details->
attrs, strdup(
"#cluster-name"), strdup(cluster_name));
3290 if (g_hash_table_lookup(node->
details->
attrs,
"#site-name") == NULL) {
3291 const char *site_name = g_hash_table_lookup(node->
details->
attrs,
"site-name");
3295 g_hash_table_insert(node->
details->
attrs, strdup(
"#site-name"), strdup(site_name));
3297 }
else if (cluster_name) {
3299 g_hash_table_insert(node->
details->
attrs, strdup(
"#site-name"), strdup(cluster_name));
3306 extract_operations(
const char *node,
const char *rsc, xmlNode * rsc_entry, gboolean active_filter)
3309 int stop_index = -1;
3310 int start_index = -1;
3312 xmlNode *rsc_op = NULL;
3320 sorted_op_list = NULL;
3322 for (rsc_op = __xml_first_child(rsc_entry); rsc_op != NULL; rsc_op = __xml_next_element(rsc_op)) {
3326 op_list = g_list_prepend(op_list, rsc_op);
3330 if (op_list == NULL) {
3338 if (active_filter == FALSE) {
3339 return sorted_op_list;
3346 for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) {
3347 xmlNode *rsc_op = (xmlNode *) gIter->data;
3351 if (start_index < stop_index) {
3352 crm_trace(
"Skipping %s: not active",
ID(rsc_entry));
3355 }
else if (counter < start_index) {
3359 op_list = g_list_append(op_list, rsc_op);
3362 g_list_free(sorted_op_list);
3373 xmlNode *tmp = NULL;
3376 node_t *this_node = NULL;
3378 xmlNode *node_state = NULL;
3380 for (node_state = __xml_first_child(status); node_state != NULL;
3381 node_state = __xml_next_element(node_state)) {
3391 if(this_node == NULL) {
3396 determine_remote_online_status(data_set, this_node);
3407 xmlNode *lrm_rsc = NULL;
3412 for (lrm_rsc = __xml_first_child(tmp); lrm_rsc != NULL;
3413 lrm_rsc = __xml_next_element(lrm_rsc)) {
3422 intermediate = extract_operations(uname, rsc_id, lrm_rsc, active_filter);
3423 output = g_list_concat(output, intermediate);
gboolean unpack_config(xmlNode *config, pe_working_set_t *data_set)
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
gboolean unpack_rsc_op(resource_t *rsc, node_t *node, xmlNode *xml_op, xmlNode **last_failure, enum action_fail_response *failed, pe_working_set_t *data_set)
void verify_pe_options(GHashTable *options)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
#define crm_notice(fmt, args...)
#define CRMD_ACTION_MIGRATED
node_t *(* location)(resource_t *, GListPtr *, gboolean)
#define pe_rsc_debug(rsc, fmt, args...)
#define pe_flag_have_stonith_resource
gboolean safe_str_neq(const char *a, const char *b)
gint sort_rsc_priority(gconstpointer a, gconstpointer b)
gboolean determine_online_status(xmlNode *node_state, node_t *this_node, pe_working_set_t *data_set)
gboolean get_target_role(resource_t *rsc, enum rsc_role_e *role)
#define XML_NODE_IS_FENCED
#define XML_ATTR_TRANSITION_MAGIC
node_t * node_copy(const node_t *this_node)
gboolean unpack_remote_status(xmlNode *status, pe_working_set_t *data_set)
#define stop_action(rsc, node, optional)
#define pe_flag_enable_unfencing
#define pe_rsc_orphan_container_filler
int default_resource_stickiness
char * clone_strip(const char *last_rsc_id)
#define XML_ATTR_QUORUM_PANIC
bool pe_can_fence(pe_working_set_t *data_set, node_t *node)
#define XML_TAG_UTILIZATION
#define pe_flag_have_remote_nodes
#define XML_RULE_ATTR_SCORE
#define XML_BOOLEAN_FALSE
#define crm_config_err(fmt...)
int get_target_rc(xmlNode *xml_op)
enum action_fail_response on_fail
resource_t * rsc_contains_remote_node(pe_working_set_t *data_set, resource_t *rsc)
int char2score(const char *score)
#define pe_proc_warn(fmt...)
#define XML_TAG_TRANSIENT_NODEATTRS
#define CRMD_ACTION_NOTIFY
#define pe_flag_startup_probes
long long crm_get_msec(const char *input)
GListPtr find_actions(GListPtr input, const char *key, const node_t *on_node)
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
enum pe_obj_types variant
void(* free)(resource_t *)
#define XML_LRM_ATTR_INTERVAL
#define XML_LRM_TAG_RESOURCE
#define pe_flag_stop_rsc_orphans
node_t * partial_migration_source
#define CRMD_ACTION_PROMOTE
int crm_parse_int(const char *text, const char *default_text)
#define XML_NVPAIR_ATTR_NAME
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
#define XML_NODE_EXPECTED
node_t * pe_find_node(GListPtr node_list, const char *uname)
#define XML_CIB_TAG_RSC_TEMPLATE
resource_t * create_child_clone(resource_t *rsc, int sub_id, pe_working_set_t *data_set)
void g_hash_destroy_str(gpointer data)
time_t get_effective_time(pe_working_set_t *data_set)
no_quorum_policy_t no_quorum_policy
#define CRM_LOG_ASSERT(expr)
const char * pe_pref(GHashTable *options, const char *name)
resource_t * uber_parent(resource_t *rsc)
#define clear_bit(word, bit)
void copy_in_properties(xmlNode *target, xmlNode *src)
#define CRMD_JOINSTATE_NACK
#define XML_CIB_TAG_NVPAIR
#define pe_rsc_allow_migrate
resource_t *(* find_rsc)(resource_t *parent, const char *search, node_t *node, int flags)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
#define pe_proc_err(fmt...)
char * strndup(const char *str, size_t len)
#define XML_CIB_TAG_PROPSET
gboolean decode_transition_key(const char *key, char **uuid, int *action, int *transition_id, int *target_rc)
gboolean unpack_resources(xmlNode *xml_resources, pe_working_set_t *data_set)
#define CRMD_ACTION_START
#define XML_LRM_ATTR_TASK_KEY
#define XML_TAG_ATTR_SETS
#define XML_LRM_ATTR_TASK
const char * role2text(enum rsc_role_e role)
gboolean is_remote_node(node_t *node)
#define CRM_OP_CLEAR_FAILCOUNT
struct node_shared_s * details
gboolean unpack_status(xmlNode *status, pe_working_set_t *data_set)
#define CRMD_JOINSTATE_DOWN
#define crm_warn(fmt, args...)
#define CRMD_ACTION_DEMOTE
#define set_bit(word, bit)
#define crm_atoi(text, default_text)
#define crm_debug(fmt, args...)
void native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
#define XML_CIB_ATTR_SHUTDOWN
#define XML_RSC_ATTR_CONTAINER
#define XML_CIB_TAG_RESOURCE
gboolean unpack_nodes(xmlNode *xml_nodes, pe_working_set_t *data_set)
int get_failcount_full(node_t *node, resource_t *rsc, time_t *last_failure, bool effective, xmlNode *xml_op, pe_working_set_t *data_set)
#define XML_CIB_TAG_STATE
node_t * partial_migration_target
resource_object_functions_t * fns
GHashTable * allowed_nodes
GHashTable * digest_cache
#define set_config_flag(data_set, option, flag)
#define crm_trace(fmt, args...)
#define CRMD_JOINSTATE_MEMBER
#define do_crm_log(level, fmt, args...)
Log a message.
enum rsc_digest_cmp_val rc
gboolean is_baremetal_remote_node(node_t *node)
char * digest_secure_calc
gboolean unpack_remote_nodes(xmlNode *xml_resources, pe_working_set_t *data_set)
gboolean add_node_attrs(xmlNode *xml_obj, node_t *node, gboolean overwrite, pe_working_set_t *data_set)
gboolean is_container_remote_node(node_t *node)
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
const char * stonith_action
#define crm_log_xml_debug(xml, text)
#define XML_AGENT_ATTR_PROVIDER
#define XML_TAG_META_SETS
Wrappers for and extensions to libxml2.
#define XML_ATTR_TE_NOWAIT
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
char * clone_zero(const char *last_rsc_id)
const char * crm_element_value(xmlNode *data, const char *name)
action_t * custom_action(resource_t *rsc, char *key, const char *task, node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
#define pe_flag_maintenance_mode
#define XML_LRM_ATTR_MIGRATE_TARGET
#define CIB_OPTIONS_FIRST
#define XML_RSC_ATTR_REMOTE_NODE
#define XML_LRM_ATTR_RESTART_DIGEST
GListPtr dangling_migrations
void free_xml(xmlNode *child)
#define pe_flag_stop_everything
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
const char * placement_strategy
int remote_reconnect_interval
#define crm_config_warn(fmt...)
#define XML_ATTR_TRANSITION_KEY
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
GHashTable * node_hash_from_list(GListPtr list)
gboolean xml_contains_remote_node(xmlNode *xml)
node_t * pe_find_node_any(GListPtr node_list, const char *id, const char *uname)
const char * fail2text(enum action_fail_response fail)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define pe_flag_quick_location
#define pe_rsc_start_pending
#define XML_LRM_TAG_RESOURCES
#define crm_err(fmt, args...)
#define XML_CIB_TAG_TICKET_STATE
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
void pe_fence_node(pe_working_set_t *data_set, node_t *node, const char *reason)
ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
enum rsc_role_e next_role
#define XML_ATTR_HAVE_WATCHDOG
#define XML_NODE_ATTR_RSC_DISCOVERY
int compare_version(const char *version1, const char *version2)
gboolean rsc_discovery_enabled
#define pe_flag_remove_after_stop
#define pe_rsc_failure_ignored
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
#define XML_NVPAIR_ATTR_VALUE
enum rsc_role_e fail_role
gboolean remote_requires_reset
#define XML_RSC_ATTR_INTERNAL_RSC
#define XML_ATTR_CRM_VERSION
#define XML_LRM_ATTR_OPSTATUS
gboolean unpack_lrm_resources(node_t *node, xmlNode *lrm_rsc_list, pe_working_set_t *data_set)
#define CRMD_JOINSTATE_PENDING
enum pe_action_flags flags
GListPtr find_operations(const char *rsc, const char *node, gboolean active_filter, pe_working_set_t *data_set)
#define XML_NODE_JOIN_STATE
void pe_free_action(action_t *action)
#define pe_flag_have_quorum
void destroy_ticket(gpointer data)
#define XML_CIB_TAG_STATUS
#define XML_CIB_TAG_OBJ_REF
void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now)
#define pe_flag_is_managed_default
gboolean remote_was_fenced
#define XML_NODE_IN_CLUSTER
#define pe_flag_stop_action_orphans
gboolean crm_is_true(const char *s)
void calculate_active_ops(GListPtr sorted_op_list, int *start_index, int *stop_index)
#define XML_CIB_TAG_GROUP
CRM_TRACE_INIT_DATA(pe_status)
#define XML_LRM_TAG_RSC_OP
#define pe_rsc_trace(rsc, fmt, args...)
#define pe_flag_symmetric_cluster
char * crm_concat(const char *prefix, const char *suffix, char join)
char * generate_op_key(const char *rsc_id, const char *op_type, int interval)
void print_resource(int log_level, const char *pre_text, resource_t *rsc, gboolean details)
gboolean unpack_tags(xmlNode *xml_tags, pe_working_set_t *data_set)
resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
#define safe_str_eq(a, b)
op_digest_cache_t * rsc_action_digest_cmp(resource_t *rsc, xmlNode *xml_op, node_t *node, pe_working_set_t *data_set)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define XML_LRM_ATTR_MIGRATE_SOURCE
void freeXpathObject(xmlXPathObjectPtr xpathObj)
gint sort_node_uname(gconstpointer a, gconstpointer b)
#define XML_CIB_TAG_TICKETS
#define crm_info(fmt, args...)
char * digest_restart_calc
GHashTable * template_rsc_sets
#define pe_rsc_unexpectedly_running
#define pe_flag_concurrent_fencing
#define XML_OP_ATTR_ALLOW_MIGRATE
#define pe_flag_start_failure_fatal
#define pe_flag_stonith_enabled
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
#define XML_AGENT_ATTR_CLASS
#define CRMD_ACTION_STATUS