From 10f00b88225ddfbdf0d8a428d6674e28adb41027 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 17 Sep 2019 15:30:21 +0900 Subject: [PATCH] repmgr: pass explicitly provided log level when executing repmgr remotely This makes it possible to return log output when executing repmgr remotely at a different level to the one defined in the remote repmgr's repmgr.conf. This is particularly useful when DEBUG output is required. --- HISTORY | 1 + doc/appendix-release-notes.xml | 16 ++++++++++++++++ repmgr-action-cluster.c | 27 +++++++++++++++++++++++++-- repmgr-client.c | 12 ++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index b78b2160..95169f2f 100644 --- a/HISTORY +++ b/HISTORY @@ -4,6 +4,7 @@ repmgr: rename "repmgr daemon ..." commands to "repmgr service ..." (Ian) repmgr: improve data directory check (Ian) repmgr: improve extension check during "standby clone" (Ian) + repmgr: pass provided log level when executing repmgr remotely (Ian) 4.4 2019-06-27 repmgr: improve "daemon status" output (Ian) diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index ce8443bd..e1dc3eab 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -194,6 +194,22 @@ conninfo='host=node1 user=repmgr dbname=repmgr connect_timeout=2' + + + + When executing &repmgr; remotely, if the &repmgr; log level was explicitly + provided (with /), that log level + will be passed to the remote &repmgr;. + + + This makes it possible to return log output when executing repmgr + remotely at a different level to the one defined in the remote + &repmgr;'s repmgr.conf. + + + This is particularly useful when DEBUG output is required. + + diff --git a/repmgr-action-cluster.c b/repmgr-action-cluster.c index 1fe913a8..a89caba5 100644 --- a/repmgr-action-cluster.c +++ b/repmgr-action-cluster.c @@ -987,7 +987,19 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length, Ite make_remote_repmgr_path(&command, cell->node_info); appendPQExpBufferStr(&command, - " cluster show --csv -L NOTICE --terse\""); + " cluster show --csv --terse"); + + /* + * Usually we'll want NOTICE as the log level, but if the user + * explicitly provided one with --log-level, that will be passed + * in the remote repmgr invocation. + */ + if (runtime_options.log_level[0] == '\0') + { + appendPQExpBufferStr(&command, + " -L NOTICE"); + } + appendPQExpBufferChar(&command, '"'); log_verbose(LOG_DEBUG, "build_cluster_matrix(): executing:\n %s", command.data); @@ -1175,7 +1187,18 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length, Item make_remote_repmgr_path(&command, cell->node_info); appendPQExpBufferStr(&command, - " cluster matrix --csv -L NOTICE --terse"); + " cluster matrix --csv --terse"); + + /* + * Usually we'll want NOTICE as the log level, but if the user + * explicitly provided one with --log-level, that will be passed + * in the remote repmgr invocation. + */ + if (runtime_options.log_level[0] == '\0') + { + appendPQExpBufferStr(&command, + " -L NOTICE"); + } initPQExpBuffer(&command_output); diff --git a/repmgr-client.c b/repmgr-client.c index 7790d846..9f8c6e78 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -3167,6 +3167,18 @@ make_remote_repmgr_path(PQExpBufferData *output_buf, t_node_info *remote_node_re "%s -f %s ", progname(), remote_node_record->config_file); + + /* + * If --log-level was explicitly supplied, pass that through + * to the remote repmgr client too. + */ + if (runtime_options.log_level[0] != '\0') + { + appendPQExpBuffer(output_buf, + " -L %s ", + runtime_options.log_level); + } + }