Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OC-1082]: migration script to work even if px-backup is disabled and for external ls server. #320

Open
wants to merge 1 commit into
base: 2.1.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions single_chart_migration/migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ set_enabled_modules() {
pxmonitor_enabled=true
fi

ls_match=`$kubectl_cmd --namespace $namespace get deployment pxcentral-license-server`
ls_match=`$kubectl_cmd --namespace $namespace get configmap $cmListLS`
if [ $? -eq 0 ] ; then
pxls_enabled=true
fi
Expand All @@ -153,13 +153,12 @@ set_enabled_modules() {

find_releases() {
namespace=$1
if [ "$pxbackup_enabled" == true ]; then
# Finding px-backup release name from frontend deployment as px-backup may not be installed
pxbackup_release=`$kubectl_cmd --namespace $namespace get deployment $frontend_deployment -o yaml | grep "^[ ]*meta.helm.sh/release-name:" | tail -1 | awk -F ":" '{print $2}' | awk '{$1=$1}1'`
if [ "$pxbackup_release" == "" ]; then
echo "px-backup is enabled but could not find the px-backup release"
exit 1
fi
# Finding px-backup release name from frontend deployment as px-backup may not be installed
# px-backup release must be installed for 1.2.x chart versions
pxbackup_release=`$kubectl_cmd --namespace $namespace get deployment $frontend_deployment -o yaml | grep "^[ ]*meta.helm.sh/release-name:" | tail -1 | awk -F ":" '{print $2}' | awk '{$1=$1}1'`
if [ "$pxbackup_release" == "" ]; then
echo "px-backup is enabled but could not find the px-backup release"
exit 1
fi
if [ "$pxmonitor_enabled" == true ]; then
pxmonitor_release=`$kubectl_cmd --namespace $namespace get deployment $cortex_nginx_deployment -o yaml | grep "^[ ]*meta.helm.sh/release-name:" | tail -1 | awk -F ":" '{print $2}' | awk '{$1=$1}1'`
Expand Down Expand Up @@ -232,21 +231,26 @@ do_rollback() {
namespace=$1
version=$2

current_px_central_version="2.0.1"
if [ `helm list -n px-backup | grep "px-central-2.0.0" | wc -l` -eq 1 ]; then
current_px_central_version="2.1.0"
if [ `helm list -n px-backup | grep "px-central-2.0.1" | wc -l` -eq 1 ]; then
current_px_central_version="2.0.1"
elif [ `helm list -n px-backup | grep "px-central-2.0.0" | wc -l` -eq 1 ]; then
current_px_central_version="2.0.0"
fi

# job_imagetag
if [ $current_px_central_version == "2.0.1" ]; then
# TODO: Needs to modify to public tags in 2.0.1 final patch
if [ $current_px_central_version == "2.1.0" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using else if can we use an array or list of the version that is supported and check for that.
In long run this will keep adding to the complexity, a better solution would be to say we support all versions ahead of 2.0.0

# TODO: Change the following to released tag
job_image="pxcentral-onprem-post-setup-base"
job_imagetag="2.1.0-dev"
elif [ $current_px_central_version == "2.0.1" ]; then
job_image="pxcentral-onprem-post-setup"
job_imagetag="2.0.1"
elif [ $current_px_central_version == "2.0.0" ]; then
job_image="pxcentral-onprem-post-setup"
job_imagetag="2.0.0"
else
echo "Invalid px-central-chart version: $px_central_version , supported ones are : 2.0.1 and 2.0.0"
echo "Invalid px-central-chart version: $px_central_version , supported ones are : 2.1.0, 2.0.1 and 2.0.0"
fi

image="$job_registry/$job_repo/$job_image:$job_imagetag"
Expand Down Expand Up @@ -496,8 +500,8 @@ if [ "$helmvaluesfile" != "" ]; then
fi

if [ "$px_central_version" != "" ]; then
if [ $px_central_version != "2.0.0" ] && [ $px_central_version != "2.0.1" ]; then
echo "upgrade-version can only be 2.0.1 or 2.0.0"
if [ $px_central_version != "2.1.0" ] && [ $px_central_version != "2.0.1" ] && [ $px_central_version != "2.0.0" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These supported versions should be in an array or a list.

echo "upgrade-version can only be 2.1.0, 2.0.1 or 2.0.0"
usage
exit 1
fi
Expand Down