提交 92bb12a0 编写于 作者: G Goutam Tadi 提交者: Goutam Tadi

Use `hba_hostnames` instead of `fqdn_hba` in config and paramteres

[#159742200]
Co-authored-by: NXin Zhang <xzhang@pivotal.io>
Co-authored-by: NGoutam Tadi <gtadi@pivotal.io>
上级 156d4434
......@@ -128,7 +128,7 @@ def parseargs():
help='remove current warm master standby. Use this option '
'if the warm master standby host has failed. This option will '
'need to shutdown the GPDB array to be able to complete the request')
optgrp.add_option('', '--fqdn_hba', action='store_true', dest='fqdn_hba',
optgrp.add_option('', '--hba_hostnames', action='store_true', dest='hba_hostnames',
help='add fully-qualified domain names to pg_hba.conf')
# XXX - This option is added to keep backward compatibility with DCA tools.
......@@ -396,7 +396,7 @@ def create_standby(options):
logger.info('Updating pg_hba.conf file...')
update_pg_hba_conf(options, array)
logger.debug('Updating pg_hba.conf file on segments...')
update_pg_hba_conf_on_segments(array, options.standby_host, options.fqdn_hba)
update_pg_hba_conf_on_segments(array, options.standby_host, options.hba_hostnames)
logger.info('pg_hba.conf files updated successfully.')
copy_master_datadir_to_standby(options, array, standby_datadir)
......@@ -515,7 +515,7 @@ def update_pg_hba_conf(options, array):
new_section = ['# standby master host ip addresses\n']
for ip in standby_ips:
if not options.fqdn_hba:
if not options.hba_hostnames:
cidr_suffix = '/128' if ':' in ip else '/32' # MPP-15889
address = ip + cidr_suffix
else:
......
......@@ -230,7 +230,7 @@ CHK_PARAMS () {
fi
# Make sure old CLUSTER_CONFIG settings are not hanging around.
unset PORT_BASE SEG_PREFIX DATA_DIRECTORY REPLICATION_PORT_BASE HEAP_CHECKSUM FQDN_HBA
unset PORT_BASE SEG_PREFIX DATA_DIRECTORY REPLICATION_PORT_BASE HEAP_CHECKSUM HBA_HOSTNAMES
# Make sure it is not a dos file with CTRL M at end of each line
$TR -d '\r' < $CLUSTER_CONFIG > $TMP_FILE
......@@ -286,9 +286,9 @@ CHK_PARAMS () {
LOG_MSG "[INFO]:-Could not find HEAP_CHECKSUM in cluster config, defaulting to on."
fi
if [ x"" = x"$FQDN_HBA" ]; then
FQDN_HBA=0
LOG_MSG "[INFO]:-Could not find FQDN_HBA in cluster config, defaulting to 0."
if [ x"" = x"$HBA_HOSTNAMES" ]; then
HBA_HOSTNAMES=0
LOG_MSG "[INFO]:-Could not find HBA_HOSTNAMES in cluster config, defaulting to 0."
fi
if [ x"" == x"$LOCALE_SETTING" ];then
......@@ -1082,7 +1082,7 @@ DISPLAY_CONFIG () {
LOG_MSG "[INFO]:-Initdb to be used = $INITDB" 1
LOG_MSG "[INFO]:-GP_LIBRARY_PATH is = $GP_LIBRARY_PATH" 1
LOG_MSG "[INFO]:-HEAP_CHECKSUM is = $HEAP_CHECKSUM" 1
LOG_MSG "[INFO]:-FQDN_HBA is = $FQDN_HBA" 1
LOG_MSG "[INFO]:-HBA_HOSTNAMES is = $HBA_HOSTNAMES" 1
if [ $ULIMIT_WARN -eq 1 ];then
LOG_MSG "[WARN]:-Ulimit check = Warnings generated, see log file $WARN_MARK" 1
else
......@@ -1277,7 +1277,7 @@ CREATE_QD_DB () {
done
fi
LOG_MSG "[INFO]:-Adding gp_dumpall access to $PG_HBA for master host"
BUILD_MASTER_PG_HBA_FILE $GP_DIR $FQDN_HBA
BUILD_MASTER_PG_HBA_FILE $GP_DIR $HBA_HOSTNAMES
LOG_MSG "[INFO]:-Creating gpssh configuration file"
BUILD_GPSSH_CONF $GP_DIR
LOG_MSG "[INFO]:-Creating perfmon directories and configuration file"
......@@ -1416,7 +1416,7 @@ CREATE_QES_PRIMARY () {
HAS_MIRRORS_OPTION=no
fi
MASTER_HOSTNAME=${MASTER_HOSTNAME} FQDN_HBA=${FQDN_HBA} $GPCREATESEG $FLAG $$ 1 $I IS_PRIMARY $INST_COUNT $LOG_FILE $HEAP_CHECKSUM \
MASTER_HOSTNAME=${MASTER_HOSTNAME} HBA_HOSTNAMES=${HBA_HOSTNAMES} $GPCREATESEG $FLAG $$ 1 $I IS_PRIMARY $INST_COUNT $LOG_FILE $HEAP_CHECKSUM \
`$ECHO ${MASTER_IP_ADDRESS[@]}|$TR ' ' '~'` \
`$ECHO ${STANDBY_IP_ADDRESS[@]}|$TR ' ' '~'` &
PARALLEL_COUNT $BATCH_LIMIT $BATCH_DEFAULT
......@@ -1476,7 +1476,7 @@ CREATE_QES_MIRROR () {
FLAG="-p $PG_CONF_ADD_FILE"
fi
MASTER_HOSTNAME=${MASTER_HOSTNAME} FQDN_HBA=${FQDN_HBA} $GPCREATESEG $FLAG $$ 1 ${MIRRORS_ORDERED_BY_CONTENT_ID[$I_INDEX]} ${PRIMARIES_ORDERED_BY_CONTENT_ID[$I_INDEX]} $INST_COUNT $LOG_FILE $HEAP_CHECKSUM \
MASTER_HOSTNAME=${MASTER_HOSTNAME} HBA_HOSTNAMES=${HBA_HOSTNAMES} $GPCREATESEG $FLAG $$ 1 ${MIRRORS_ORDERED_BY_CONTENT_ID[$I_INDEX]} ${PRIMARIES_ORDERED_BY_CONTENT_ID[$I_INDEX]} $INST_COUNT $LOG_FILE $HEAP_CHECKSUM \
`$ECHO ${MASTER_IP_ADDRESS[@]}|$TR ' ' '~'` \
`$ECHO ${STANDBY_IP_ADDRESS[@]}|$TR ' ' '~'` &
PARALLEL_COUNT $BATCH_LIMIT $BATCH_DEFAULT
......@@ -1526,8 +1526,8 @@ CREATE_STANDBY_QD () {
if [ x"" != x"$STANDBY_DATADIR" ]; then
INIT_STANDBY_ARGS+=" -F $STANDBY_DATADIR"
fi
if [ $FQDN_HBA -eq 1 ]; then
INIT_STANDBY_ARGS+=" --fqdn_hba"
if [ $HBA_HOSTNAMES -eq 1 ]; then
INIT_STANDBY_ARGS+=" --hba_hostnames"
fi
export MASTER_DATA_DIRECTORY=${MASTER_DIRECTORY}/${SEG_PREFIX}-1;$INIT_STANDBY_PROG -s $STANDBY_HOSTNAME $INIT_STANDBY_ARGS -a
STANDBY_RET_CODE=$?
......@@ -1677,8 +1677,8 @@ DUMP_OUTPUT_CONFIG () {
$ECHO "HEAP_CHECKSUM=$HEAP_CHECKSUM" >> $OUTPUT_CONFIG
fi
if [ x"" != x"$FQDN_HBA" ] ; then
$ECHO "FQDN_HBA=$FQDN_HBA" >> $OUTPUT_CONFIG
if [ x"" != x"$HBA_HOSTNAMES" ] ; then
$ECHO "HBA_HOSTNAMES=$HBA_HOSTNAMES" >> $OUTPUT_CONFIG
fi
$ECHO "QD_PRIMARY_ARRAY=$QD_PRIMARY_ARRAY" >> $OUTPUT_CONFIG
......
......@@ -771,7 +771,7 @@ BUILD_MASTER_PG_HBA_FILE () {
LOG_MSG "[INFO]:-Start Function $FUNCNAME"
if [ $# -eq 0 ];then ERROR_EXIT "[FATAL]:-Passed zero parameters, expected at least 2" 2;fi
GP_DIR=$1
FQDN_HBA=${2:-0}
HBA_HOSTNAMES=${2:-0}
LOG_MSG "[INFO]:-Clearing values in Master $PG_HBA"
$GREP "^#" ${GP_DIR}/$PG_HBA > $TMP_PG_HBA
$MV $TMP_PG_HBA ${GP_DIR}/$PG_HBA
......@@ -779,7 +779,7 @@ BUILD_MASTER_PG_HBA_FILE () {
$ECHO "local all $USER_NAME $PG_METHOD" >> ${GP_DIR}/$PG_HBA
#$ECHO "local all all $PG_METHOD" >> ${GP_DIR}/$PG_HBA
LOG_MSG "[INFO]:-Setting local host access"
if [ $FQDN_HBA -eq 0 ];then
if [ $HBA_HOSTNAMES -eq 0 ];then
$ECHO "host all $USER_NAME 127.0.0.1/28 trust" >> ${GP_DIR}/$PG_HBA
for ADDR in "${MASTER_IP_ADDRESS_ALL[@]}"
......
......@@ -176,7 +176,7 @@ PROCESS_QE () {
fi
# Configuring PG_HBA -- on mirror, only need to add local addresses (skip the other addresses)
LOG_MSG "[INFO][$INST_COUNT]:-Configuring segment $PG_HBA"
if [ $FQDN_HBA -eq 0 ]; then
if [ $HBA_HOSTNAMES -eq 0 ]; then
if [ x"" = x"$COPY_FROM_PRIMARY_HOSTADDRESS" ]; then
for MASTER_IP in "${MASTER_IP_ADDRESS[@]}"
do
......
......@@ -109,37 +109,37 @@ Feature: gpinitsystem tests
And the startup timezone is saved
And the startup timezone matches "HST"
@gpinitsystem_fqdn_hba
@gpinitsystem_fqdn_hba_on
Scenario: gpinitsystem should print FQDN in pg_hba.conf when FQDN_HBA=1
Given the cluster config is generated with FQDN_HBA "1"
@gpinitsystem_hba_hostnames
@gpinitsystem_hba_hostnames_on
Scenario: gpinitsystem should print FQDN in pg_hba.conf when HBA_HOSTNAMES=1
Given the cluster config is generated with HBA_HOSTNAMES "1"
When generate cluster config file "/tmp/output_config_file"
Then verify that the file "/tmp/output_config_file" contains "FQDN_HBA=1"
Then verify that the file "/tmp/output_config_file" contains "HBA_HOSTNAMES=1"
When initialize a cluster using "/tmp/output_config_file"
Then verify that the file "../gpAux/gpdemo/datadirs/qddir/demoDataDir-1/pg_hba.conf" contains FQDN only for trusted host
And verify that the file "../gpAux/gpdemo/datadirs/dbfast1/demoDataDir0/pg_hba.conf" contains FQDN only for trusted host
@gpinitsystem_fqdn_hba
@gpinitsystem_fqdn_hba_off
Scenario: gpinitsystem should print CIDR in pg_hba.conf when FQDN_HBA=0
Given the cluster config is generated with FQDN_HBA "0"
@gpinitsystem_hba_hostnames
@gpinitsystem_hba_hostnames_off
Scenario: gpinitsystem should print CIDR in pg_hba.conf when HBA_HOSTNAMES=0
Given the cluster config is generated with HBA_HOSTNAMES "0"
When generate cluster config file "/tmp/output_config_file"
Then verify that the file "/tmp/output_config_file" contains "FQDN_HBA=0"
Then verify that the file "/tmp/output_config_file" contains "HBA_HOSTNAMES=0"
When initialize a cluster using "/tmp/output_config_file"
Then verify that the file "../gpAux/gpdemo/datadirs/qddir/demoDataDir-1/pg_hba.conf" contains CIDR only for trusted host
And verify that the file "../gpAux/gpdemo/datadirs/dbfast1/demoDataDir0/pg_hba.conf" contains CIDR only for trusted host
@gpinitsystem_fqdn_hba
@gpinitsystem_fqdn_hba_on_with_standby
Scenario: gpinitsystem should print FQDN in pg_hba.conf for standby when FQDN_HBA=1
@gpinitsystem_hba_hostnames
@gpinitsystem_hba_hostnames_on_with_standby
Scenario: gpinitsystem should print FQDN in pg_hba.conf for standby when HBA_HOSTNAMES=1
Given the database is running
And all the segments are running
And the segments are synchronized
And the standby is not initialized
And ensure the standby directory does not exist
And the cluster config is generated with FQDN_HBA "1"
And the cluster config is generated with HBA_HOSTNAMES "1"
When generate cluster config file "/tmp/output_config_file"
Then verify that the file "/tmp/output_config_file" contains "FQDN_HBA=1"
Then verify that the file "/tmp/output_config_file" contains "HBA_HOSTNAMES=1"
When initialize a cluster with standby using "/tmp/output_config_file"
Then verify that the file "../gpAux/gpdemo/datadirs/qddir/demoDataDir-1/pg_hba.conf" contains FQDN only for trusted host
And verify that the file "../gpAux/gpdemo/datadirs/dbfast1/demoDataDir0/pg_hba.conf" contains FQDN only for trusted host
......
......@@ -37,8 +37,8 @@ master_data_dir = os.environ.get('MASTER_DATA_DIRECTORY')
if master_data_dir is None:
raise Exception('Please set MASTER_DATA_DIRECTORY in environment')
@given('the cluster config is generated with FQDN_HBA "{fqdn_hba_toggle}"')
def impl(context, fqdn_hba_toggle):
@given('the cluster config is generated with HBA_HOSTNAMES "{hba_hostnames_toggle}"')
def impl(context, hba_hostnames_toggle):
stop_database(context)
cmd = """
......@@ -48,12 +48,12 @@ def impl(context, fqdn_hba_toggle):
export NUM_PRIMARY_MIRROR_PAIRS={num_primary_mirror_pairs} && \
export WITH_MIRRORS={with_mirrors} && \
./demo_cluster.sh -d && ./demo_cluster.sh -c && \
env EXTRA_CONFIG="FQDN_HBA={fqdn_hba_toggle}" ONLY_PREPARE_CLUSTER_ENV=true ./demo_cluster.sh
env EXTRA_CONFIG="HBA_HOSTNAMES={hba_hostnames_toggle}" ONLY_PREPARE_CLUSTER_ENV=true ./demo_cluster.sh
""".format(master_port=os.getenv('MASTER_PORT', 15432),
port_base=os.getenv('PORT_BASE', 25432),
num_primary_mirror_pairs=os.getenv('NUM_PRIMARY_MIRROR_PAIRS', 3),
with_mirrors='true',
fqdn_hba_toggle=fqdn_hba_toggle)
hba_hostnames_toggle=hba_hostnames_toggle)
run_command(context, cmd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册