From b55c4e75458b7f74a3f6d56c1c214f148078b69d Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Sat, 10 Jul 2021 12:28:06 +0530 Subject: [PATCH] chore(upgrade): upgrade script fixes. --- scripts/helm/migration.yaml | 5 ++--- scripts/helm/upgrade.sh | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/helm/migration.yaml b/scripts/helm/migration.yaml index 8f2a683a5..5b4025715 100644 --- a/scripts/helm/migration.yaml +++ b/scripts/helm/migration.yaml @@ -8,7 +8,7 @@ - block: - name: generating migration db paths set_fact: - db_path: "{{dst_list | default([])}} + [ '{{ item[0] }}/*.sql' ]" + db_path: "{{dst_list | default([])}} + [ '{{playbook_dir}}/db/init_dbs/postgresql/{{ item }}/*.sql' ]" with_items: "{{ migration_versions.split(',') }}" - name: Migrate postgresql shell: | @@ -18,8 +18,7 @@ kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -U postgres -f /tmp/$file" &> "{{ playbook_dir }}"/postgresql_init.log args: chdir: db/init_dbs/postgresql - with_fileglob: - - "{{ db_path }}" + with_fileglob: "{{ db_path }}" tags: - postgresql - block: diff --git a/scripts/helm/upgrade.sh b/scripts/helm/upgrade.sh index 5bf0c56c0..1ef1b8213 100644 --- a/scripts/helm/upgrade.sh +++ b/scripts/helm/upgrade.sh @@ -9,7 +9,7 @@ vars_file_path=$1/scripts/helm/vars.yaml echo -e "OpenReplay previous version path not given.\nUsage: bash $0 /path/to/previous_openreplay_code_path" exit 1 } -[[ -f $1 ]] || { +[[ -d $1 ]] || { echo -e "$1 doesn't exist. Please check the path and run\n \`bash upgrade.sh \`" } which ansible &> /dev/null || { @@ -26,6 +26,9 @@ echo -e"Updating vars.yaml\n" } old_version=`grep openreplay_version ${vars_file_path} | cut -d "v" -f 3 | cut -d '"' -f 1` +[[ -z $old_version ]] && { + old_version=`grep image_tag ${vars_file_path} | cut -d "v" -f 2 | cut -d '"' -f 1` +} enterprise_edition=`grep enterprise_edition_license ${vars_file_path} | cut -d ":" -f 2 | xargs` migration(){ # Ref: https://stackoverflow.com/questions/1527049/how-can-i-join-elements-of-an-array-in-bash @@ -40,13 +43,14 @@ migration(){ echo -e "Starting db migrations" echo -e "Migrating versions $migration_versions" - ansible-playbook -c local migration.yaml -e vars.yaml -e migration_versions=${joined_migration_versions} --tags $db + ansible-playbook -c local migration.yaml -e @vars.yaml -e migration_versions=${joined_migration_versions} --tags $db -v } } -# As of now, we don't have any migrations to do, as there is no delta files, -# We'll have to do full installation. -# -# echo -e "Migrating postgresql" -# migration postgresql -# Re installing everything. -./install.sh +echo -e "Migrating postgresql" +migration postgresql +# Re installing apps. +apps=($(ls app/*.yaml|cut -d "." -f1|cut -d '/' -f2)) +apps+=(frontend nginx) +for app in ${apps}; do + bash -x kube-install.sh --app $app +done