30 #define set_config_flag(data_set, option, flag) do { \
31 const char *tmp = pe_pref(data_set->config_hash, option); \
33 if(crm_is_true(tmp)) { \
34 set_bit(data_set->flags, flag); \
36 clear_bit(data_set->flags, flag); \
42 xmlNode **last_failure,
46 static void add_node_attrs(xmlNode *attrs,
pe_node_t *node,
bool overwrite,
54 is_dangling_guest_node(
node_t *node)
89 "(otherwise would because %s): "
90 "its guest resource %s is unmanaged",
93 crm_warn(
"Guest node %s will be fenced "
94 "(by recovering its guest resource %s): %s",
107 }
else if (is_dangling_guest_node(node)) {
108 crm_info(
"Cleaning up dangling connection for guest node %s: "
109 "fencing was already done because %s, "
110 "and guest resource no longer exists",
120 "(otherwise would because %s): connection is unmanaged",
126 pe_can_fence(data_set, node)?
"will be fenced" :
"is unclean",
133 crm_trace(
"Cluster node %s %s because %s",
135 pe_can_fence(data_set, node)?
"would also be fenced" :
"also is unclean",
141 pe_can_fence(data_set, node)?
"will be fenced" :
"is unclean",
151 #define XPATH_UNFENCING_NVPAIR XML_CIB_TAG_NVPAIR \
152 "[(@" XML_NVPAIR_ATTR_NAME "='" XML_RSC_ATTR_PROVIDES "'" \
153 "or @" XML_NVPAIR_ATTR_NAME "='" XML_RSC_ATTR_REQUIRES "') " \
154 "and @" XML_NVPAIR_ATTR_VALUE "='unfencing']"
157 #define XPATH_ENABLE_UNFENCING \
158 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES \
159 "//" XML_TAG_META_SETS "/" XPATH_UNFENCING_NVPAIR \
160 "|/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RSCCONFIG \
161 "/" XML_TAG_META_SETS "/" XPATH_UNFENCING_NVPAIR
164 void set_if_xpath(
unsigned long long flag,
const char *xpath,
167 xmlXPathObjectPtr result = NULL;
169 if (is_not_set(data_set->
flags, flag)) {
171 if (result && (numXpathResults(result) > 0)) {
181 const char *value = NULL;
182 GHashTable *config_hash = crm_str_table_new();
193 crm_info(
"Startup probes: disabled (dangerous)");
198 crm_notice(
"Watchdog will be used via SBD if fencing is required "
199 "and stonith-watchdog-timeout is nonzero");
213 crm_debug(
"STONITH of failed nodes is %s",
219 "Support for stonith-action of 'poweroff' is deprecated "
220 "and will be removed in a future release (use 'off' instead)");
230 crm_debug(
"Stop all active resources: %s",
235 crm_debug(
"Cluster is symmetric" " - resources can run anywhere by default");
258 crm_notice(
"Resetting no-quorum-policy to 'stop': cluster has never had quorum");
262 crm_config_err(
"Resetting no-quorum-policy to 'stop': stonith is not configured");
272 crm_debug(
"On loss of quorum: Freeze resources");
275 crm_debug(
"On loss of quorum: Stop ALL resources");
279 "Demote promotable resources and stop other resources");
282 crm_notice(
"On loss of quorum: Fence all remaining nodes");
294 crm_trace(
"Orphan resource actions are %s",
298 crm_trace(
"Stopped resources are removed from the status section: %s",
307 is_set(data_set->
flags,
314 crm_trace(
"Unseen nodes will be fenced");
323 crm_debug(
"Node scores: 'red' = %s, 'yellow' = %s, 'green' = %s",
335 destroy_digest_cache(gpointer ptr)
343 free(
data->digest_all_calc);
344 free(
data->digest_restart_calc);
345 free(
data->digest_secure_calc);
358 " - this is rarely intended",
uname);
361 new_node = calloc(1,
sizeof(
node_t));
362 if (new_node == NULL) {
367 new_node->
fixed = FALSE;
370 if (new_node->
details == NULL) {
405 destroy_digest_cache);
418 if (
data->name_check == NULL) {
420 for (xml_rsc = __xml_first_child_element(parent); xml_rsc != NULL;
421 xml_rsc = __xml_next_element(xml_rsc)) {
423 const char *
id =
ID(xml_rsc);
426 g_hash_table_insert(
data->name_check, (
char *)
id, (
char *)
id);
429 if (g_hash_table_lookup(
data->name_check, remote_name)) {
434 crm_err(
"Invalid remote-node name, a resource called '%s' already exists.", remote_name);
445 xmlNode *attr_set = NULL;
446 xmlNode *attr = NULL;
448 const char *container_id =
ID(xml_obj);
449 const char *remote_name = NULL;
450 const char *remote_server = NULL;
451 const char *remote_port = NULL;
452 const char *connect_timeout =
"60s";
453 const char *remote_allow_migrate=NULL;
454 const char *is_managed = NULL;
456 for (attr_set = __xml_first_child_element(xml_obj); attr_set != NULL;
457 attr_set = __xml_next_element(attr_set)) {
462 for (attr = __xml_first_child_element(attr_set); attr != NULL;
463 attr = __xml_next_element(attr)) {
470 remote_server = value;
473 }
else if (
safe_str_eq(name,
"remote-connect-timeout")) {
474 connect_timeout = value;
475 }
else if (
safe_str_eq(name,
"remote-allow-migrate")) {
476 remote_allow_migrate=value;
483 if (remote_name == NULL) {
492 remote_allow_migrate, is_managed,
493 connect_timeout, remote_server, remote_port);
525 xmlNode *xml_obj = NULL;
527 const char *
id = NULL;
528 const char *
uname = NULL;
529 const char *
type = NULL;
530 const char *score = NULL;
532 for (xml_obj = __xml_first_child_element(xml_nodes); xml_obj != NULL;
533 xml_obj = __xml_next_element(xml_obj)) {
550 if (new_node == NULL) {
560 handle_startup_fencing(data_set, new_node);
562 add_node_attrs(xml_obj, new_node, FALSE, data_set);
572 crm_info(
"Creating a fake local node");
583 const char *container_id = NULL;
588 for (; gIter != NULL; gIter = gIter->next) {
591 setup_container(child_rsc, data_set);
604 pe_rsc_trace(rsc,
"Resource %s's container is %s", rsc->
id, container_id);
606 pe_err(
"Resource %s: Unknown resource container (%s)", rsc->
id, container_id);
614 xmlNode *xml_obj = NULL;
619 for (xml_obj = __xml_first_child_element(xml_resources); xml_obj != NULL;
620 xml_obj = __xml_next_element(xml_obj)) {
622 const char *new_node_id = NULL;
628 new_node_id =
ID(xml_obj);
632 crm_trace(
"Found remote node %s defined by resource %s",
633 new_node_id,
ID(xml_obj));
648 new_node_id = expand_remote_rsc_meta(xml_obj, xml_resources, data_set);
650 crm_trace(
"Found guest node %s in resource %s",
651 new_node_id,
ID(xml_obj));
662 xmlNode *xml_obj2 = NULL;
663 for (xml_obj2 = __xml_first_child_element(xml_obj); xml_obj2 != NULL;
664 xml_obj2 = __xml_next_element(xml_obj2)) {
666 new_node_id = expand_remote_rsc_meta(xml_obj2, xml_resources, data_set);
669 crm_trace(
"Found guest node %s in resource %s inside group %s",
670 new_node_id,
ID(xml_obj2),
ID(xml_obj));
691 node_t *remote_node = NULL;
705 pe_rsc_trace(new_rsc,
"Linking remote connection resource %s to node %s",
713 handle_startup_fencing(data_set, remote_node);
720 strdup(
"container"));
725 destroy_tag(gpointer
data)
731 g_list_free_full(tag->
refs, free);
751 xmlNode *xml_obj = NULL;
758 for (xml_obj = __xml_first_child_element(xml_resources); xml_obj != NULL;
759 xml_obj = __xml_next_element(xml_obj)) {
764 const char *template_id =
ID(xml_obj);
767 template_id, NULL, NULL) == FALSE) {
774 crm_trace(
"Beginning unpack... <%s id=%s... >", crm_element_name(xml_obj),
ID(xml_obj));
782 if (new_rsc != NULL && new_rsc->
fns != NULL) {
788 for (gIter = data_set->
resources; gIter != NULL; gIter = gIter->next) {
791 setup_container(rsc, data_set);
792 link_rsc2remotenode(data_set, rsc);
802 crm_config_err(
"Resource start-up disabled since no STONITH resources have been defined");
803 crm_config_err(
"Either configure some or disable STONITH with the stonith-enabled option");
804 crm_config_err(
"NOTE: Clusters with shared data need STONITH to ensure data integrity");
813 xmlNode *xml_tag = NULL;
818 for (xml_tag = __xml_first_child_element(xml_tags); xml_tag != NULL;
819 xml_tag = __xml_next_element(xml_tag)) {
821 xmlNode *xml_obj_ref = NULL;
822 const char *tag_id =
ID(xml_tag);
828 if (tag_id == NULL) {
834 for (xml_obj_ref = __xml_first_child_element(xml_tag); xml_obj_ref != NULL;
835 xml_obj_ref = __xml_next_element(xml_obj_ref)) {
837 const char *obj_ref =
ID(xml_obj_ref);
843 if (obj_ref == NULL) {
844 crm_config_err(
"Failed unpacking %s for tag %s: %s should be specified",
845 crm_element_name(xml_obj_ref), tag_id,
XML_ATTR_ID);
863 const char *ticket_id = NULL;
864 const char *granted = NULL;
865 const char *last_granted = NULL;
866 const char *standby = NULL;
867 xmlAttrPtr xIter = NULL;
871 ticket_id =
ID(xml_ticket);
872 if (ticket_id == NULL || strlen(ticket_id) == 0) {
876 crm_trace(
"Processing ticket state for %s", ticket_id);
878 ticket = g_hash_table_lookup(data_set->
tickets, ticket_id);
879 if (ticket == NULL) {
881 if (ticket == NULL) {
886 for (xIter = xml_ticket->properties; xIter; xIter = xIter->next) {
887 const char *prop_name = (
const char *)xIter->name;
893 g_hash_table_replace(ticket->
state, strdup(prop_name), strdup(prop_value));
896 granted = g_hash_table_lookup(ticket->
state,
"granted");
902 crm_info(
"We do not have ticket '%s'", ticket->
id);
905 last_granted = g_hash_table_lookup(ticket->
state,
"last-granted");
910 standby = g_hash_table_lookup(ticket->
state,
"standby");
914 crm_info(
"Granted ticket '%s' is in standby-mode", ticket->
id);
920 crm_trace(
"Done with ticket state for %s", ticket_id);
928 xmlNode *xml_obj = NULL;
930 for (xml_obj = __xml_first_child_element(xml_tickets); xml_obj != NULL;
931 xml_obj = __xml_next_element(xml_obj)) {
936 unpack_ticket_state(xml_obj, data_set);
945 const char *resource_discovery_enabled = NULL;
946 xmlNode *attrs = NULL;
967 add_node_attrs(attrs, this_node, TRUE, data_set);
989 if (resource_discovery_enabled && !
crm_is_true(resource_discovery_enabled)) {
992 crm_warn(
"Ignoring %s attribute on remote node %s because stonith is disabled",
1007 unpack_node_loop(xmlNode * status,
bool fence,
pe_working_set_t * data_set)
1009 bool changed =
false;
1010 xmlNode *lrm_rsc = NULL;
1012 for (xmlNode *state = __xml_first_child_element(status); state != NULL;
1013 state = __xml_next_element(state)) {
1015 const char *
id = NULL;
1016 const char *
uname = NULL;
1017 node_t *this_node = NULL;
1018 bool process = FALSE;
1028 if (this_node == NULL) {
1029 crm_info(
"Node %s is unknown",
id);
1033 crm_info(
"Node %s is already processed",
id);
1048 }
else if(rsc == NULL) {
1067 determine_remote_online_status(data_set, this_node);
1068 unpack_handle_remote_attrs(this_node, state, data_set);
1080 crm_trace(
"Processing lrm resource entries on %shealthy%s node: %s",
1101 const char *
id = NULL;
1102 const char *
uname = NULL;
1104 xmlNode *state = NULL;
1105 node_t *this_node = NULL;
1109 if (data_set->
tickets == NULL) {
1114 for (state = __xml_first_child_element(status); state != NULL;
1115 state = __xml_next_element(state)) {
1118 unpack_tickets_state((xmlNode *) state, data_set);
1121 xmlNode *attrs = NULL;
1122 const char *resource_discovery_enabled = NULL;
1128 if (
uname == NULL) {
1132 }
else if (this_node == NULL) {
1154 add_node_attrs(attrs, this_node, TRUE, data_set);
1167 if (resource_discovery_enabled && !
crm_is_true(resource_discovery_enabled)) {
1168 crm_warn(
"ignoring %s attribute on node %s, disabling resource discovery is not allowed on cluster nodes",
1181 pe_fence_node(data_set, this_node,
"cluster does not have quorum");
1187 while(unpack_node_loop(status, FALSE, data_set)) {
1198 for (GList *item = data_set->
stop_needed; item; item = item->next) {
1200 pe_node_t *node = pe__current_node(container);
1210 for (
GListPtr gIter = data_set->
nodes; gIter != NULL; gIter = gIter->next) {
1211 node_t *this_node = gIter->data;
1213 if (this_node == NULL) {
1220 determine_remote_online_status(data_set, this_node);
1227 determine_online_status_no_fencing(
pe_working_set_t * data_set, xmlNode * node_state,
1230 gboolean online = FALSE;
1243 crm_debug(
"Node is not ready to run resources: %s", join);
1248 crm_trace(
"\tis_peer=%s, join=%s, expected=%s",
1253 pe_fence_node(data_set, this_node,
"peer is unexpectedly down");
1254 crm_info(
"\tin_cluster=%s, is_peer=%s, join=%s, expected=%s",
1261 determine_online_status_fencing(
pe_working_set_t * data_set, xmlNode * node_state,
1264 gboolean online = FALSE;
1265 gboolean do_terminate = FALSE;
1266 bool crmd_online = FALSE;
1281 do_terminate = TRUE;
1283 }
else if (terminate != NULL && strlen(terminate) > 0) {
1285 char t = terminate[0];
1287 if (t !=
'0' && isdigit(t)) {
1288 do_terminate = TRUE;
1292 crm_trace(
"%s: in_cluster=%s, is_peer=%s, join=%s, expected=%s, term=%d",
1298 if (exp_state == NULL) {
1306 online = crmd_online;
1308 }
else if (in_cluster == NULL) {
1309 pe_fence_node(data_set, this_node,
"peer has not been seen by the cluster");
1312 pe_fence_node(data_set, this_node,
"peer failed the pacemaker membership criteria");
1326 &&
crm_is_true(in_cluster) == FALSE && !crmd_online) {
1331 pe_fence_node(data_set, this_node,
"peer is no longer part of the cluster");
1333 }
else if (!crmd_online) {
1334 pe_fence_node(data_set, this_node,
"peer process is no longer available");
1337 }
else if (do_terminate) {
1338 pe_fence_node(data_set, this_node,
"termination was requested");
1350 pe_fence_node(data_set, this_node,
"peer was in an unknown state");
1351 crm_warn(
"%s: in-cluster=%s, is-peer=%s, join=%s, expected=%s, term=%d, shutdown=%d",
1372 goto remote_online_done;
1377 if (container && (g_list_length(rsc->
running_on) == 1)) {
1383 crm_trace(
"%s node %s presumed ONLINE because connection resource is started",
1384 (container?
"Guest" :
"Remote"), this_node->
details->
id);
1390 crm_trace(
"%s node %s shutting down because connection resource is stopping",
1391 (container?
"Guest" :
"Remote"), this_node->
details->
id);
1397 crm_trace(
"Guest node %s UNCLEAN because guest resource failed",
1403 crm_trace(
"%s node %s OFFLINE because connection resource failed",
1404 (container?
"Guest" :
"Remote"), this_node->
details->
id);
1410 crm_trace(
"%s node %s OFFLINE because its resource is stopped",
1411 (container?
"Guest" :
"Remote"), this_node->
details->
id);
1415 }
else if (
host && (
host->details->online == FALSE)
1416 &&
host->details->unclean) {
1417 crm_trace(
"Guest node %s UNCLEAN because host is unclean",
1432 gboolean online = FALSE;
1435 if (this_node == NULL) {
1458 online = determine_online_status_no_fencing(data_set, node_state, this_node);
1461 online = determine_online_status_fencing(data_set, node_state, this_node);
1469 this_node->
fixed = TRUE;
1475 this_node->
fixed = TRUE;
1510 if (!crm_strlen_zero(
id)) {
1511 const char *end =
id + strlen(
id) - 1;
1513 for (
const char *s = end; s >
id; --s) {
1527 return (s == end)? s : (s - 1);
1551 char *basename = NULL;
1554 basename =
strndup(last_rsc_id, end - last_rsc_id + 1);
1573 size_t base_name_len = end - last_rsc_id + 1;
1577 zero = calloc(base_name_len + 3,
sizeof(
char));
1579 memcpy(zero, last_rsc_id, base_name_len);
1580 zero[base_name_len] =
':';
1581 zero[base_name_len + 1] =
'0';
1586 create_fake_resource(
const char *rsc_id, xmlNode * rsc_entry,
pe_working_set_t * data_set)
1602 crm_debug(
"Detected orphaned remote node %s", rsc_id);
1607 link_rsc2remotenode(data_set, rsc);
1610 crm_trace(
"Setting node %s as shutting down due to orphaned connection resource", rsc_id);
1617 crm_trace(
"Detected orphaned container filler %s", rsc_id);
1630 create_anonymous_orphan(
pe_resource_t *parent,
const char *rsc_id,
1638 pe_rsc_debug(parent,
"Created orphan %s for %s: %s on %s",
1664 gboolean skip_inactive = FALSE;
1672 for (rIter = parent->
children; rsc == NULL && rIter; rIter = rIter->next) {
1717 crm_notice(
"Active (now-)anonymous clone %s has "
1718 "multiple (orphan) instance histories on %s",
1720 skip_inactive = TRUE;
1727 g_list_free(locations);
1731 if (!skip_inactive && !inactive_instance
1734 inactive_instance = parent->
fns->
find_rsc(child, rsc_id, NULL,
1740 if (inactive_instance && inactive_instance->
pending_node
1742 inactive_instance = NULL;
1748 if ((rsc == NULL) && !skip_inactive && (inactive_instance != NULL)) {
1749 pe_rsc_trace(parent,
"Resource %s, empty slot", inactive_instance->
id);
1750 rsc = inactive_instance;
1774 rsc = create_anonymous_orphan(parent, rsc_id, node, data_set);
1782 xmlNode * rsc_entry)
1801 crm_trace(
"%s found as %s (%s)", rsc_id, clone0_id, parent->
id);
1803 crm_trace(
"%s is not known as %s either (orphan)",
1809 crm_trace(
"Resource history for %s is orphaned because it is no longer primitive",
1817 if (pe_rsc_is_anon_clone(parent)) {
1819 if (pe_rsc_is_bundled(parent)) {
1824 rsc = find_anonymous_clone(data_set, node, parent, base);
1835 pe_rsc_debug(rsc,
"Internally renamed %s on %s to %s%s",
1849 rsc = create_fake_resource(rsc_id, rsc_entry, data_set);
1868 char *reason = NULL;
1871 pe_rsc_trace(rsc,
"Resource %s is %s on %s: on_fail=%s",
1899 gboolean should_fence = FALSE;
1911 should_fence = TRUE;
1925 " revoked if remote connection can "
1926 "be re-established elsewhere)",
1929 should_fence = TRUE;
1933 if (reason == NULL) {
2003 if (rsc->
container && pe_rsc_is_bundled(rsc)) {
2034 "remote connection is unrecoverable");
2069 " %s must be stopped manually on %s",
2101 for (; gIter != NULL; gIter = gIter->next) {
2107 g_list_free(possible_matches);
2114 int start_index,
int stop_index,
2118 const char *task = NULL;
2119 const char *status = NULL;
2123 pe_rsc_trace(rsc,
"%s: Start index %d, stop index = %d", rsc->
id, start_index, stop_index);
2125 for (; gIter != NULL; gIter = gIter->next) {
2126 xmlNode *rsc_op = (xmlNode *) gIter->data;
2128 guint interval_ms = 0;
2130 const char *
id =
ID(rsc_op);
2131 const char *interval_ms_s = NULL;
2140 }
else if (start_index < stop_index && counter <= stop_index) {
2144 }
else if (counter < start_index) {
2151 if (interval_ms == 0) {
2173 int implied_monitor_start = -1;
2174 int implied_clone_start = -1;
2175 const char *task = NULL;
2176 const char *status = NULL;
2182 for (; gIter != NULL; gIter = gIter->next) {
2183 xmlNode *rsc_op = (xmlNode *) gIter->data;
2192 *stop_index = counter;
2195 *start_index = counter;
2201 implied_monitor_start = counter;
2204 implied_clone_start = counter;
2208 if (*start_index == -1) {
2209 if (implied_clone_start != -1) {
2210 *start_index = implied_clone_start;
2211 }
else if (implied_monitor_start != -1) {
2212 *start_index = implied_monitor_start;
2221 int stop_index = -1;
2222 int start_index = -1;
2225 const char *task = NULL;
2232 xmlNode *migrate_op = NULL;
2233 xmlNode *rsc_op = NULL;
2234 xmlNode *last_failure = NULL;
2240 crm_element_name(rsc_entry), rsc_id, node->
details->
uname);
2244 sorted_op_list = NULL;
2246 for (rsc_op = __xml_first_child_element(rsc_entry); rsc_op != NULL;
2247 rsc_op = __xml_next_element(rsc_op)) {
2249 op_list = g_list_prepend(op_list, rsc_op);
2253 if (op_list == NULL) {
2259 rsc = unpack_find_resource(data_set, node, rsc_id, rsc_entry);
2261 rsc = process_orphan_resource(rsc_entry, node, data_set);
2266 saved_role = rsc->
role;
2270 for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) {
2271 xmlNode *rsc_op = (xmlNode *) gIter->data;
2275 migrate_op = rsc_op;
2278 unpack_rsc_op(rsc, node, rsc_op, &last_failure, &on_fail, data_set);
2283 process_recurring(node, rsc, start_index, stop_index, sorted_op_list, data_set);
2286 g_list_free(sorted_op_list);
2288 process_rsc_state(rsc, node, on_fail, migrate_op, data_set);
2292 pe_rsc_debug(rsc,
"%s: Overwriting calculated next role %s"
2293 " with requested next role %s",
2298 pe_rsc_info(rsc,
"%s: Not overwriting calculated next role %s"
2299 " with requested next role %s",
2304 if (saved_role > rsc->
role) {
2305 rsc->
role = saved_role;
2312 handle_orphaned_container_fillers(xmlNode * lrm_rsc_list,
pe_working_set_t * data_set)
2314 xmlNode *rsc_entry = NULL;
2315 for (rsc_entry = __xml_first_child_element(lrm_rsc_list); rsc_entry != NULL;
2316 rsc_entry = __xml_next_element(rsc_entry)) {
2321 const char *container_id;
2329 if (container_id == NULL || rsc_id == NULL) {
2334 if (container == NULL) {
2345 pe_rsc_trace(rsc,
"Mapped container of orphaned resource %s to %s",
2346 rsc->
id, container_id);
2355 xmlNode *rsc_entry = NULL;
2356 gboolean found_orphaned_container_filler = FALSE;
2362 for (rsc_entry = __xml_first_child_element(lrm_rsc_list); rsc_entry != NULL;
2363 rsc_entry = __xml_next_element(rsc_entry)) {
2366 resource_t *rsc = unpack_lrm_rsc_state(node, rsc_entry, data_set);
2371 found_orphaned_container_filler = TRUE;
2379 if (found_orphaned_container_filler) {
2380 handle_orphaned_container_fillers(lrm_rsc_list, data_set);
2398 set_node_score(gpointer key, gpointer value, gpointer user_data)
2401 int *score = user_data;
2406 #define STATUS_PATH_MAX 1024
2408 find_lrm_op(
const char *resource,
const char *op,
const char *node,
const char *source,
2413 xmlNode *xml = NULL;
2415 offset += snprintf(xpath + offset,
STATUS_PATH_MAX - offset,
"//node_state[@uname='%s']", node);
2440 if (xml && success_only) {
2454 pe__call_id(xmlNode *op_xml)
2487 return (stop_op && (pe__call_id(stop_op) > pe__call_id(xml_op)));
2512 int from_status = 0;
2515 xmlNode *migrate_from = NULL;
2522 if (stop_happened_after(rsc, node, xml_op, data_set)) {
2534 source, FALSE, data_set);
2538 pe_rsc_trace(rsc,
"%s op on %s exited with status=%d, rc=%d",
2539 ID(migrate_from), target, from_status, from_rc);
2548 pe_rsc_trace(rsc,
"Detected dangling migration op: %s on %s",
ID(xml_op),
2555 pe_rsc_trace(rsc,
"Marking active on %s %p %d", target, target_node,
2562 pe_rsc_trace(rsc,
"Marking active on %s %p %d", target, target_node,
2589 int target_stop_id = 0;
2590 int target_migrate_from_id = 0;
2591 xmlNode *target_stop = NULL;
2592 xmlNode *target_migrate_from = NULL;
2607 target_stop_id = pe__call_id(target_stop);
2611 source, TRUE, data_set);
2612 target_migrate_from_id = pe__call_id(target_migrate_from);
2614 if ((target_stop == NULL) || (target_stop_id < target_migrate_from_id)) {
2622 target_stop_id, target_migrate_from_id);
2627 }
else if (target_migrate_from == NULL) {
2638 xmlNode *source_migrate_from = NULL;
2639 xmlNode *source_start = NULL;
2640 int source_migrate_to_id = pe__call_id(xml_op);
2643 NULL, TRUE, data_set);
2644 if (pe__call_id(source_migrate_from) > source_migrate_to_id) {
2650 if (pe__call_id(source_start) > source_migrate_to_id) {
2663 xmlNode *source_stop = NULL;
2664 xmlNode *source_migrate_to = NULL;
2682 source, target, TRUE, data_set);
2684 if ((source_stop == NULL)
2685 || (pe__call_id(source_stop) < pe__call_id(source_migrate_to))) {
2699 record_failed_op(xmlNode *op,
const pe_node_t *node,
2702 xmlNode *xIter = NULL;
2709 for (xIter = data_set->
failed->children; xIter; xIter = xIter->next) {
2725 static const char *get_op_key(xmlNode *xml_op)
2735 last_change_str(xmlNode *xml_op)
2738 const char *when_s = NULL;
2745 when_s = strchr(when_s,
' ');
2751 return ((when_s && *when_s)? when_s :
"unknown time");
2841 return first - second;
2845 unpack_rsc_op_failure(
resource_t * rsc,
node_t * node,
int rc, xmlNode * xml_op, xmlNode ** last_failure,
2848 guint interval_ms = 0;
2849 bool is_probe =
false;
2852 const char *key = get_op_key(xml_op);
2860 *last_failure = xml_op;
2867 if (exit_reason == NULL) {
2873 crm_trace(
"Unexpected result (%s%s%s) was recorded for "
2874 "%s of %s on %s at %s " CRM_XS " rc=%d id=%s",
2875 services_ocf_exitcode_str(rc),
2876 (*exit_reason?
": " :
""), exit_reason,
2878 last_change_str(xml_op), rc,
ID(xml_op));
2880 crm_warn(
"Unexpected result (%s%s%s) was recorded for "
2881 "%s of %s on %s at %s " CRM_XS " rc=%d id=%s",
2882 services_ocf_exitcode_str(rc),
2883 (*exit_reason?
": " :
""), exit_reason,
2885 last_change_str(xml_op), rc,
ID(xml_op));
2894 crm_notice(
"If it is not possible for %s to run on %s, see "
2895 "the resource-discovery option for location constraints",
2899 record_failed_op(xml_op, node, rsc, data_set);
2902 action =
custom_action(rsc, strdup(key), task, NULL, TRUE, FALSE, data_set);
2903 if (cmp_on_fail(*on_fail, action->
on_fail) < 0) {
2913 unpack_migrate_to_failure(rsc, node, xml_op, data_set);
2916 unpack_migrate_from_failure(rsc, node, xml_op, data_set);
2950 pe_rsc_trace(rsc,
"Resource %s: role=%s, unclean=%s, on_fail=%s, fail_role=%s",
2967 if (pe_rsc_is_clone(parent)
2975 crm_notice(
"%s will not be started under current conditions",
2982 g_hash_table_foreach(fail_rsc->
allowed_nodes, set_node_score, &score);
3008 determine_op_status(
3011 guint interval_ms = 0;
3012 bool is_probe =
false;
3014 const char *key = get_op_key(xml_op);
3022 if (exit_reason == NULL) {
3032 if (target_rc < 0) {
3042 crm_warn(
"Expected result not found for %s on %s (corrupt or obsolete CIB?)",
3045 }
else if (target_rc != rc) {
3047 pe_rsc_debug(rsc,
"%s on %s: expected %d (%s), got %d (%s%s%s)",
3049 target_rc, services_ocf_exitcode_str(target_rc),
3050 rc, services_ocf_exitcode_str(rc),
3051 (*exit_reason?
": " :
""), exit_reason);
3058 pe_rsc_info(rsc,
"Probe found %s active on %s at %s",
3060 last_change_str(xml_op));
3076 if (is_probe && (rc != target_rc)) {
3079 "Probe found %s active and promoted on %s at %s",
3081 last_change_str(xml_op));
3097 if (interval_ms > 0) {
3108 pe_proc_err(
"No further recovery can be attempted for %s "
3109 "because %s on %s failed (%s%s%s) at %s "
3110 CRM_XS " rc=%d id=%s", rsc->
id, task,
3112 (*exit_reason?
": " :
""), exit_reason,
3113 last_change_str(xml_op), rc,
ID(xml_op));
3122 crm_info(
"Treating unknown exit status %d from %s of %s "
3123 "on %s at %s as failure",
3125 last_change_str(xml_op));
3135 should_clear_for_param_change(xmlNode *xml_op,
const char *task,
3139 if (!strcmp(task,
"start") || !strcmp(task,
"monitor")) {
3153 switch (digest_data->
rc) {
3155 crm_trace(
"Resource %s history entry %s on %s"
3156 " has no digest to compare",
3185 should_ignore_failure_timeout(
pe_resource_t *rsc, xmlNode *xml_op,
3186 const char *task, guint interval_ms,
3216 if (is_last_failure) {
3217 crm_info(
"Waiting to clear monitor failure for remote node %s"
3218 " until fencing has occurred", rsc->
id);
3252 bool expired = FALSE;
3254 time_t last_run = 0;
3255 guint interval_ms = 0;
3256 int unexpired_fail_count = 0;
3258 const char *clear_reason = NULL;
3269 time_t last_failure = 0;
3273 && !should_ignore_failure_timeout(rsc, xml_op, task, interval_ms,
3274 is_last_failure, data_set)) {
3284 crm_trace(
"%s@%lld is %sexpired @%lld with unexpired_failures=%d timeout=%ds"
3285 " last-failure@%lld",
3286 ID(xml_op), (
long long) last_run, (expired?
"" :
"not "),
3288 (
long long) last_failure);
3290 if (unexpired_fail_count && (now < last_failure)) {
3300 if (unexpired_fail_count == 0) {
3302 clear_reason =
"it expired";
3318 clear_reason =
"reconnect interval is set";
3322 if (!expired && is_last_failure
3323 && should_clear_for_param_change(xml_op, task, rsc, node, data_set)) {
3324 clear_reason =
"resource parameters have changed";
3327 if (clear_reason != NULL) {
3342 crm_info(
"Clearing %s failure will wait until any scheduled "
3343 "fencing of %s completes", task, rsc->
id);
3344 order_after_remote_fencing(clear_op, rsc, data_set);
3389 update_resource_state(
resource_t * rsc,
node_t * node, xmlNode * xml_op,
const char * task,
int rc,
3392 gboolean clear_past_failure = FALSE;
3398 clear_past_failure = TRUE;
3405 const char *op_key = get_op_key(xml_op);
3406 const char *last_failure_key = get_op_key(last_failure);
3409 clear_past_failure = TRUE;
3419 clear_past_failure = TRUE;
3423 clear_past_failure = TRUE;
3427 clear_past_failure = TRUE;
3433 clear_past_failure = TRUE;
3439 clear_past_failure = TRUE;
3442 unpack_migrate_to_success(rsc, node, xml_op, data_set);
3450 if (clear_past_failure) {
3456 pe_rsc_trace(rsc,
"%s.%s is not cleared by a completed stop",
3505 remap_monitor_rc(
int rc, xmlNode *xml_op,
const pe_node_t *node,
3508 int remapped_rc = rc;
3523 if (rc != remapped_rc) {
3524 crm_trace(
"Remapping monitor result %d to %d", rc, remapped_rc);
3526 record_failed_op(xml_op, node, rsc, data_set);
3541 guint interval_ms = 0;
3542 const char *task = NULL;
3543 const char *task_key = NULL;
3544 const char *exit_reason = NULL;
3545 bool expired = FALSE;
3549 CRM_CHECK(rsc && node && xml_op,
return);
3552 task_key = get_op_key(xml_op);
3555 if (exit_reason == NULL) {
3578 pe_rsc_trace(rsc,
"Unpacking task %s/%s (call_id=%d, status=%d, rc=%d) on %s (role=%s)",
3582 pe_rsc_trace(rsc,
"Node %s (where %s is running) is unclean."
3583 " Further action depends on the value of the stop's on-fail attribute",
3600 && check_operation_expiry(rsc, node, rc, xml_op, data_set)) {
3605 rc = remap_monitor_rc(rc, xml_op, node, rsc, data_set);
3608 if (expired && (rc != target_rc)) {
3611 if (interval_ms == 0) {
3612 crm_notice(
"Ignoring expired %s failure on %s "
3613 CRM_XS " actual=%d expected=%d magic=%s",
3628 crm_notice(
"Rescheduling %s after failure expired on %s "
3629 CRM_XS " actual=%d expected=%d magic=%s",
3642 status = determine_op_status(rsc, rc, target_rc, node, xml_op, on_fail, data_set);
3643 pe_rsc_trace(rsc,
"Remapped %s status to %d", task_key, status);
3649 pe_err(
"Resource history contains cancellation '%s' "
3650 "(%s of %s on %s at %s)",
3652 last_change_str(xml_op));
3694 last_change_str(xml_op),
ID(xml_op));
3695 update_resource_state(rsc, node, xml_op, task, rc, *last_failure, on_fail, data_set);
3699 failure_strategy = get_action_on_fail(rsc, task_key, task, data_set);
3701 crm_warn(
"Cannot ignore failed %s of %s on %s: "
3702 "Resource agent doesn't exist "
3703 CRM_XS " status=%d rc=%d id=%s",
3710 unpack_rsc_op_failure(rsc, node, rc, xml_op, last_failure, on_fail, data_set);
3735 failure_strategy = get_action_on_fail(rsc, task_key, task, data_set);
3740 crm_warn(
"Pretending failed %s (%s%s%s) of %s on %s at %s "
3741 "succeeded " CRM_XS " rc=%d id=%s",
3742 task, services_ocf_exitcode_str(rc),
3743 (*exit_reason?
": " :
""), exit_reason, rsc->
id,
3747 update_resource_state(rsc, node, xml_op, task, target_rc, *last_failure, on_fail, data_set);
3751 record_failed_op(xml_op, node, rsc, data_set);
3755 *on_fail = failure_strategy;
3759 unpack_rsc_op_failure(rsc, node, rc, xml_op, last_failure, on_fail, data_set);
3763 "Preventing %s from restarting on %s because "
3764 "of hard failure (%s%s%s)" CRM_XS " rc=%d id=%s",
3766 services_ocf_exitcode_str(rc),
3767 (*exit_reason?
": " :
""), exit_reason,
3772 crm_err(
"Preventing %s from restarting anywhere because "
3773 "of fatal failure (%s%s%s) " CRM_XS " rc=%d id=%s",
3774 parent->
id, services_ocf_exitcode_str(rc),
3775 (*exit_reason?
": " :
""), exit_reason,
3784 pe_rsc_trace(rsc,
"Resource %s after %s: role=%s, next=%s",
3790 add_node_attrs(xmlNode *xml_obj,
pe_node_t *node,
bool overwrite,
3793 const char *cluster_name = NULL;
3810 cluster_name = g_hash_table_lookup(data_set->
config_hash,
"cluster-name");
3813 strdup(cluster_name));
3827 }
else if (cluster_name) {
3831 strdup(cluster_name));
3837 extract_operations(
const char *node,
const char *rsc, xmlNode * rsc_entry, gboolean active_filter)
3840 int stop_index = -1;
3841 int start_index = -1;
3843 xmlNode *rsc_op = NULL;
3851 sorted_op_list = NULL;
3853 for (rsc_op = __xml_first_child_element(rsc_entry);
3854 rsc_op != NULL; rsc_op = __xml_next_element(rsc_op)) {
3858 op_list = g_list_prepend(op_list, rsc_op);
3862 if (op_list == NULL) {
3870 if (active_filter == FALSE) {
3871 return sorted_op_list;
3878 for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) {
3879 xmlNode *rsc_op = (xmlNode *) gIter->data;
3883 if (start_index < stop_index) {
3884 crm_trace(
"Skipping %s: not active",
ID(rsc_entry));
3887 }
else if (counter < start_index) {
3891 op_list = g_list_append(op_list, rsc_op);
3894 g_list_free(sorted_op_list);
3905 xmlNode *tmp = NULL;
3908 node_t *this_node = NULL;
3910 xmlNode *node_state = NULL;
3912 for (node_state = __xml_first_child_element(status); node_state != NULL;
3913 node_state = __xml_next_element(node_state)) {
3923 if(this_node == NULL) {
3928 determine_remote_online_status(data_set, this_node);
3939 xmlNode *lrm_rsc = NULL;
3944 for (lrm_rsc = __xml_first_child_element(tmp); lrm_rsc != NULL;
3945 lrm_rsc = __xml_next_element(lrm_rsc)) {
3954 intermediate = extract_operations(
uname, rsc_id, lrm_rsc, active_filter);
3955 output = g_list_concat(output, intermediate);