From de67fa2441555bbf7239646cde6ce31b8b53c05d Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 16 Oct 2019 15:58:11 +0900 Subject: [PATCH] standby clone: simplify data directory check Now we no longer care about the upstream's data directory, and normally expect to find the data directory in repmgr.conf, we can just exit with an error in the corner case that no repmgr.conf is provided and no data directory specified with -D/--pgdata. --- repmgr-action-standby.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index c66ba7fe..5c6cd713 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -68,7 +68,6 @@ static PGconn *primary_conn = NULL; static PGconn *source_conn = NULL; static char local_data_directory[MAXPGPATH] = ""; -static bool local_data_directory_provided = false; static bool upstream_conninfo_found = false; static int upstream_node_id = UNKNOWN_NODE_ID; @@ -155,6 +154,8 @@ do_standby_clone(void) /* dummy node record */ t_node_info local_node_record = T_NODE_INFO_INITIALIZER; + bool local_data_directory_provided = false; + initialize_conninfo_params(&recovery_conninfo, false); /* @@ -187,13 +188,14 @@ do_standby_clone(void) log_notice(_("destination directory \"%s\" provided"), local_data_directory); } - else if (mode == barman) + else { /* - * XXX in Barman mode it's still possible to connect to the upstream, - * so only fail if that's not available. + * If a configuration file is provided, repmgr will error out after + * parsing it if no data directory is provided; this check is for + * niche use-cases where no configuration file is provided. */ - log_error(_("Barman mode requires a data directory")); + log_error(_("no data directory provided")); log_hint(_("use -D/--pgdata to explicitly specify a data directory")); exit(ERR_BAD_CONFIG); } @@ -4993,17 +4995,6 @@ check_source_server() } } - /* - * If no target data directory was explicitly provided, we'll default to - * the source host's data directory. - */ - if (local_data_directory_provided == false) - { - log_error(_("no data directory provided")); - log_hint(_("use -D/--pgdata to explicitly specify a data directory")); - PQfinish(source_conn); - exit(ERR_BAD_CONFIG); - } /* * Check the local directory to see if it appears to be a PostgreSQL