mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-28 21:25:55 +01:00
pg upgrade failure handling (#14934)
To ensure the upgrade execution idempotence, it needs to clean the $PGDATANEW on pg_upgrade failure. Otherwise, the upgrade will skip the upgrade process from the second time launch as the exist of $PGDATANEW. Signed-off-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
6c14e699b1
commit
39bdd7b506
@ -27,8 +27,15 @@ if [ "$(ls -A $PGDATA)" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
initPG $PGDATANEW false
|
initPG $PGDATANEW false
|
||||||
# because of the 'set -e', the upgrade failure will break execution.
|
# it needs to clean the $PGDATANEW on upgrade failure
|
||||||
|
set +e
|
||||||
./$CUR/upgrade.sh --old-bindir $PGBINOLD --old-datadir $PGDATAOLD --new-datadir $PGDATANEW
|
./$CUR/upgrade.sh --old-bindir $PGBINOLD --old-datadir $PGDATAOLD --new-datadir $PGDATANEW
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "remove the $PGDATANEW after fail to upgrade"
|
||||||
|
rm -rf $PGDATANEW
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
echo "remove the $PGDATAOLD after upgrade success."
|
echo "remove the $PGDATAOLD after upgrade success."
|
||||||
if [ "$PGDATAOLD" = "$PGDATA" ]; then
|
if [ "$PGDATAOLD" = "$PGDATA" ]; then
|
||||||
find $PGDATA/* -prune ! -name pg${PG_VERSION_NEW} -exec rm -rf {} \;
|
find $PGDATA/* -prune ! -name pg${PG_VERSION_NEW} -exec rm -rf {} \;
|
||||||
|
Loading…
Reference in New Issue
Block a user