Skip to content

Commit

Permalink
Fix: crmadmin: return error if DC is not elected #2902 #3606
Browse files Browse the repository at this point in the history
If the DC is not yet elected, the crmadmin will return an error.
(This change complements #3606).
  • Loading branch information
Aleksei Burlakov committed Nov 11, 2024
1 parent 26f9591 commit 2f31653
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/crm/common/results.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ typedef enum crm_exit_e {
CRM_EX_NOT_YET_IN_EFFECT = 111, //!< Requested item is not in effect
CRM_EX_INDETERMINATE = 112, //!< Could not determine status
CRM_EX_UNSATISFIED = 113, //!< Requested item does not satisfy constraints
CRM_EX_DC_NOT_ELECTED_YET = 114, //!< DC is not yet elected, e.g. right after cluster restart

// Other
CRM_EX_TIMEOUT = 124, //!< Convention from timeout(1)
Expand Down
2 changes: 2 additions & 0 deletions lib/common/results.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ crm_exit_name(crm_exit_t exit_code)
case CRM_EX_NOT_YET_IN_EFFECT: return "CRM_EX_NOT_YET_IN_EFFECT";
case CRM_EX_INDETERMINATE: return "CRM_EX_INDETERMINATE";
case CRM_EX_UNSATISFIED: return "CRM_EX_UNSATISFIED";
case CRM_EX_DC_NOT_ELECTED_YET: return "CRM_EX_DC_NOT_ELECTED_YET";
case CRM_EX_OLD: return "CRM_EX_OLD";
case CRM_EX_TIMEOUT: return "CRM_EX_TIMEOUT";
case CRM_EX_DEGRADED: return "CRM_EX_DEGRADED";
Expand Down Expand Up @@ -786,6 +787,7 @@ crm_exit_str(crm_exit_t exit_code)
case CRM_EX_NOT_YET_IN_EFFECT: return "Requested item is not yet in effect";
case CRM_EX_INDETERMINATE: return "Could not determine status";
case CRM_EX_UNSATISFIED: return "Not applicable under current conditions";
case CRM_EX_DC_NOT_ELECTED_YET: return "DC is not yet elected";
case CRM_EX_OLD: return "Update was older than existing configuration";
case CRM_EX_TIMEOUT: return "Timeout occurred";
case CRM_EX_DEGRADED: return "Service is active but might fail soon";
Expand Down
3 changes: 1 addition & 2 deletions lib/pacemaker/pcmk_cluster_queries.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ designated_controller_event_cb(pcmk_ipc_api_t *controld_api,
}

reply = (const pcmk_controld_api_reply_t *) event_data;
out->message(out, "dc", reply->host_from);
data->rc = pcmk_rc_ok;
data->rc = out->message(out, "dc", reply->host_from);
}

/*!
Expand Down
6 changes: 5 additions & 1 deletion lib/pacemaker/pcmk_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,12 @@ dc(pcmk__output_t *out, va_list args)
{
const char *dc = va_arg(args, const char *);

return out->info(out, "Designated Controller is: %s",
int rc = out->info(out, "Designated Controller is: %s",
pcmk__s(dc, "not yet elected"));
if (dc)
return rc;
else
return CRM_EX_DC_NOT_ELECTED_YET;
}

PCMK__OUTPUT_ARGS("dc", "const char *")
Expand Down

0 comments on commit 2f31653

Please sign in to comment.