061-check-gcp-candidate-master-is-master.sh 375 Bytes
Newer Older
1 2 3 4
#!/bin/bash

set -eu

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

Matteo Melli's avatar
Matteo Melli committed
8
if echo "select pg_is_in_recovery()" \
9
  | ssh_remote "$GCP_MASTER_CANDIDATE" sudo -u gitlab-psql gitlab-psql -v ON_ERROR_STOP=1 -d postgres -t -A \
Matteo Melli's avatar
Matteo Melli committed
10
  | grep -q 'f'
11 12
then
  echo "$GCP_MASTER_CANDIDATE is master"
Matteo Melli's avatar
Matteo Melli committed
13
  exit 0
14
else
Matteo Melli's avatar
Matteo Melli committed
15 16
  >&2 echo "$GCP_MASTER_CANDIDATE is NOT master"
  exit 1
17
fi