From dd45189fa88b38563a49f61ca98386455ceff9f7 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 5 Feb 2018 10:32:20 +0900 Subject: [PATCH] "cluster show": output any connection error messagesin list of warnings This ensures any connection errors are displayed by default in a comprehensible, easily reportable way, and saves having to request/filter DEBUG output. Implements GitHub #369. --- repmgr-action-cluster.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/repmgr-action-cluster.c b/repmgr-action-cluster.c index 6a06320a..da9fa47b 100644 --- a/repmgr-action-cluster.c +++ b/repmgr-action-cluster.c @@ -140,8 +140,14 @@ do_cluster_show(void) } else { + char error[MAXLEN]; + + strncpy(error, PQerrorMessage(cell->node_info->conn), MAXLEN); cell->node_info->node_status = NODE_STATUS_DOWN; cell->node_info->recovery_type = RECTYPE_UNKNOWN; + item_list_append_format(&warnings, + "when attempting to connect to node \"%s\" (ID: %i), following error encountered :\n\"%s\"", + cell->node_info->node_name, cell->node_info->node_id, trim(error)); } initPQExpBuffer(&details); @@ -416,7 +422,7 @@ do_cluster_show(void) printf(_("\nWARNING: following issues were detected\n")); for (cell = warnings.head; cell; cell = cell->next) { - printf(_(" %s\n"), cell->string); + printf(_(" - %s\n"), cell->string); } } }