From aac55a2f9ba09db9296f8d1e3e502cf432c432a5 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). --- lib/pacemaker/pcmk_cluster_queries.c | 3 +-- lib/pacemaker/pcmk_output.c | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/pacemaker/pcmk_cluster_queries.c b/lib/pacemaker/pcmk_cluster_queries.c index 3f7584e9ff7..56eff7bd23f 100644 --- a/lib/pacemaker/pcmk_cluster_queries.c +++ b/lib/pacemaker/pcmk_cluster_queries.c @@ -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); } /*! diff --git a/lib/pacemaker/pcmk_output.c b/lib/pacemaker/pcmk_output.c index 7a1a7018ae1..5dd15de621e 100644 --- a/lib/pacemaker/pcmk_output.c +++ b/lib/pacemaker/pcmk_output.c @@ -887,9 +887,13 @@ 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 pcmk_rc_undetermined; + } PCMK__OUTPUT_ARGS("dc", "const char *") static int