Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Fix connections to clouds (no ssh support) #127

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions check
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ validate_arg_type() {
exit 1
fi
elif [ $type = "word" ]; then
re='^[a-zA-Z_-]+$'
re='^[a-zA-Z0-9_-]+$'
if ! [[ $value =~ $re ]]; then
err "'$name' = '$value' => is not a '$type' (${re})"
exit 1
Expand Down Expand Up @@ -436,7 +436,7 @@ usage() {
# additional info
echo >&${out_descriptor}
echo "Example:" >&${out_descriptor}
echo "./${SCRIPT_NAME} -h dev -p 5432 --username ${USER} --dbname postgres --project dummy" >&${out_descriptor}
echo "PGPASSWORD=postgres ./${SCRIPT_NAME} -h dev -p 5432 --username ${USER} --dbname postgres --project dummy" >&${out_descriptor}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't go to master, right?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is just an example... Ok.

echo >&${out_descriptor}
echo "Add more checks into './resources/checks/' directory." >&${out_descriptor}
echo >&${out_descriptor}
Expand Down Expand Up @@ -676,7 +676,7 @@ check_bin_deps() {
#######################################
# Check rights, set global variables, etc.
# Globals:
# HOST, CHECK_HOST_CMD
# HOST, CHECK_HOST_CMD, NATIVE_HOSTNAME
# Arguments:
# None
# Returns:
Expand All @@ -685,12 +685,20 @@ check_bin_deps() {
host_pre_start_checks() {
# choise host connection command
# while checking ssh support
if (ssh $HOST "true" >/dev/null 2>&1); then
# and determine NATIVE_HOSTNAME (a host key in JSON reports)
if NATIVE_HOSTNAME=$(ssh $HOST "hostname" 2>/dev/null); then
# ssh to remote host and use local psql (default)
export CHECK_HOST_CMD="ssh ${HOST}"
else
NATIVE_HOSTNAME="${HOST}"
# swap ssh with bash
export CHECK_HOST_CMD="bash -e -u -o pipefail -c"
# use local psql and connect to remote postgres without ssh
export _PSQL="${_PSQL} -h ${HOST}"
fi
dbg "CHECK_HOST_CMD: ${CHECK_HOST_CMD}"
export NATIVE_HOSTNAME
dbg "CHECK_HOST_CMD: '${CHECK_HOST_CMD}'"
dbg "NATIVE_HOSTNAME: '$NATIVE_HOSTNAME'"
}

#######################################
Expand Down Expand Up @@ -784,7 +792,6 @@ update_nodes_json() {
fi

export ALIAS_NAME ALIAS_INDEX ROLE EPOCH
dbg "NATIVE_HOSTNAME: '$NATIVE_HOSTNAME'"
dbg "ALIAS_NAME: '$ALIAS_NAME'"
dbg "ALIAS_INDEX: '$ALIAS_INDEX'"
dbg "ROLE: '$ROLE'"
Expand Down Expand Up @@ -832,13 +839,6 @@ update_nodes_json() {
run_checks() {
# perform pre-checks here

# get native hostname from remote host due to accurate
# mapping in the future
if ! NATIVE_HOSTNAME="$(${CHECK_HOST_CMD} "hostname")"; then
NATIVE_HOSTNAME="$HOST"
fi
export NATIVE_HOSTNAME

local pghrep_failed_jsons_stack=""

# perform all checks from './resources/checks/' directory
Expand Down