Skip to content

Commit 1e88a47

Browse files
pcncdarora
authored andcommitted
chore: preserve md5 auth scheme if project used it before the upgrade
1 parent a5449bb commit 1e88a47

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ansible/files/admin_api_scripts/pg_upgrade_scripts/complete.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SCRIPT_DIR=$(dirname -- "$0";)
1111
# shellcheck disable=SC1091
1212
source "$SCRIPT_DIR/common.sh"
1313

14-
LOG_FILE="/tmp/pg-upgrade-complete.log"
14+
LOG_FILE="/var/log/pg-upgrade-complete.log"
1515

1616
function cleanup {
1717
UPGRADE_STATUS=${1:-"failed"}
@@ -45,6 +45,9 @@ function complete_pg_upgrade {
4545
echo "4. Running generated SQL files"
4646
retry 3 run_generated_sql
4747

48+
echo "4.1. Applying correct authentication scheme"
49+
retry 3 use_corect_auth_scheme
50+
4851
sleep 5
4952

5053
echo "5. Restarting postgresql"
@@ -70,6 +73,15 @@ function run_generated_sql {
7073
fi
7174
}
7275

76+
# Projects which had their passwords hashed using md5 need be
77+
# configured to use md5 on upgraded instances as well, as opposed to scram-sha-256
78+
function use_corect_auth_scheme {
79+
PASSWORD_ENCRYPTION_SETTING=$(run_sql -A -t -c "SHOW password_encryption;")
80+
if [ "$PASSWORD_ENCRYPTION_SETTING" = "md5" ]; then
81+
sed -i 's/scram-sha-256/md5/g' /etc/postgresql/pg_hba.conf
82+
fi
83+
}
84+
7385
function start_vacuum_analyze {
7486
echo "complete" > /tmp/pg-upgrade-status
7587
su -c 'vacuumdb --all --analyze-in-stages' -s "$SHELL" postgres

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ EOF
282282
mkdir -p "$MOUNT_POINT/conf"
283283
cp -R /etc/postgresql-custom/* "$MOUNT_POINT/conf/"
284284

285+
# removing wal-g config as to allow it to be explicitly enabled on the new instance
286+
rm -f "$MOUNT_POINT/conf/wal-g.conf"
287+
285288
# copy sql files generated by pg_upgrade
286289
echo "11. Copying sql files generated by pg_upgrade"
287290
mkdir -p "$MOUNT_POINT/sql"

0 commit comments

Comments
 (0)