10 #include <sys/types.h>
21 is_matched_failure(
const char *rsc_id, xmlNode *conf_op_xml,
24 gboolean matched = FALSE;
25 const char *conf_op_name = NULL;
26 const char *lrm_op_task = NULL;
27 const char *conf_op_interval_spec = NULL;
28 guint conf_op_interval_ms = 0;
29 guint lrm_op_interval_ms = 0;
30 const char *lrm_op_id = NULL;
31 char *last_failure_key = NULL;
33 if (rsc_id == NULL || conf_op_xml == NULL || lrm_op_xml == NULL) {
48 if ((conf_op_interval_ms != lrm_op_interval_ms)
53 lrm_op_id =
ID(lrm_op_xml);
54 last_failure_key =
pcmk__op_key(rsc_id,
"last_failure", 0);
60 char *expected_op_key =
pcmk__op_key(rsc_id, conf_op_name,
68 if (
rc != target_rc) {
72 free(expected_op_key);
75 free(last_failure_key);
99 gboolean should_block = FALSE;
104 int max = numXpathResults(xpathObj);
107 for (lpc = 0; lpc < max; lpc++) {
111 should_block = is_matched_failure(xml_name, pref, xml_op);
117 const char *conf_op_name = NULL;
118 const char *conf_op_interval_spec = NULL;
119 guint conf_op_interval_ms = 0;
120 char *lrm_op_xpath = NULL;
121 xmlXPathObject *lrm_op_xpathObj = NULL;
129 "//lrm_resource[@id='%s']"
130 "/lrm_rsc_op[@operation='%s'][@interval='%u']",
132 conf_op_name, conf_op_interval_ms);
137 if (lrm_op_xpathObj) {
138 int max2 = numXpathResults(lrm_op_xpathObj);
141 for (lpc2 = 0; lpc2 < max2; lpc2++) {
145 should_block = is_matched_failure(xml_name, pref,
198 generate_fail_regex(
const char *prefix,
const char *rsc_name,
199 gboolean is_legacy, gboolean is_unique, regex_t *re)
206 const char *op_pattern = (is_legacy?
"" :
"#.+_[0-9]+");
214 const char *instance_pattern = (is_unique?
"" :
"(:[0-9]+)?");
217 instance_pattern, op_pattern);
218 CRM_LOG_ASSERT(regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) == 0);
235 regex_t *failcount_re, regex_t *lastfailure_re)
237 char *rsc_name = rsc_fail_name(rsc);
255 const char *value = NULL;
256 regex_t failcount_re, lastfailure_re;
261 generate_fail_regexes(rsc, data_set, &failcount_re, &lastfailure_re);
265 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
266 if (regexec(&failcount_re, key, 0, NULL, 0) == 0) {
268 }
else if (regexec(&lastfailure_re, key, 0, NULL, 0) == 0) {
269 last = QB_MAX(last, (time_t)
crm_parse_ll(value, NULL));
273 regfree(&failcount_re);
274 regfree(&lastfailure_re);
276 if ((failcount > 0) && (last > 0) && (last_failure != NULL)) {
277 *last_failure = last;
282 && block_failure(node, rsc, xml_op, data_set)) {
284 pe_warn(
"Ignoring failure timeout %d for %s because it conflicts with on-fail=block",
296 crm_debug(
"Failcount for %s on %s expired after %ds",
313 && !pe_rsc_is_bundled(rsc)) {
317 for (gIter = rsc->
fillers; gIter != NULL; gIter = gIter->next) {
319 time_t filler_last_failure = 0;
322 flags, xml_op, data_set);
324 if (last_failure && filler_last_failure > *last_failure) {
325 *last_failure = filler_last_failure;
332 crm_info(
"Container %s and the resources within it have failed %s times on %s",
337 }
else if (failcount > 0) {
340 crm_info(
"%s has failed %s times on %s",
366 CRM_CHECK(rsc && node && reason && data_set,
return NULL);