Skip to content

Commit

Permalink
Fix: libpacemaker: set fail-count to INFINITY for fatal failures
Browse files Browse the repository at this point in the history
... to be consistent with what controller does with update_failcount()
  • Loading branch information
gao-yan committed Dec 13, 2024
1 parent 3cce5ed commit 99a3ed6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/pacemaker/libpacemaker_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,8 @@ xmlNode *pcmk__inject_resource_history(pcmk__output_t *out, xmlNode *cib_node,
G_GNUC_INTERNAL
void pcmk__inject_failcount(pcmk__output_t *out, cib_t *cib_conn,
xmlNode *cib_node, const char *resource,
const char *task, guint interval_ms, int rc);
const char *task, guint interval_ms, int rc,
const char *offset);

G_GNUC_INTERNAL
xmlNode *pcmk__inject_action_result(xmlNode *cib_resource,
Expand Down
23 changes: 20 additions & 3 deletions lib/pacemaker/pcmk_injections.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ inject_transient_attr(pcmk__output_t *out, xmlNode *cib_node,
void
pcmk__inject_failcount(pcmk__output_t *out, cib_t *cib_conn, xmlNode *cib_node,
const char *resource, const char *task,
guint interval_ms, int exit_status)
guint interval_ms, int exit_status, const char *offset)
{
char *name = NULL;
char *value = NULL;
Expand All @@ -120,7 +120,14 @@ pcmk__inject_failcount(pcmk__output_t *out, cib_t *cib_conn, xmlNode *cib_node,
failcount = 0;
}
}
value = pcmk__itoa(failcount + 1);

if (pcmk_str_is_infinity(offset)) {
value = strdup(offset);

} else {
value = pcmk__itoa(failcount + 1);
}

inject_transient_attr(out, cib_node, name, value);

free(name);
Expand Down Expand Up @@ -559,6 +566,7 @@ inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
const char *rtype = NULL;
const char *rclass = NULL;
const char *rprovider = NULL;
const char *offset = NULL;

xmlNode *cib_op = NULL;
xmlNode *cib_node = NULL;
Expand Down Expand Up @@ -592,8 +600,17 @@ inject_action(pcmk__output_t *out, const char *spec, cib_t *cib,
cib_node = pcmk__inject_node(cib, node, NULL);
pcmk__assert(cib_node != NULL);

if (pcmk__str_eq(task, PCMK_ACTION_STOP, pcmk__str_none)) {
offset = PCMK_VALUE_INFINITY;

} else if (pcmk__str_eq(task, PCMK_ACTION_START, pcmk__str_none)
&& pcmk_is_set(scheduler->flags,
pcmk__sched_start_failure_fatal)) {
offset = PCMK_VALUE_INFINITY;
}

pcmk__inject_failcount(out, cib, cib_node, resource, task, interval_ms,
outcome);
outcome, offset);

cib_resource = pcmk__inject_resource_history(out, cib_node,
resource, resource,
Expand Down
12 changes: 11 additions & 1 deletion lib/pacemaker/pcmk_simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ simulate_resource_action(pcmk__graph_t *graph, pcmk__graph_action_t *action)
const char *spec = (const char *) iter->data;
char *key = NULL;
const char *match_name = NULL;
const char *offset = NULL;

// Allow user to specify anonymous clone with or without instance number
key = crm_strdup_printf(PCMK__OP_FMT "@%s=", resource, op->op_type,
Expand Down Expand Up @@ -637,8 +638,17 @@ simulate_resource_action(pcmk__graph_t *graph, pcmk__graph_action_t *action)
action->id, op->rc);
pcmk__set_graph_action_flags(action, pcmk__graph_action_failed);
graph->abort_priority = PCMK_SCORE_INFINITY;

if (pcmk__str_eq(op->op_type, PCMK_ACTION_START, pcmk__str_none)) {
offset = pcmk__s(graph->failed_start_offset, PCMK_VALUE_INFINITY);

} else if (pcmk__str_eq(op->op_type, PCMK_ACTION_STOP,
pcmk__str_none)) {
offset = pcmk__s(graph->failed_stop_offset, PCMK_VALUE_INFINITY);
}

pcmk__inject_failcount(out, fake_cib, cib_node, match_name, op->op_type,
op->interval_ms, op->rc);
op->interval_ms, op->rc, offset);
break;
}

Expand Down

0 comments on commit 99a3ed6

Please sign in to comment.