From 4f269ce4a08b86f9b5565a3108488cccab0d3363 Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Wed, 6 Nov 2024 14:54:44 +0100 Subject: [PATCH] chore(helm): Adding opereplay config map for Installation agnostic version access. This is useful for db migration, especially when we install using argo, or other means precedence to the autogenereated prev version. Set migration is true if its argo deployment fix the forceMigration override --- scripts/helmcharts/openreplay/files/dbops.sh | 16 ++++++++++++++++ scripts/helmcharts/openreplay/templates/job.yaml | 4 ++-- scripts/helmcharts/openreplay/values.yaml | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/helmcharts/openreplay/files/dbops.sh b/scripts/helmcharts/openreplay/files/dbops.sh index 2c3b243b2..c936e971e 100644 --- a/scripts/helmcharts/openreplay/files/dbops.sh +++ b/scripts/helmcharts/openreplay/files/dbops.sh @@ -5,9 +5,25 @@ cd $(dirname $0) is_migrate=$1 +# Check if the openreplay version is set. +# This will take precedence over the .Values.fromVersion variable +# Because its created by installation programatically. +if [[ -n $OPENREPLAY_VERSION ]]; then + is_migrate=true + PREVIOUS_APP_VERSION=$OPENREPLAY_VERSION + echo "$OPENREPLAY_VERSION set" +fi + +if [[ $FORCE_MIGRATION == "true" ]]; then + is_migrate=true +fi + # Passed from env # PREVIOUS_APP_VERSION # CHART_APP_VERSION +# Converting alphaneumeric to number. +PREVIOUS_APP_VERSION=$(echo $PREVIOUS_APP_VERSION | cut -d "v" -f2) +CHART_APP_VERSION=$(echo $CHART_APP_VERSION | cut -d "v" -f2) function migration() { ls -la /opt/openreplay/openreplay diff --git a/scripts/helmcharts/openreplay/templates/job.yaml b/scripts/helmcharts/openreplay/templates/job.yaml index ae479e8e6..6a8664d93 100644 --- a/scripts/helmcharts/openreplay/templates/job.yaml +++ b/scripts/helmcharts/openreplay/templates/job.yaml @@ -3,8 +3,8 @@ Don't have to trigger migration if there is no version change Don't have to trigger migration if skipMigration is set Have to trigger migration if forceMigration is set */}} -{{- $versionChange := and (eq .Values.fromVersion .Chart.AppVersion) (.Release.IsUpgrade) }} -{{- if or (not (or .Values.skipMigration $versionChange)) .Values.forceMigration }} +{{- $versionChange := (or .Values.deployment.argo (and (not (eq .Values.fromVersion .Chart.AppVersion)) .Release.IsUpgrade)) }} +{{- if or .Values.forceMigration (and (not .Values.skipMigration) $versionChange) }} --- apiVersion: v1 kind: ConfigMap diff --git a/scripts/helmcharts/openreplay/values.yaml b/scripts/helmcharts/openreplay/values.yaml index 96164aa20..9d90dfef2 100644 --- a/scripts/helmcharts/openreplay/values.yaml +++ b/scripts/helmcharts/openreplay/values.yaml @@ -5,6 +5,11 @@ migrationJob: migration: env: {} +deployment: + argo: false +forceMigration: false +skipMigration: false + redis: &redis tls: enabled: false