10 #include <sys/types.h> 28 is_matched_failure(
const char *rsc_id, xmlNode *conf_op_xml,
31 gboolean matched = FALSE;
32 const char *conf_op_name = NULL;
33 int conf_op_interval = 0;
34 const char *lrm_op_task = NULL;
35 int lrm_op_interval = 0;
36 const char *lrm_op_id = NULL;
37 char *last_failure_key = NULL;
39 if (rsc_id == NULL || conf_op_xml == NULL || lrm_op_xml == NULL) {
49 || conf_op_interval != lrm_op_interval) {
53 lrm_op_id =
ID(lrm_op_xml);
68 if (rc != target_rc) {
72 free(expected_op_key);
75 free(last_failure_key);
87 gboolean should_block = FALSE;
100 int max = numXpathResults(xpathObj);
103 for (lpc = 0; lpc < max; lpc++) {
107 should_block = is_matched_failure(xml_name, pref, xml_op);
113 const char *conf_op_name = NULL;
114 int conf_op_interval = 0;
115 char *lrm_op_xpath = NULL;
116 xmlXPathObject *lrm_op_xpathObj = NULL;
122 "//lrm_resource[@id='%s']" 123 "/lrm_rsc_op[@operation='%s'][@interval='%d']",
125 conf_op_name, conf_op_interval);
130 if (lrm_op_xpathObj) {
131 int max2 = numXpathResults(lrm_op_xpathObj);
134 for (lpc2 = 0; lpc2 < max2; lpc2++) {
138 should_block = is_matched_failure(xml_name, pref,
191 generate_fail_regex(
const char *prefix,
const char *rsc_name,
192 gboolean is_legacy, gboolean is_unique, regex_t *re)
199 const char *op_pattern = (is_legacy?
"" :
"#.+_[0-9]+");
207 const char *instance_pattern = (is_unique?
"" :
"(:[0-9]+)?");
210 instance_pattern, op_pattern);
211 CRM_LOG_ASSERT(regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) == 0);
228 regex_t *failcount_re, regex_t *lastfailure_re)
230 char *rsc_name = rsc_fail_name(rsc);
248 const char *value = NULL;
249 regex_t failcount_re, lastfailure_re;
254 generate_fail_regexes(rsc, data_set, &failcount_re, &lastfailure_re);
258 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
259 if (regexec(&failcount_re, key, 0, NULL, 0) == 0) {
261 }
else if (regexec(&lastfailure_re, key, 0, NULL, 0) == 0) {
266 regfree(&failcount_re);
267 regfree(&lastfailure_re);
269 if ((failcount > 0) && (last > 0) && (last_failure != NULL)) {
270 *last_failure = last;
275 && block_failure(node, rsc, xml_op, data_set)) {
277 pe_warn(
"Ignoring failure timeout %d for %s because it conflicts with on-fail=block",
283 if (effective && (failcount > 0) && (last > 0) && rsc->
failure_timeout) {
287 crm_debug(
"Failcount for %s on %s expired after %ds",
296 crm_info(
"%s has failed %s times on %s",
311 int failcount_all = 0;
313 failcount_all =
get_failcount(node, rsc, last_failure, data_set);
318 for (gIter = rsc->
fillers; gIter != NULL; gIter = gIter->next) {
320 time_t filler_last_failure = 0;
322 failcount_all +=
get_failcount(node, filler, &filler_last_failure,
325 if (last_failure && filler_last_failure > *last_failure) {
326 *last_failure = filler_last_failure;
330 if (failcount_all != 0) {
333 crm_info(
"Container %s and the resources within it have failed %s times on %s",
339 return failcount_all;
int get_failcount_all(node_t *node, resource_t *rsc, time_t *last_failure, pe_working_set_t *data_set)
#define CRM_LAST_FAILURE_PREFIX
long long crm_int_helper(const char *text, char **end_text)
int char2score(const char *score)
long long crm_get_msec(const char *input)
#define XML_LRM_ATTR_INTERVAL
time_t get_effective_time(pe_working_set_t *data_set)
#define CRM_LOG_ASSERT(expr)
int get_target_rc(xmlNode *xml_op)
#define XML_LRM_ATTR_TASK
struct node_shared_s * details
#define crm_debug(fmt, args...)
#define CRM_FAIL_COUNT_PREFIX
char * clone_strip(const char *last_rsc_id)
Wrappers for and extensions to libxml2.
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
const char * crm_element_value(xmlNode *data, const char *name)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
int get_failcount(node_t *node, resource_t *rsc, time_t *last_failure, pe_working_set_t *data_set)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
int compare_version(const char *version1, const char *version2)
int merge_weights(int w1, int w2)
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_ATTR_CRM_VERSION
char * generate_op_key(const char *rsc_id, const char *op_type, int interval)
Generate an operation key.
#define safe_str_eq(a, b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
void freeXpathObject(xmlXPathObjectPtr xpathObj)
#define crm_info(fmt, args...)
#define pe_flag_stonith_enabled
char * score2char(int score)