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

multiple host support part1 #77

Merged
merged 10 commits into from
Nov 26, 2018
Merged

multiple host support part1 #77

merged 10 commits into from
Nov 26, 2018

Conversation

Nastradamus
Copy link
Contributor

No description provided.

@Nastradamus Nastradamus mentioned this pull request Nov 23, 2018
@Nastradamus Nastradamus changed the title [WIP] multiple host support multiple host support part1 Nov 23, 2018
@Nastradamus Nastradamus self-assigned this Nov 23, 2018
echo >&2
}

#######################################
# Cleanup function: close ssh sockets, etc.
# Globals:
# None
# HOST
Copy link
Collaborator

Choose a reason for hiding this comment

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

HOSTS?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, I see -- HOST

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to check only one host per single script run.

done
if [[ ! -z ${HOST+x} ]]; then
dbg "closing ssh conenction to host '$HOST' (if exists)"
ssh -O exit ${HOST} 2>/dev/null || true
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this for closing persistent ssh connection ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

check Outdated
# Generate json report
# Globals:
# CURRENT_CHECK, SCRIPT_DIR, PROJECT,
# HOST,
Copy link
Collaborator

Choose a reason for hiding this comment

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

extra ,


local epoch=null

[[ -z ${3+x} ]] && err "function needs 3 arguments"
Copy link
Collaborator

Choose a reason for hiding this comment

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

cool way to check it!

#dbg "PSQL_CONN_OPTIONS: ${PSQL_CONN_OPTIONS}"
pgver=$(psql ${PSQL_CONN_OPTIONS} -c "SHOW server_version" -t -A)

pgver=$(ssh ${HOST} "${_PSQL} -c \"SHOW server_version\"")
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's a bit easer to get show server_version_num here and the make interger comparison, w/o any regexp-replacement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's refactor checks separate from script logic?

@@ -127,7 +129,7 @@ EOF

fi

psql ${PSQL_CONN_OPTIONS} <<SQL
ssh ${HOST} "${_PSQL} -f - " <<SQL
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's great that it works!

@@ -10,7 +10,10 @@
Connection options|p|port|PORT|number|optional|PostgreSQL database server port (default: "5432")
Connection options|d|dbname|DBNAME|word|optional|database name to connect to (default: "postgres")
Connection options|U|username|USERNAME|word|optional|database user name (default: current)
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket")
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default)
Copy link
Collaborator

Choose a reason for hiding this comment

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

there is light inconsistency in naming here -- various prefixes (DB..., PG..., and no prefix as in HOST)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. I changed PORT to PGPORT. DBNAME: I've got from man psql.
HOST: I decided to keep "as is" 'cause it is slightly not the same as PGHOST - we use it for a ssh connection.

Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket")
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default)
Connection options|None|psql-binary|PGBINARY|text|optional|psql utility path (default: from $PATH)
Copy link
Collaborator

Choose a reason for hiding this comment

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

PSQLBINARY ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, fixed. Thanks.

@@ -0,0 +1,12 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any risk that we, working with some particular DB replicaset, will override this file and commit/push by mistake?

it is kind of config, right? it will be individual for every project? where can we keep it (may we keep it outside the repo?)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm... ./resources/templates directory conceived as a place where we keep templates to generate another files.
It is a part of ./check. We don't write artifacts into ./resources dirs.

NikolayS
NikolayS previously approved these changes Nov 24, 2018
Copy link
Collaborator

@NikolayS NikolayS left a comment

Choose a reason for hiding this comment

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

Awesome! Only a few of minor comments. Let's merge it

Copy link
Contributor Author

@Nastradamus Nastradamus left a comment

Choose a reason for hiding this comment

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

I replied and will push fixes.

echo >&2
}

#######################################
# Cleanup function: close ssh sockets, etc.
# Globals:
# None
# HOST
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We decided to check only one host per single script run.

done
if [[ ! -z ${HOST+x} ]]; then
dbg "closing ssh conenction to host '$HOST' (if exists)"
ssh -O exit ${HOST} 2>/dev/null || true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

#dbg "PSQL_CONN_OPTIONS: ${PSQL_CONN_OPTIONS}"
pgver=$(psql ${PSQL_CONN_OPTIONS} -c "SHOW server_version" -t -A)

pgver=$(ssh ${HOST} "${_PSQL} -c \"SHOW server_version\"")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's refactor checks separate from script logic?

@@ -10,7 +10,10 @@
Connection options|p|port|PORT|number|optional|PostgreSQL database server port (default: "5432")
Connection options|d|dbname|DBNAME|word|optional|database name to connect to (default: "postgres")
Connection options|U|username|USERNAME|word|optional|database user name (default: current)
Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket")
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. I changed PORT to PGPORT. DBNAME: I've got from man psql.
HOST: I decided to keep "as is" 'cause it is slightly not the same as PGHOST - we use it for a ssh connection.

Connection options|h|hostname|HOST|alnum|mandatory|database and ssh server host or socket directory (default: "local socket")
Connection options|h|hostname|HOST|text|mandatory|database and ssh server host
Connection options|s|pg-socket-dir|PGSOCKET|text|optional|PostgreSQL domain socket dir (default: psql's default)
Connection options|None|psql-binary|PGBINARY|text|optional|psql utility path (default: from $PATH)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, fixed. Thanks.

@@ -0,0 +1,12 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm... ./resources/templates directory conceived as a place where we keep templates to generate another files.
It is a part of ./check. We don't write artifacts into ./resources dirs.

@Nastradamus Nastradamus merged commit 36cc88e into master Nov 26, 2018
@ane4ka ane4ka added the S4 Sprint №4 label Nov 29, 2018
@NikolayS NikolayS deleted the 64-multiple-host-support branch December 7, 2018 15:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S4 Sprint №4
Development

Successfully merging this pull request may close these issues.

4 participants