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) {
272 last = (time_t) QB_MAX(last, last_ll);
277 regfree(&failcount_re);
278 regfree(&lastfailure_re);
280 if ((failcount > 0) && (last > 0) && (last_failure != NULL)) {
281 *last_failure = last;
286 && block_failure(node, rsc, xml_op, data_set)) {
288 pe_warn(
"Ignoring failure timeout %d for %s because it conflicts with on-fail=block",
300 crm_debug(
"Failcount for %s on %s expired after %ds",
317 && !pe_rsc_is_bundled(rsc)) {
321 for (gIter = rsc->
fillers; gIter != NULL; gIter = gIter->next) {
323 time_t filler_last_failure = 0;
326 flags, xml_op, data_set);
328 if (last_failure && filler_last_failure > *last_failure) {
329 *last_failure = filler_last_failure;
336 crm_info(
"Container %s and the resources within it have failed %s times on %s",
341 }
else if (failcount > 0) {
344 crm_info(
"%s has failed %s times on %s",
370 CRM_CHECK(rsc && node && reason && data_set,
return NULL);
#define CRM_CHECK(expr, failure_action)
#define crm_notice(fmt, args...)
int pe__target_rc_from_xml(xmlNode *xml_op)
int char2score(const char *score)
#define XML_LRM_ATTR_INTERVAL
time_t get_effective_time(pe_working_set_t *data_set)
#define CRM_LOG_ASSERT(expr)
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
#define PCMK__LAST_FAILURE_PREFIX
#define XML_LRM_ATTR_TASK
#define CRM_OP_CLEAR_FAILCOUNT
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
char * clone_strip(const char *last_rsc_id)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
Wrappers for and extensions to libxml2.
#define XML_ATTR_TE_NOWAIT
#define PCMK__FAIL_COUNT_PREFIX
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
int pe__add_scores(int score1, int score2)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
pe_action_t * pe__clear_failcount(pe_resource_t *rsc, pe_node_t *node, const char *reason, pe_working_set_t *data_set)
Schedule a controller operation to clear a fail count.
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
int compare_version(const char *version1, const char *version2)
#define XML_LRM_ATTR_INTERVAL_MS
#define XML_ATTR_CRM_VERSION
void freeXpathObject(xmlXPathObjectPtr xpathObj)
#define crm_info(fmt, args...)
int pe_get_failcount(pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, xmlNode *xml_op, pe_working_set_t *data_set)
char * score2char(int score)
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)