Remove ssh_hostname support

Currently repmgr assumes the SSH hostname will be the same as the
database hostname, and it's easy enough now to extract this
from the node's conninfo string.

We can consider re-adding this in the next release if required.
This commit is contained in:
Ian Barwick
2016-09-29 00:24:04 +09:00
parent 9b5b9acb82
commit 41ec45a4cc
8 changed files with 23 additions and 54 deletions

View File

@@ -1607,8 +1607,7 @@ which contains connection details for the local database.
replication cluster. This command polls each registered server and replication cluster. This command polls each registered server and
asks it to connect to each other node. asks it to connect to each other node.
This command requires a valid `repmgr.conf` file on each node, This command requires a valid `repmgr.conf` file on each node.
with the optional `ssh_hostname` parameter set.
Example 1 (all nodes up): Example 1 (all nodes up):

View File

@@ -217,7 +217,6 @@ parse_config(t_configuration_options *options)
memset(options->conninfo, 0, sizeof(options->conninfo)); memset(options->conninfo, 0, sizeof(options->conninfo));
memset(options->barman_server, 0, sizeof(options->barman_server)); memset(options->barman_server, 0, sizeof(options->barman_server));
memset(options->barman_config, 0, sizeof(options->barman_config)); memset(options->barman_config, 0, sizeof(options->barman_config));
memset(options->ssh_hostname, 0, sizeof(options->ssh_hostname));
options->failover = MANUAL_FAILOVER; options->failover = MANUAL_FAILOVER;
options->priority = DEFAULT_PRIORITY; options->priority = DEFAULT_PRIORITY;
memset(options->node_name, 0, sizeof(options->node_name)); memset(options->node_name, 0, sizeof(options->node_name));
@@ -317,8 +316,6 @@ parse_config(t_configuration_options *options)
strncpy(options->barman_server, value, MAXLEN); strncpy(options->barman_server, value, MAXLEN);
else if (strcmp(name, "barman_config") == 0) else if (strcmp(name, "barman_config") == 0)
strncpy(options->barman_config, value, MAXLEN); strncpy(options->barman_config, value, MAXLEN);
else if (strcmp(name, "ssh_hostname") == 0)
strncpy(options->ssh_hostname, value, MAXLEN);
else if (strcmp(name, "rsync_options") == 0) else if (strcmp(name, "rsync_options") == 0)
strncpy(options->rsync_options, value, QUERY_STR_LEN); strncpy(options->rsync_options, value, QUERY_STR_LEN);
else if (strcmp(name, "ssh_options") == 0) else if (strcmp(name, "ssh_options") == 0)
@@ -455,10 +452,6 @@ parse_config(t_configuration_options *options)
PQconninfoFree(conninfo_options); PQconninfoFree(conninfo_options);
} }
/*
* TODO: Sanity check ssh_hostname
*/
if (config_errors.head != NULL) if (config_errors.head != NULL)
{ {
exit_with_errors(&config_errors); exit_with_errors(&config_errors);
@@ -627,10 +620,6 @@ reload_config(t_configuration_options *orig_options)
PQfinish(conn); PQfinish(conn);
} }
/*
* TODO: Sanity check the new ssh_hostname
*/
/* /*
* No configuration problems detected - copy any changed values * No configuration problems detected - copy any changed values
* *
@@ -659,13 +648,6 @@ reload_config(t_configuration_options *orig_options)
config_changed = true; config_changed = true;
} }
/* ssh_hostname */
if (strcmp(orig_options->ssh_hostname, new_options.ssh_hostname) != 0)
{
strcpy(orig_options->ssh_hostname, new_options.ssh_hostname);
config_changed = true;
}
/* node */ /* node */
if (orig_options->node != new_options.node) if (orig_options->node != new_options.node)
{ {

View File

@@ -60,7 +60,6 @@ typedef struct
char conninfo[MAXLEN]; char conninfo[MAXLEN];
char barman_server[MAXLEN]; char barman_server[MAXLEN];
char barman_config[MAXLEN]; char barman_config[MAXLEN];
char ssh_hostname[MAXLEN];
int failover; int failover;
int priority; int priority;
char node_name[MAXLEN]; char node_name[MAXLEN];
@@ -94,7 +93,7 @@ typedef struct
* The following will initialize the structure with a minimal set of options; * The following will initialize the structure with a minimal set of options;
* actual defaults are set in parse_config() before parsing the configuration file * actual defaults are set in parse_config() before parsing the configuration file
*/ */
#define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, { NULL, NULL } } #define T_CONFIGURATION_OPTIONS_INITIALIZER { "", -1, NO_UPSTREAM_NODE, "", "", "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", "", "", "", -1, -1, -1, "", "", "", "", "", 0, 0, 0, 0, "", { NULL, NULL }, { NULL, NULL } }
typedef struct ItemListCell typedef struct ItemListCell
{ {

View File

@@ -1227,7 +1227,7 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
/* Get current records from primary */ /* Get current records from primary */
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"SELECT id, type, upstream_node_id, name, conninfo, ssh_command, priority, slot_name, active FROM %s.repl_nodes", "SELECT id, type, upstream_node_id, name, conninfo, priority, slot_name, active FROM %s.repl_nodes",
get_repmgr_schema_quoted(masterconn)); get_repmgr_schema_quoted(masterconn));
log_verbose(LOG_DEBUG, "witness_copy_node_records():\n%s\n", sqlquery); log_verbose(LOG_DEBUG, "witness_copy_node_records():\n%s\n", sqlquery);
@@ -1263,7 +1263,6 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
cluster_name, cluster_name,
PQgetvalue(res, i, 3), PQgetvalue(res, i, 3),
PQgetvalue(res, i, 4), PQgetvalue(res, i, 4),
PQgetvalue(res, i, 5),
atoi(PQgetvalue(res, i, 6)), atoi(PQgetvalue(res, i, 6)),
strlen(PQgetvalue(res, i, 7)) strlen(PQgetvalue(res, i, 7))
? PQgetvalue(res, i, 7) ? PQgetvalue(res, i, 7)
@@ -1301,7 +1300,7 @@ witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster
* XXX we should pass the record parameters as a struct. * XXX we should pass the record parameters as a struct.
*/ */
bool bool
create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, char *ssh_hostname, int priority, char *slot_name, bool active) create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, int priority, char *slot_name, bool active)
{ {
char sqlquery[QUERY_STR_LEN]; char sqlquery[QUERY_STR_LEN];
char upstream_node_id[MAXLEN]; char upstream_node_id[MAXLEN];
@@ -1342,9 +1341,9 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"INSERT INTO %s.repl_nodes " "INSERT INTO %s.repl_nodes "
" (id, type, upstream_node_id, cluster, " " (id, type, upstream_node_id, cluster, "
" name, conninfo, ssh_hostname, slot_name, " " name, conninfo, slot_name, "
" priority, active) " " priority, active) "
"VALUES (%i, '%s', %s, '%s', '%s', '%s', '%s', %s, %i, %s) ", "VALUES (%i, '%s', %s, '%s', '%s', '%s', %s, %i, %s) ",
get_repmgr_schema_quoted(conn), get_repmgr_schema_quoted(conn),
node, node,
type, type,
@@ -1352,7 +1351,6 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
cluster_name, cluster_name,
node_name, node_name,
conninfo, conninfo,
ssh_hostname,
slot_name_buf, slot_name_buf,
priority, priority,
active == true ? "TRUE" : "FALSE"); active == true ? "TRUE" : "FALSE");
@@ -1719,7 +1717,7 @@ get_node_record(PGconn *conn, char *cluster, int node_id, t_node_info *node_info
sqlquery_snprintf( sqlquery_snprintf(
sqlquery, sqlquery,
"SELECT id, type, upstream_node_id, name, conninfo, ssh_hostname, " "SELECT id, type, upstream_node_id, name, conninfo, "
" slot_name, priority, active" " slot_name, priority, active"
" FROM %s.repl_nodes " " FROM %s.repl_nodes "
" WHERE cluster = '%s' " " WHERE cluster = '%s' "
@@ -1793,10 +1791,9 @@ _get_node_record(PGconn *conn, char *cluster, char *sqlquery, t_node_info *node_
node_info->upstream_node_id = atoi(PQgetvalue(res, 0, 2)); node_info->upstream_node_id = atoi(PQgetvalue(res, 0, 2));
strncpy(node_info->name, PQgetvalue(res, 0, 3), MAXLEN); strncpy(node_info->name, PQgetvalue(res, 0, 3), MAXLEN);
strncpy(node_info->conninfo_str, PQgetvalue(res, 0, 4), MAXLEN); strncpy(node_info->conninfo_str, PQgetvalue(res, 0, 4), MAXLEN);
strncpy(node_info->ssh_hostname_str, PQgetvalue(res, 0, 5), MAXLEN); strncpy(node_info->slot_name, PQgetvalue(res, 0, 5), MAXLEN);
strncpy(node_info->slot_name, PQgetvalue(res, 0, 6), MAXLEN); node_info->priority = atoi(PQgetvalue(res, 0, 6));
node_info->priority = atoi(PQgetvalue(res, 0, 7)); node_info->active = (strcmp(PQgetvalue(res, 0, 7), "t") == 0)
node_info->active = (strcmp(PQgetvalue(res, 0, 8), "t") == 0)
? true ? true
: false; : false;

View File

@@ -45,7 +45,6 @@ typedef struct s_node_info
t_server_type type; t_server_type type;
char name[MAXLEN]; char name[MAXLEN];
char conninfo_str[MAXLEN]; char conninfo_str[MAXLEN];
char ssh_hostname_str[MAXLEN];
char slot_name[MAXLEN]; char slot_name[MAXLEN];
int priority; int priority;
bool active; bool active;
@@ -62,7 +61,6 @@ typedef struct s_node_info
"", \ "", \
"", \ "", \
"", \ "", \
"", \
DEFAULT_PRIORITY, \ DEFAULT_PRIORITY, \
true, \ true, \
false, \ false, \
@@ -128,7 +126,7 @@ bool start_backup(PGconn *conn, char *first_wal_segment, bool fast_checkpoint);
bool stop_backup(PGconn *conn, char *last_wal_segment); bool stop_backup(PGconn *conn, char *last_wal_segment);
bool set_config_bool(PGconn *conn, const char *config_param, bool state); bool set_config_bool(PGconn *conn, const char *config_param, bool state);
bool witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster_name); bool witness_copy_node_records(PGconn *masterconn, PGconn *witnessconn, char *cluster_name);
bool create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, char *ssh_hostname, int priority, char *slot_name, bool active); bool create_node_record(PGconn *conn, char *action, int node, char *type, int upstream_node, char *cluster_name, char *node_name, char *conninfo, int priority, char *slot_name, bool active);
bool delete_node_record(PGconn *conn, int node, char *action); bool delete_node_record(PGconn *conn, int node, char *action);
int get_node_record(PGconn *conn, char *cluster, int node_id, t_node_info *node_info); int get_node_record(PGconn *conn, char *cluster, int node_id, t_node_info *node_info);
int get_node_record_by_name(PGconn *conn, char *cluster, const char *node_name, t_node_info *node_info); int get_node_record_by_name(PGconn *conn, char *cluster, const char *node_name, t_node_info *node_info);

View File

@@ -1105,7 +1105,7 @@ do_cluster_matrix(void)
conn = establish_db_connection(options.conninfo, true); conn = establish_db_connection(options.conninfo, true);
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"SELECT conninfo, ssh_hostname, type, name, upstream_node_name, id" "SELECT conninfo, type, name, upstream_node_name, id"
" FROM %s.repl_show_nodes", " FROM %s.repl_show_nodes",
get_repmgr_schema_quoted(conn)); get_repmgr_schema_quoted(conn));
@@ -1144,7 +1144,7 @@ do_cluster_matrix(void)
{ {
int name_length_cur; int name_length_cur;
name_length_cur = strlen(PQgetvalue(res, i, 3)); name_length_cur = strlen(PQgetvalue(res, i, 2));
if (name_length_cur > name_length) if (name_length_cur > name_length)
name_length = name_length_cur; name_length = name_length_cur;
} }
@@ -1152,6 +1152,11 @@ do_cluster_matrix(void)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
int connection_status; int connection_status;
t_conninfo_param_list remote_conninfo;
char *host;
initialize_conninfo_params(&remote_conninfo, false);
host = param_get(&remote_conninfo, "host");
conn = establish_db_connection(PQgetvalue(res, i, 0), false); conn = establish_db_connection(PQgetvalue(res, i, 0), false);
@@ -1173,7 +1178,7 @@ do_cluster_matrix(void)
initPQExpBuffer(&command_output); initPQExpBuffer(&command_output);
(void)remote_command( (void)remote_command(
PQgetvalue(res, i, 1), host,
"postgres", "postgres",
command, command,
&command_output); &command_output);
@@ -1226,7 +1231,7 @@ do_cluster_matrix(void)
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
printf("%*s | %2d ", name_length, printf("%*s | %2d ", name_length,
PQgetvalue(res, i, 3), i + 1); PQgetvalue(res, i, 2), i + 1);
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
{ {
switch (matrix[i * n + j]) switch (matrix[i * n + j])
@@ -1475,7 +1480,6 @@ do_master_register(void)
options.cluster_name, options.cluster_name,
options.node_name, options.node_name,
options.conninfo, options.conninfo,
options.ssh_hostname,
options.priority, options.priority,
repmgr_slot_name_ptr, repmgr_slot_name_ptr,
true); true);
@@ -1601,7 +1605,6 @@ do_standby_register(void)
options.cluster_name, options.cluster_name,
options.node_name, options.node_name,
options.conninfo, options.conninfo,
options.ssh_hostname,
options.priority, options.priority,
repmgr_slot_name_ptr, repmgr_slot_name_ptr,
true); true);
@@ -5533,7 +5536,6 @@ do_witness_register(PGconn *masterconn)
options.cluster_name, options.cluster_name,
options.node_name, options.node_name,
options.conninfo, options.conninfo,
options.ssh_hostname,
options.priority, options.priority,
NULL, NULL,
true); true);
@@ -6531,7 +6533,6 @@ create_schema(PGconn *conn)
" cluster TEXT NOT NULL, " " cluster TEXT NOT NULL, "
" name TEXT NOT NULL, " " name TEXT NOT NULL, "
" conninfo TEXT NOT NULL, " " conninfo TEXT NOT NULL, "
" ssh_hostname TEXT NULL, "
" slot_name TEXT NULL, " " slot_name TEXT NULL, "
" priority INTEGER NOT NULL, " " priority INTEGER NOT NULL, "
" active BOOLEAN NOT NULL DEFAULT TRUE )", " active BOOLEAN NOT NULL DEFAULT TRUE )",
@@ -6667,7 +6668,7 @@ create_schema(PGconn *conn)
/* CREATE VIEW repl_show_nodes */ /* CREATE VIEW repl_show_nodes */
sqlquery_snprintf(sqlquery, sqlquery_snprintf(sqlquery,
"CREATE VIEW %s.repl_show_nodes AS " "CREATE VIEW %s.repl_show_nodes AS "
"SELECT rn.id, rn.conninfo, rn.ssh_hostname, " "SELECT rn.id, rn.conninfo, "
" rn.type, rn.name, rn.cluster," " rn.type, rn.name, rn.cluster,"
" rn.priority, rn.active, sq.name AS upstream_node_name" " rn.priority, rn.active, sq.name AS upstream_node_name"
" FROM %s.repl_nodes as rn" " FROM %s.repl_nodes as rn"

View File

@@ -42,12 +42,6 @@
# Optional configuration items # Optional configuration items
# ============================ # ============================
# SSH connection information
# We recommend using the "postgres" user, so it is enough to indicate the hostname.
# If extra parameters such as port, etc. are needed, they can be
# specified in the .ssh/config file.
#ssh_hostname='192.168.204.104'
# Replication settings # Replication settings
# --------------------- # ---------------------

View File

@@ -17,7 +17,6 @@ CREATE TABLE repl_nodes (
cluster text not null, -- Name to identify the cluster cluster text not null, -- Name to identify the cluster
name text not null, name text not null,
conninfo text not null, conninfo text not null,
ssh_command text,
priority integer not null, priority integer not null,
witness boolean not null default false witness boolean not null default false
); );
@@ -65,7 +64,7 @@ CREATE INDEX idx_repl_status_sort ON repl_monitor(last_monitor_time, standby_nod
* This view shows the list of nodes with the information of which one is the upstream * This view shows the list of nodes with the information of which one is the upstream
* in each case (when appliable) * in each case (when appliable)
*/ */
CREATE VIEW repl_show_nodes AS CREATE VIEW repl_show_nodes AS
SELECT rn.id, rn.conninfo, rn.ssh_command, rn.type, rn.name, rn.cluster, SELECT rn.id, rn.conninfo, rn.type, rn.name, rn.cluster,
rn.priority, rn.active, sq.name AS upstream_node_name rn.priority, rn.active, sq.name AS upstream_node_name
FROM repl_nodes as rn LEFT JOIN repl_nodes AS sq ON sq.id=rn.upstream_node_id; FROM repl_nodes as rn LEFT JOIN repl_nodes AS sq ON sq.id=rn.upstream_node_id;