From f0471b562f44e2d557c3d5650bbd1fc31ef807b1 Mon Sep 17 00:00:00 2001 From: Aleksei Burlakov Date: Sat, 2 Nov 2024 12:49:01 +0100 Subject: [PATCH] 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). --- include/crm/common/results.h | 1 + lib/common/results.c | 2 ++ lib/pacemaker/pcmk_cluster_queries.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/crm/common/results.h b/include/crm/common/results.h index 2fedb7c7364..116156a4313 100644 --- a/include/crm/common/results.h +++ b/include/crm/common/results.h @@ -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) diff --git a/lib/common/results.c b/lib/common/results.c index bad074b6fd9..cfc52b1168a 100644 --- a/lib/common/results.c +++ b/lib/common/results.c @@ -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"; @@ -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"; diff --git a/lib/pacemaker/pcmk_cluster_queries.c b/lib/pacemaker/pcmk_cluster_queries.c index 3f7584e9ff7..46679395036 100644 --- a/lib/pacemaker/pcmk_cluster_queries.c +++ b/lib/pacemaker/pcmk_cluster_queries.c @@ -235,7 +235,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 = reply->host_from ? pcmk_rc_ok : CRM_EX_DC_NOT_ELECTED_YET; } /*!