fix(uprade): version check
Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>
This commit is contained in:
parent
50feb5e2d3
commit
443db93866
2 changed files with 12 additions and 5 deletions
|
|
@ -5,16 +5,21 @@ cd $(dirname $0)
|
|||
function migration() {
|
||||
ls -la /opt/openreplay/openreplay
|
||||
db=$1
|
||||
old_version=$2
|
||||
|
||||
if [[ old_version == $CHART_APP_VERSION ]]; then
|
||||
# Checking if previous app version is set.
|
||||
if [[ $PREVIOUS_APP_VERSION == "" ]]; then
|
||||
echo "Previous app verision to be migrated is not set. Rerun using --set fromVersion=v1.3.5"
|
||||
exit 100
|
||||
fi
|
||||
|
||||
if [[ $PREVIOUS_APP_VERSION == $CHART_APP_VERSION ]]; then
|
||||
echo "No application version change. Not upgrading."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Checking migration versions
|
||||
cd /opt/openreplay/openreplay/scripts/helm
|
||||
migration_versions=(`ls -l db/init_dbs/$db | grep -E ^d | awk -v number=${old_version} '$NF > number {print $NF}' | grep -v create`)
|
||||
migration_versions=(`ls -l db/init_dbs/$db | grep -E ^d | awk -v number=${PREVIOUS_APP_VERSION} '$NF > number {print $NF}' | grep -v create`)
|
||||
echo "Migration version: $migration_versions"
|
||||
|
||||
cd -
|
||||
|
|
@ -56,7 +61,7 @@ case "$1" in
|
|||
init $2
|
||||
;;
|
||||
"true")
|
||||
migration $2 $CHART_APP_VERSION
|
||||
migration $2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown operation for db migration; exiting."
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ metadata:
|
|||
"helm.sh/hook": pre-install, pre-upgrade
|
||||
"helm.sh/hook-weight": "-5"
|
||||
spec:
|
||||
backoffLimit: 1
|
||||
backoffLimit: 0 # Don't restart failing containers
|
||||
template:
|
||||
metadata:
|
||||
name: postgresqlMigrate
|
||||
|
|
@ -41,6 +41,8 @@ spec:
|
|||
containers:
|
||||
- name: postgres
|
||||
env:
|
||||
- name: PREVIOUS_APP_VERSION
|
||||
value: "{{ .Values.fromVersion }}"
|
||||
- name: CHART_APP_VERSION
|
||||
value: "{{ .Chart.AppVersion }}"
|
||||
- name: PGHOST
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue