051-check-gcp-master-is-standby.sh 377 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash

set -eu

# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"

if echo "select pg_is_in_recovery()" \
  | ssh_remote "$GCP_MASTER_CANDIDATE" sudo -u gitlab-psql gitlab-psql -v ON_ERROR_STOP=1 -d postgres -t -A \
  | grep -q 't'
then
  echo "$GCP_MASTER_CANDIDATE is standby"
  exit 0
else
  >&2 echo "$GCP_MASTER_CANDIDATE is NOT standby"
  exit 1
fi