10 #include <sys/types.h> 21 is_matched_failure(
const char *rsc_id,
const xmlNode *conf_op_xml,
22 const xmlNode *lrm_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);
101 gboolean should_block = FALSE;
106 int max = numXpathResults(xpathObj);
109 for (lpc = 0; lpc < max; lpc++) {
113 should_block = is_matched_failure(xml_name, pref, xml_op);
119 const char *conf_op_name = NULL;
120 const char *conf_op_interval_spec = NULL;
121 guint conf_op_interval_ms = 0;
122 char *lrm_op_xpath = NULL;
123 xmlXPathObject *lrm_op_xpathObj = NULL;
130 #define XPATH_FMT "//" XML_CIB_TAG_STATE "[@" XML_ATTR_UNAME "='%s']" \ 131 "//" XML_LRM_TAG_RESOURCE "[@" XML_ATTR_ID "='%s']" \ 132 "/" XML_LRM_TAG_RSC_OP "[@" XML_LRM_ATTR_TASK "='%s']" \ 133 "[@" XML_LRM_ATTR_INTERVAL "='%u']" 138 conf_op_interval_ms);
143 if (lrm_op_xpathObj) {
144 int max2 = numXpathResults(lrm_op_xpathObj);
147 for (lpc2 = 0; lpc2 < max2; lpc2++) {
151 should_block = is_matched_failure(xml_name, pref,
205 generate_fail_regex(
const char *prefix,
const char *rsc_name,
206 gboolean is_legacy, gboolean is_unique, regex_t *re)
213 const char *op_pattern = (is_legacy?
"" :
"#.+_[0-9]+");
221 const char *instance_pattern = (is_unique?
"" :
"(:[0-9]+)?");
224 instance_pattern, op_pattern);
225 if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
250 regex_t *failcount_re, regex_t *lastfailure_re)
252 char *rsc_name = rsc_fail_name(rsc);
267 regfree(failcount_re);
276 time_t *last_failure, uint32_t
flags,
const xmlNode *xml_op)
279 const char *value = NULL;
280 regex_t failcount_re, lastfailure_re;
291 while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) {
292 if (regexec(&failcount_re, key, 0, NULL, 0) == 0) {
294 crm_trace(
"Added %s (%s) to %s fail count (now %s)",
296 }
else if (regexec(&lastfailure_re, key, 0, NULL, 0) == 0) {
300 last = (time_t) QB_MAX(last, last_ll);
305 regfree(&failcount_re);
306 regfree(&lastfailure_re);
308 if ((failcount > 0) && (last > 0) && (last_failure != NULL)) {
309 *last_failure = last;
314 && block_failure(node, rsc, xml_op)) {
316 pe_warn(
"Ignoring failure timeout %d for %s because it conflicts with on-fail=block",
328 crm_debug(
"Failcount for %s on %s expired after %ds",
345 && !pe_rsc_is_bundled(rsc)) {
349 for (gIter = rsc->
fillers; gIter != NULL; gIter = gIter->next) {
351 time_t filler_last_failure = 0;
356 if (last_failure && filler_last_failure > *last_failure) {
357 *last_failure = filler_last_failure;
362 crm_info(
"Container %s and the resources within it " 363 "have failed %s time%s on %s",
368 }
else if (failcount > 0) {
369 crm_info(
"%s has failed %s time%s on %s",
401 rsc->
id, pe__node_name(node), reason, clear->
uuid);
#define CRM_CHECK(expr, failure_action)
#define crm_notice(fmt, args...)
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
int pe__target_rc_from_xml(const xmlNode *xml_op)
int char2score(const char *score)
Get the integer value of a score string.
#define XML_LRM_ATTR_INTERVAL
time_t get_effective_time(pe_working_set_t *data_set)
#define XML_OP_ATTR_ON_FAIL
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.
#define XML_CIB_TAG_RESOURCE
char * clone_strip(const char *last_rsc_id)
#define crm_trace(fmt, args...)
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
int pe_get_failcount(const pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, const xmlNode *xml_op)
pe_working_set_t * data_set
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)
pe_action_t * pe__clear_failcount(pe_resource_t *rsc, const pe_node_t *node, const char *reason, pe_working_set_t *data_set)
Schedule a controller operation to clear a fail count.
void add_hash_param(GHashTable *hash, const char *name, const char *value)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
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
#define pcmk__plural_s(i)
pe_working_set_t * cluster
int pcmk__add_scores(int score1, int score2)
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, const pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
Create or update an action object.
void freeXpathObject(xmlXPathObjectPtr xpathObj)
#define crm_info(fmt, args...)