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);
81 const xmlNode *xml_op)
102 gboolean should_block = FALSE;
107 int max = numXpathResults(xpathObj);
110 for (lpc = 0; lpc < max; lpc++) {
114 should_block = is_matched_failure(xml_name, pref, xml_op);
120 const char *conf_op_name = NULL;
121 const char *conf_op_interval_spec = NULL;
122 guint conf_op_interval_ms = 0;
123 char *lrm_op_xpath = NULL;
124 xmlXPathObject *lrm_op_xpathObj = NULL;
131 #define XPATH_FMT "//" XML_CIB_TAG_STATE "[@" XML_ATTR_UNAME "='%s']" \ 132 "//" XML_LRM_TAG_RESOURCE "[@" XML_ATTR_ID "='%s']" \ 133 "/" XML_LRM_TAG_RSC_OP "[@" XML_LRM_ATTR_TASK "='%s']" \ 134 "[@" XML_LRM_ATTR_INTERVAL "='%u']" 139 conf_op_interval_ms);
144 if (lrm_op_xpathObj) {
145 int max2 = numXpathResults(lrm_op_xpathObj);
148 for (lpc2 = 0; lpc2 < max2; lpc2++) {
152 should_block = is_matched_failure(xml_name, pref,
206 generate_fail_regex(
const char *prefix,
const char *rsc_name,
207 gboolean is_legacy, gboolean is_unique, regex_t *re)
214 const char *op_pattern = (is_legacy?
"" :
"#.+_[0-9]+");
222 const char *instance_pattern = (is_unique?
"" :
"(:[0-9]+)?");
225 instance_pattern, op_pattern);
226 if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0) {
249 regex_t *failcount_re, regex_t *lastfailure_re)
252 char *rsc_name = rsc_fail_name(rsc);
269 regfree(failcount_re);
277 struct failcount_data {
281 const xmlNode *xml_op;
282 regex_t failcount_re;
283 regex_t lastfailure_re;
297 update_failcount_for_attr(gpointer key, gpointer value, gpointer user_data)
299 struct failcount_data *fc_data = user_data;
302 if (regexec(&(fc_data->failcount_re), (
const char *) key, 0, NULL, 0) == 0) {
305 pe_rsc_trace(fc_data->rsc,
"Added %s (%s) to %s fail count (now %s)",
306 (
const char *) key, (
const char *) value, fc_data->rsc->id,
312 if (regexec(&(fc_data->lastfailure_re), (
const char *) key, 0, NULL,
317 fc_data->last_failure = (time_t) QB_MAX(fc_data->last_failure,
331 update_failcount_for_filler(gpointer
data, gpointer user_data)
334 struct failcount_data *fc_data = user_data;
335 time_t filler_last_failure = 0;
338 &filler_last_failure, fc_data->flags,
340 fc_data->last_failure = QB_MAX(fc_data->last_failure, filler_last_failure);
361 time_t *last_failure, uint32_t
flags,
const xmlNode *xml_op)
363 struct failcount_data fc_data = {
369 .last_failure = (time_t) 0,
373 CRM_CHECK(generate_fail_regexes(rsc, &fc_data.failcount_re,
376 g_hash_table_foreach(node->
details->
attrs, update_failcount_for_attr,
378 regfree(&(fc_data.failcount_re));
379 regfree(&(fc_data.lastfailure_re));
383 && block_failure(node, rsc, xml_op)) {
385 pe_warn(
"Ignoring failure timeout %d for %s " 386 "because it conflicts with on-fail=block",
398 pe_rsc_debug(rsc,
"Failcount for %s on %s expired after %ds",
400 fc_data.failcount = 0;
415 && !pe_rsc_is_bundled(rsc)) {
417 g_list_foreach(rsc->
fillers, update_failcount_for_filler, &fc_data);
418 if (fc_data.failcount > 0) {
420 "Container %s and the resources within it " 421 "have failed %s time%s on %s",
426 }
else if (fc_data.failcount > 0) {
432 if (last_failure != NULL) {
433 if ((fc_data.failcount > 0) && (fc_data.last_failure > 0)) {
434 *last_failure = fc_data.last_failure;
439 return fc_data.failcount;
466 rsc->
id, pe__node_name(node), reason, clear->
uuid);
#define CRM_CHECK(expr, failure_action)
#define crm_notice(fmt, args...)
pcmk_scheduler_t * cluster
Cluster that resource is part of.
GHashTable * attrs
Node attributes.
#define pe_rsc_debug(rsc, 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)
xmlNode * xml
Resource configuration (possibly expanded from template)
Implementation of pcmk_action_t.
int char2score(const char *score)
Get the integer value of a score string.
#define XML_LRM_ATTR_INTERVAL
#define PCMK_ACTION_CLEAR_FAILCOUNT
#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.
Implementation of pcmk_scheduler_t.
#define PCMK__LAST_FAILURE_PREFIX
int pe_get_failcount(const pcmk_node_t *node, pcmk_resource_t *rsc, time_t *last_failure, uint32_t flags, const xmlNode *xml_op)
#define XML_LRM_ATTR_TASK
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.
Implementation of pcmk_resource_t.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
int failure_timeout
Failure timeout.
char * clone_strip(const char *last_rsc_id)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
GHashTable * meta
Meta-attributes relevant to action.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
Basic node information.
unsigned long long flags
Group of enum pcmk_rsc_flags.
const char * uname
Node name in cluster.
Wrappers for and extensions to libxml2.
#define XML_ATTR_TE_NOWAIT
char * clone_name
Resource instance ID in history.
#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)
Implementation of pcmk_node_t.
pcmk_action_t * custom_action(pcmk_resource_t *rsc, char *key, const char *task, const pcmk_node_t *on_node, gboolean optional, pcmk_scheduler_t *scheduler)
Create or update an action object.
GList * fillers
Resources contained by this one, if any.
xmlXPathObjectPtr xpath_search(const xmlNode *xml_top, const char *path)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
pcmk_scheduler_t * scheduler
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)
int pcmk__add_scores(int score1, int score2)
#define pe_rsc_trace(rsc, fmt, args...)
pcmk_action_t * pe__clear_failcount(pcmk_resource_t *rsc, const pcmk_node_t *node, const char *reason, pcmk_scheduler_t *scheduler)
Schedule a controller operation to clear a fail count.
time_t get_effective_time(pcmk_scheduler_t *scheduler)
void freeXpathObject(xmlXPathObjectPtr xpathObj)
Whether resource is not an anonymous clone instance.
#define pe_rsc_info(rsc, fmt, args...)
char * id
Resource ID in configuration.