Skip to content

Commit a1d94f7

Browse files
Aleksei BurlakovAleksei Burlakov
Aleksei Burlakov
authored and
Aleksei Burlakov
committed
Fix: crmadmin: return error if DC is not elected #2902 #3606
If the DC is not yet elected, the crmadmin will return an error. (This change complements #3606).
1 parent 4540673 commit a1d94f7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

cts/cli/regression.error_codes.exp

+4
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ CRM_EX_ERROR - Error occurred
404404
111: Requested item is not yet in effect
405405
112: Could not determine status
406406
113: Not applicable under current conditions
407+
114: DC is not yet elected
407408
124: Timeout occurred
408409
190: Service is active but might fail soon
409410
191: Service is promoted but might fail soon
@@ -451,6 +452,7 @@ CRM_EX_ERROR - Error occurred
451452
<result-code code="111" description="Requested item is not yet in effect"/>
452453
<result-code code="112" description="Could not determine status"/>
453454
<result-code code="113" description="Not applicable under current conditions"/>
455+
<result-code code="114" description="DC is not yet elected"/>
454456
<result-code code="124" description="Timeout occurred"/>
455457
<result-code code="190" description="Service is active but might fail soon"/>
456458
<result-code code="191" description="Service is promoted but might fail soon"/>
@@ -499,6 +501,7 @@ CRM_EX_ERROR - Error occurred
499501
111: CRM_EX_NOT_YET_IN_EFFECT Requested item is not yet in effect
500502
112: CRM_EX_INDETERMINATE Could not determine status
501503
113: CRM_EX_UNSATISFIED Not applicable under current conditions
504+
114: CRM_EX_NO_DC DC is not yet elected
502505
124: CRM_EX_TIMEOUT Timeout occurred
503506
190: CRM_EX_DEGRADED Service is active but might fail soon
504507
191: CRM_EX_DEGRADED_PROMOTED Service is promoted but might fail soon
@@ -546,6 +549,7 @@ CRM_EX_ERROR - Error occurred
546549
<result-code code="111" name="CRM_EX_NOT_YET_IN_EFFECT" description="Requested item is not yet in effect"/>
547550
<result-code code="112" name="CRM_EX_INDETERMINATE" description="Could not determine status"/>
548551
<result-code code="113" name="CRM_EX_UNSATISFIED" description="Not applicable under current conditions"/>
552+
<result-code code="114" name="CRM_EX_NO_DC" description="DC is not yet elected"/>
549553
<result-code code="124" name="CRM_EX_TIMEOUT" description="Timeout occurred"/>
550554
<result-code code="190" name="CRM_EX_DEGRADED" description="Service is active but might fail soon"/>
551555
<result-code code="191" name="CRM_EX_DEGRADED_PROMOTED" description="Service is promoted but might fail soon"/>

include/crm/common/results.h

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ enum pcmk_rc_e {
111111
/* When adding new values, use consecutively lower numbers, update the array
112112
* in lib/common/results.c, and test with crm_error.
113113
*/
114+
pcmk_rc_no_dc = -1040,
114115
pcmk_rc_compression = -1039,
115116
pcmk_rc_ns_resolution = -1038,
116117
pcmk_rc_no_transaction = -1037,
@@ -273,6 +274,7 @@ typedef enum crm_exit_e {
273274
CRM_EX_NOT_YET_IN_EFFECT = 111, //!< Requested item is not in effect
274275
CRM_EX_INDETERMINATE = 112, //!< Could not determine status
275276
CRM_EX_UNSATISFIED = 113, //!< Requested item does not satisfy constraints
277+
CRM_EX_NO_DC = 114, //!< DC is not yet elected, e.g. right after cluster restart
276278

277279
// Other
278280
CRM_EX_TIMEOUT = 124, //!< Convention from timeout(1)

lib/common/results.c

+5
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ crm_exit_name(crm_exit_t exit_code)
734734
case CRM_EX_NOT_YET_IN_EFFECT: return "CRM_EX_NOT_YET_IN_EFFECT";
735735
case CRM_EX_INDETERMINATE: return "CRM_EX_INDETERMINATE";
736736
case CRM_EX_UNSATISFIED: return "CRM_EX_UNSATISFIED";
737+
case CRM_EX_NO_DC: return "CRM_EX_NO_DC";
737738
case CRM_EX_OLD: return "CRM_EX_OLD";
738739
case CRM_EX_TIMEOUT: return "CRM_EX_TIMEOUT";
739740
case CRM_EX_DEGRADED: return "CRM_EX_DEGRADED";
@@ -786,6 +787,7 @@ crm_exit_str(crm_exit_t exit_code)
786787
case CRM_EX_NOT_YET_IN_EFFECT: return "Requested item is not yet in effect";
787788
case CRM_EX_INDETERMINATE: return "Could not determine status";
788789
case CRM_EX_UNSATISFIED: return "Not applicable under current conditions";
790+
case CRM_EX_NO_DC: return "DC is not yet elected";
789791
case CRM_EX_OLD: return "Update was older than existing configuration";
790792
case CRM_EX_TIMEOUT: return "Timeout occurred";
791793
case CRM_EX_DEGRADED: return "Service is active but might fail soon";
@@ -922,6 +924,9 @@ pcmk_rc2exitc(int rc)
922924
case pcmk_rc_bad_xml_patch:
923925
return CRM_EX_DATAERR;
924926

927+
case pcmk_rc_no_dc:
928+
return CRM_EX_NO_DC;
929+
925930
default:
926931
return CRM_EX_ERROR;
927932
}

lib/pacemaker/pcmk_cluster_queries.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ designated_controller_event_cb(pcmk_ipc_api_t *controld_api,
235235

236236
reply = (const pcmk_controld_api_reply_t *) event_data;
237237
out->message(out, "dc", reply->host_from);
238-
data->rc = pcmk_rc_ok;
238+
data->rc = reply->host_from ? pcmk_rc_ok : pcmk_rc_no_dc;
239239
}
240240

241241
/*!

0 commit comments

Comments
 (0)