Skip to content

Commit

Permalink
Merge pull request open-horizon#4006 from LiilyZhang/zhangl/Issue4005
Browse files Browse the repository at this point in the history
Issue open-horizon#4005 - Bug: Auto-upgrade failed to rollback on k3s…
  • Loading branch information
LiilyZhang authored Feb 12, 2024
2 parents 04ccc1a + 673bdb8 commit 70bc7d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions anax-in-k8s/cronjobs/auto-upgrade-cronjob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function rollback_agent_image() {
local current_version
old_image_version=$(cat $STATUS_PATH | jq '.agentUpgradePolicyStatus.k8s.imageVersion.from' | sed 's/\"//g')
log_debug "Old image version: $old_image_version"
current_version=$($KUBECTL get deployment -n ${AGENT_NAMESPACE} agent -o=jsonpath='{..image}' | sed 's/.*://')
current_version=$($KUBECTL get deployment -n ${AGENT_NAMESPACE} agent -o=jsonpath='{$..spec.template.spec.containers[0].image}' | sed 's/.*://')

# Download the agent deployment to a yaml file
log_verbose "Dowloading agent deployment to yaml file..."
Expand All @@ -274,8 +274,10 @@ function rollback_agent_image() {
fi

# Replace the agent version in the yaml file to the version the agent attempted to upgrade from
current_anax_image_version="_anax_k8s:$current_version"
old_anax_image_version="_anax_k8s:$old_image_version"
log_verbose "Downgrading version from $current_version to $old_image_version..."
sed -i "s/$current_version/$old_image_version/g" /tmp/agentbackup/deployment.yaml
sed -i "s/$current_anax_image_version/$old_anax_image_version/g" /tmp/agentbackup/deployment.yaml

log_debug "New deployment.yaml file: $(cat /tmp/agentbackup/deployment.yaml)"

Expand Down

0 comments on commit 70bc7d6

Please sign in to comment.