From 029164a817800db453c4deb0bf86bb522f69f1fb Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 7 May 2020 17:47:16 +0900 Subject: [PATCH] Make configuration default value usage more consistent --- configdata.c | 14 ++++++------- configfile.c | 2 +- repmgr-client.c | 1 - repmgr.h | 52 ++++++++++++++++++++++++++++++------------------- 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/configdata.c b/configdata.c index 037287d9..0bf55a01 100644 --- a/configdata.c +++ b/configdata.c @@ -181,7 +181,7 @@ struct ConfigFileSetting config_file_settings[] = "use_replication_slots", CONFIG_BOOL, { .boolptr = &config_file_options.use_replication_slots }, - { .booldefault = false }, + { .booldefault = DEFAULT_USE_REPLICATION_SLOTS }, {}, {}, {} @@ -246,13 +246,12 @@ struct ConfigFileSetting config_file_settings[] = "use_primary_conninfo_password", CONFIG_BOOL, { .boolptr = &config_file_options.use_primary_conninfo_password }, - { .booldefault = false }, + { .booldefault = DEFAULT_USE_PRIMARY_CONNINFO_PASSWORD }, {}, {}, {} }, /* passfile */ - // XXX canonicalize path? { "passfile", CONFIG_STRING, @@ -512,7 +511,7 @@ struct ConfigFileSetting config_file_settings[] = "monitoring_history", CONFIG_BOOL, { .boolptr = &config_file_options.monitoring_history }, - { .booldefault = false }, + { .booldefault = DEFAULT_MONITORING_HISTORY }, {}, {}, {} @@ -572,7 +571,7 @@ struct ConfigFileSetting config_file_settings[] = "standby_disconnect_on_failover", CONFIG_BOOL, { .boolptr = &config_file_options.standby_disconnect_on_failover }, - { .booldefault = false }, + { .booldefault = DEFAULT_STANDBY_DISCONNECT_ON_FAILOVER }, {}, {}, {} @@ -602,8 +601,7 @@ struct ConfigFileSetting config_file_settings[] = "primary_visibility_consensus", CONFIG_BOOL, { .boolptr = &config_file_options.primary_visibility_consensus }, - // XXX constant - { .booldefault = false }, + { .booldefault = DEFAULT_PRIMARY_VISIBILITY_CONSENSUS }, {}, {}, {} @@ -853,7 +851,7 @@ struct ConfigFileSetting config_file_settings[] = "ssh_options", CONFIG_STRING, { .strptr = config_file_options.ssh_options }, - { .strdefault = "" }, + { .strdefault = DEFAULT_SSH_OPTIONS }, {}, { .strmaxlen = sizeof(config_file_options.ssh_options) }, {} diff --git a/configfile.c b/configfile.c index 45bfe228..7b7af854 100644 --- a/configfile.c +++ b/configfile.c @@ -939,7 +939,7 @@ _parse_config_old(t_configuration_options *options, ItemList *error_list, ItemLi */ memset(options->rsync_options, 0, sizeof(options->rsync_options)); memset(options->ssh_options, 0, sizeof(options->ssh_options)); - strncpy(options->ssh_options, "-q -o ConnectTimeout=10", sizeof(options->ssh_options)); + strncpy(options->ssh_options, DEFAULT_SSH_OPTIONS, sizeof(options->ssh_options)); /*--------------------------- * undocumented test settings diff --git a/repmgr-client.c b/repmgr-client.c index 428cd453..4d6e016c 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -1079,7 +1079,6 @@ main(int argc, char **argv) runtime_options.terse, argv[0]); - //exit(0); check_cli_parameters(action); /* diff --git a/repmgr.h b/repmgr.h index 9bf03711..8735aa21 100644 --- a/repmgr.h +++ b/repmgr.h @@ -97,43 +97,55 @@ #define ARCHIVE_STATUS_DIR_ERROR -1 #define NO_DEGRADED_MONITORING_ELAPSED -1 +#define WALRECEIVER_DISABLE_TIMEOUT_VALUE 86400000 /* milliseconds */ + /* - * various default values - ensure repmgr.conf.sample is update - * if any of these are changed + * Default command line option parameter values */ -#define DEFAULT_LOCATION "default" -#define DEFAULT_PRIORITY 100 -#define DEFAULT_RECONNECTION_ATTEMPTS 6 /* seconds */ -#define DEFAULT_RECONNECTION_INTERVAL 10 /* seconds */ -#define DEFAULT_MONITORING_INTERVAL 2 /* seconds */ -#define DEFAULT_DEGRADED_MONITORING_TIMEOUT -1 /* seconds */ -#define DEFAULT_ASYNC_QUERY_TIMEOUT 60 /* seconds */ -#define DEFAULT_PRIMARY_NOTIFICATION_TIMEOUT 60 /* seconds */ -#define DEFAULT_REPMGRD_STANDBY_STARTUP_TIMEOUT -1 /*seconds */ -#define DEFAULT_CONNECTION_CHECK_TYPE CHECK_PING +#define DEFAULT_WAIT_START 30 /* seconds */ + +/* + * Default configuration file parameter values - ensure repmgr.conf.sample + * is update if any of these are changed + */ + +#define DEFAULT_USE_REPLICATION_SLOTS false +#define DEFAULT_USE_PRIMARY_CONNINFO_PASSWORD false +#define DEFAULT_PROMOTE_CHECK_TIMEOUT 60 /* seconds */ +#define DEFAULT_PROMOTE_CHECK_INTERVAL 1 /* seconds */ #define DEFAULT_PRIMARY_FOLLOW_TIMEOUT 60 /* seconds */ #define DEFAULT_STANDBY_FOLLOW_TIMEOUT 30 /* seconds */ +#define DEFAULT_SHUTDOWN_CHECK_TIMEOUT 60 /* seconds */ +#define DEFAULT_STANDBY_RECONNECT_TIMEOUT 60 /* seconds */ +#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */ #define DEFAULT_ARCHIVE_READY_WARNING 16 /* WAL files */ #define DEFAULT_ARCHIVE_READY_CRITICAL 128 /* WAL files */ #define DEFAULT_REPLICATION_LAG_WARNING 300 /* seconds */ #define DEFAULT_REPLICATION_LAG_CRITICAL 600 /* seconds */ #define DEFAULT_WITNESS_SYNC_INTERVAL 15 /* seconds */ -#define DEFAULT_WAIT_START 30 /* seconds */ -#define DEFAULT_PROMOTE_CHECK_TIMEOUT 60 /* seconds */ -#define DEFAULT_PROMOTE_CHECK_INTERVAL 1 /* seconds */ -#define DEFAULT_SHUTDOWN_CHECK_TIMEOUT 60 /* seconds */ -#define DEFAULT_STANDBY_RECONNECT_TIMEOUT 60 /* seconds */ -#define DEFAULT_NODE_REJOIN_TIMEOUT 60 /* seconds */ #define DEFAULT_WAL_RECEIVE_CHECK_TIMEOUT 30 /* seconds */ +#define DEFAULT_LOCATION "default" +#define DEFAULT_PRIORITY 100 +#define DEFAULT_MONITORING_INTERVAL 2 /* seconds */ +#define DEFAULT_RECONNECTION_ATTEMPTS 6 /* seconds */ +#define DEFAULT_RECONNECTION_INTERVAL 10 /* seconds */ +#define DEFAULT_MONITORING_HISTORY false +#define DEFAULT_DEGRADED_MONITORING_TIMEOUT -1 /* seconds */ +#define DEFAULT_ASYNC_QUERY_TIMEOUT 60 /* seconds */ +#define DEFAULT_PRIMARY_NOTIFICATION_TIMEOUT 60 /* seconds */ +#define DEFAULT_REPMGRD_STANDBY_STARTUP_TIMEOUT -1 /*seconds */ +#define DEFAULT_STANDBY_DISCONNECT_ON_FAILOVER false #define DEFAULT_SIBLING_NODES_DISCONNECT_TIMEOUT 30 /* seconds */ +#define DEFAULT_CONNECTION_CHECK_TYPE CHECK_PING +#define DEFAULT_PRIMARY_VISIBILITY_CONSENSUS false #define DEFAULT_ELECTION_RERUN_INTERVAL 15 /* seconds */ #define DEFAULT_CHILD_NODES_CHECK_INTERVAL 5 /* seconds */ #define DEFAULT_CHILD_NODES_DISCONNECT_MIN_COUNT -1 #define DEFAULT_CHILD_NODES_CONNECTED_MIN_COUNT -1 -#define DEFAULT_CHILD_NODES_DISCONNECT_TIMEOUT 30 /* seconds */ #define DEFAULT_CHILD_NODES_CONNECTED_INCLUDE_WITNESS false +#define DEFAULT_CHILD_NODES_DISCONNECT_TIMEOUT 30 /* seconds */ +#define DEFAULT_SSH_OPTIONS "-q -o ConnectTimeout=10" -#define WALRECEIVER_DISABLE_TIMEOUT_VALUE 86400000 /* milliseconds */ #ifndef RECOVERY_COMMAND_FILE #define RECOVERY_COMMAND_FILE "recovery.conf"