Skip to content

Commit

Permalink
Refactor: controller: functionize attribute failure handling
Browse files Browse the repository at this point in the history
... for future reuse
  • Loading branch information
kgaillot committed Oct 6, 2022
1 parent 5715560 commit 36558d3
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions daemons/controld/controld_attrd.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ when(void)
return pcmk_is_set(fsa_input_register, R_SHUTDOWN)? " at shutdown" : "";
}

static void
handle_attr_error(void)
{
if (AM_I_DC) {
/* We are unable to provide accurate information to the
* scheduler, so allow another node to take over DC.
* @TODO Should we do this unconditionally on any failure?
*/
crmd_exit(CRM_EX_FATAL);

} else if (pcmk_is_set(fsa_input_register, R_SHUTDOWN)) {
// Fast-track shutdown since unable to request via attribute
register_fsa_input(C_FSA_INTERNAL, I_FAIL, NULL);
}
}

static void
log_attrd_error(const char *host, const char *name, const char *value,
gboolean is_remote, enum attrd_command command, int rc)
Expand All @@ -74,19 +90,7 @@ log_attrd_error(const char *host, const char *name, const char *value,
"Could not update attribute %s=%s for %s node %s%s: %s "
CRM_XS " rc=%d", name, value, node_type(is_remote), host,
when(), pcmk_rc_str(rc), rc);


if (AM_I_DC) {
/* We are unable to provide accurate information to the
* scheduler, so allow another node to take over DC.
* @TODO Should we do this unconditionally on any failure?
*/
crmd_exit(CRM_EX_FATAL);

} else if (pcmk_is_set(fsa_input_register, R_SHUTDOWN)) {
// Fast-track shutdown since unable to request via attribute
register_fsa_input(C_FSA_INTERNAL, I_FAIL, NULL);
}
handle_attr_error();
break;
}
}
Expand Down

0 comments on commit 36558d3

Please sign in to comment.