Fix "repmgr cluster crosscheck" output

Addresses GitHub #398.
This commit is contained in:
Ian Barwick
2018-03-27 10:24:36 +09:00
parent 37e53108a2
commit deea4f69f7
4 changed files with 26 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
4.0.5 2018-??-??
repmgr: fix display of conninfo parsing error messages (Ian)
repmgr: fix "repmgr cluster crosscheck" output; GitHub #389 (Ian)
repmgrd: fix memory leaks in witness code (AndrzejNowicki, Martín)
4.0.4 2018-03-09

View File

@@ -964,8 +964,7 @@ build_cluster_matrix(t_node_matrix_rec ***matrix_rec_dest, int *name_length)
initPQExpBuffer(&command_output);
(void) remote_command(
host,
(void) remote_command(host,
runtime_options.remote_user,
command.data,
&command_output);
@@ -1144,9 +1143,8 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length)
/* fix to work with --node-id */
if (cube[i]->node_id == config_file_options.node_id)
{
(void) local_command(
command.data,
&command_output);
(void) local_command_simple(command.data,
&command_output);
}
else
{
@@ -1170,8 +1168,7 @@ build_cluster_crosscheck(t_node_status_cube ***dest_cube, int *name_length)
log_verbose(LOG_DEBUG, "build_cluster_crosscheck(): executing\n %s", quoted_command.data);
(void) remote_command(
host,
(void) remote_command(host,
runtime_options.remote_user,
quoted_command.data,
&command_output);

View File

@@ -208,6 +208,7 @@ extern void check_93_config(void);
extern bool create_repmgr_extension(PGconn *conn);
extern int test_ssh_connection(char *host, char *remote_user);
extern bool local_command(const char *command, PQExpBufferData *outputbuf);
extern bool local_command_simple(const char *command, PQExpBufferData *outputbuf);
extern standy_clone_mode get_standby_clone_mode(void);

View File

@@ -90,6 +90,7 @@ t_node_info target_node_info = T_NODE_INFO_INITIALIZER;
static ItemList cli_errors = {NULL, NULL};
static ItemList cli_warnings = {NULL, NULL};
static bool _local_command(const char *command, PQExpBufferData *outputbuf, bool simple);
int
main(int argc, char **argv)
@@ -2096,12 +2097,28 @@ test_ssh_connection(char *host, char *remote_user)
}
/*
* Execute a command locally. "outputbuf" should either be an
* initialised PQexpbuffer, or NULL
*/
bool
local_command(const char *command, PQExpBufferData *outputbuf)
{
return _local_command(command, outputbuf, false);
}
bool
local_command_simple(const char *command, PQExpBufferData *outputbuf)
{
return _local_command(command, outputbuf, true);
}
static bool
_local_command(const char *command, PQExpBufferData *outputbuf, bool simple)
{
FILE *fp = NULL;
char output[MAXLEN];
@@ -2128,7 +2145,8 @@ local_command(const char *command, PQExpBufferData *outputbuf)
while (fgets(output, MAXLEN, fp) != NULL)
{
appendPQExpBuffer(outputbuf, "%s", output);
if (!feof(fp))
if (!feof(fp) && simple == false)
{
break;
}
@@ -2353,9 +2371,6 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
}
/*
* Execute a command via ssh on the remote host.
*
@@ -2421,7 +2436,7 @@ remote_command(const char *host, const char *user, const char *command, PQExpBuf
if (outputbuf != NULL)
{
if (strlen(outputbuf->data))
log_verbose(LOG_DEBUG, "remote_command(): output returned was:\n %s", outputbuf->data);
log_verbose(LOG_DEBUG, "remote_command(): output returned was:\n%s", outputbuf->data);
else
log_verbose(LOG_DEBUG, "remote_command(): no output returned");
}