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 int conf_op_interval = 0;
27 const char *lrm_op_task = NULL;
28 int lrm_op_interval = 0;
29 const char *lrm_op_id = NULL;
30 char *last_failure_key = NULL;
32 if (rsc_id == NULL || conf_op_xml == NULL || lrm_op_xml == NULL) {
42 || conf_op_interval != lrm_op_interval) {
46 lrm_op_id =
ID(lrm_op_xml);
61 if (rc != target_rc) {
65 free(expected_op_key);
68 free(last_failure_key);
80 gboolean should_block = FALSE;
93 int max = numXpathResults(xpathObj);
96 for (lpc = 0; lpc < max; lpc++) {
100 should_block = is_matched_failure(xml_name, pref, xml_op);
106 const char *conf_op_name = NULL;
107 int conf_op_interval = 0;
108 char *lrm_op_xpath = NULL;
109 xmlXPathObject *lrm_op_xpathObj = NULL;
115 "//lrm_resource[@id='%s']"
116 "/lrm_rsc_op[@operation='%s'][@interval='%d']",
118 conf_op_name, conf_op_interval);
123 if (lrm_op_xpathObj) {
124 int max2 = numXpathResults(lrm_op_xpathObj);
127 for (lpc2 = 0; lpc2 < max2; lpc2++) {
131 should_block = is_matched_failure(xml_name, pref,
184 generate_fail_regex(
const char *prefix,
const char *rsc_name,
185 gboolean is_legacy, gboolean is_unique, regex_t *re)
192 const char *op_pattern = (is_legacy?
"" :
"#.+_[0-9]+");
200 const char *instance_pattern = (is_unique?
"" :
"(:[0-9]+)?");
203 instance_pattern, op_pattern);
204 CRM_LOG_ASSERT(regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) == 0);
221 regex_t *failcount_re, regex_t *lastfailure_re)
223 char *rsc_name = rsc_fail_name(rsc);
241 const char *value = NULL;
242 regex_t failcount_re, lastfailure_re;
247 generate_fail_regexes(rsc, data_set, &failcount_re, &lastfailure_re);
251 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
252 if (regexec(&failcount_re, key, 0, NULL, 0) == 0) {
254 }
else if (regexec(&lastfailure_re, key, 0, NULL, 0) == 0) {
259 regfree(&failcount_re);
260 regfree(&lastfailure_re);
262 if ((failcount > 0) && (last > 0) && (last_failure != NULL)) {
263 *last_failure = last;
268 && block_failure(node, rsc, xml_op, data_set)) {
270 pe_warn(
"Ignoring failure timeout %d for %s because it conflicts with on-fail=block",
282 crm_debug(
"Failcount for %s on %s expired after %ds",
291 for (gIter = rsc->
fillers; gIter != NULL; gIter = gIter->next) {
293 time_t filler_last_failure = 0;
296 flags, xml_op, data_set);
298 if (last_failure && filler_last_failure > *last_failure) {
299 *last_failure = filler_last_failure;
306 crm_info(
"Container %s and the resources within it have failed %s times on %s",
311 }
else if (failcount > 0) {
314 crm_info(
"%s has failed %s times on %s",
#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)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
int compare_version(const char *version1, const char *version2)
int merge_weights(int w1, int w2)
#define XML_ATTR_CRM_VERSION
int pe_get_failcount(node_t *node, resource_t *rsc, time_t *last_failure, uint32_t flags, xmlNode *xml_op, pe_working_set_t *data_set)
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)