Skip to content

Commit

Permalink
Fix recovery upgrades
Browse files Browse the repository at this point in the history
This commit fixes a bug related environment variables setting for
cos-upgrade command. `cos-upgrade --recovery` was not using
the recovery/cos image for upgrades since at the time the upgrade image
was evaluated and decided the `RECOVERY_UPGRADE` variable was not set
yet.

Signed-off-by: David Cassany <[email protected]>
  • Loading branch information
davidcassany committed Jul 23, 2021
1 parent b16cf43 commit 45ad3ca
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/cos/collection.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
packages:
- name: "cos"
category: "system"
version: 0.5.8+4
version: 0.5.8+6
description: "cOS base image, used to build cOS live ISOs"
brand_name: "cOS"
labels:
autobump.revdeps: "true"
autobump.revbump_related: "recovery/cos-img recovery/cos-squash"
- name: "cos"
category: "recovery"
version: 0.5.8+4
version: 0.5.8+6
brand_name: "cOS recovery"
description: "cOS recovery image, used to boot cOS for troubleshooting"
labels:
autobump.revdeps: "true"
autobump.revbump_related: "recovery/cos-img recovery/cos-squash"
- name: "cos-container"
category: "system"
version: 0.5.8+5
version: 0.5.8+6
brand_name: "cOS"
description: "cOS container image, used to build cOS derivatives from scratch"
labels:
Expand Down
2 changes: 1 addition & 1 deletion packages/cos/recovery-img/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "cos-img"
category: "recovery"
version: 0.5.8+5
version: 0.5.8+6
brand_name: "cOS"
2 changes: 1 addition & 1 deletion packages/cos/recovery-img/squash/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: "cos-squash"
category: "recovery"
version: 0.5.8+5
version: 0.5.8+6
2 changes: 1 addition & 1 deletion packages/installer/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: "installer"
category: "utils"
version: 0.8+9
version: 0.9
12 changes: 8 additions & 4 deletions packages/installer/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ find_upgrade_channel() {
source /etc/cos-upgrade-image
fi

if [ -n "$NO_CHANNEL" ] && [ $NO_CHANNEL == true ]; then
CHANNEL_UPGRADES=false
fi

if [ -n "$IMAGE" ]; then
UPGRADE_IMAGE=$IMAGE
echo "Upgrading to image $UPGRADE_IMAGE"
Expand Down Expand Up @@ -184,12 +188,10 @@ usage()
exit 1
}

find_upgrade_channel

while [ "$#" -gt 0 ]; do
case $1 in
--docker-image)
CHANNEL_UPGRADES=false
NO_CHANNEL=true
;;
--no-verify)
VERIFY=false
Expand All @@ -207,13 +209,15 @@ while [ "$#" -gt 0 ]; do
if [ "$#" -gt 2 ]; then
usage
fi
UPGRADE_IMAGE=$1
IMAGE=$1
break
;;
esac
shift 1
done

find_upgrade_channel

trap cleanup exit


Expand Down
28 changes: 16 additions & 12 deletions packages/installer/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,22 @@ find_upgrade_channel() {
source /etc/cos-upgrade-image
fi

if [ -n "$NO_CHANNEL" ] && [ $NO_CHANNEL == true ]; then
CHANNEL_UPGRADES=false
fi

if [ -n "$IMAGE" ]; then
UPGRADE_IMAGE=$IMAGE
echo "Upgrading to image $UPGRADE_IMAGE"
fi
else

if [ -z "$UPGRADE_IMAGE" ]; then
UPGRADE_IMAGE="system/cos"
fi
if [ -z "$UPGRADE_IMAGE" ]; then
UPGRADE_IMAGE="system/cos"
fi

if [ -n "$UPGRADE_RECOVERY" ] && [ $UPGRADE_RECOVERY == true ] && [ -n "$RECOVERY_IMAGE" ]; then
UPGRADE_IMAGE=$RECOVERY_IMAGE
if [ -n "$UPGRADE_RECOVERY" ] && [ $UPGRADE_RECOVERY == true ] && [ -n "$RECOVERY_IMAGE" ]; then
UPGRADE_IMAGE=$RECOVERY_IMAGE
fi
fi
}

Expand Down Expand Up @@ -264,15 +269,13 @@ usage()
exit 1
}

find_upgrade_channel

while [ "$#" -gt 0 ]; do
case $1 in
--docker-image)
CHANNEL_UPGRADES=false
NO_CHANNEL=true
;;
--directory)
CHANNEL_UPGRADES=false
NO_CHANNEL=true
DIRECTORY=true
;;
--recovery)
Expand All @@ -292,13 +295,15 @@ while [ "$#" -gt 0 ]; do
usage
fi
INTERACTIVE=true
UPGRADE_IMAGE=$1
IMAGE=$1
break
;;
esac
shift 1
done

find_upgrade_channel

trap cleanup exit

if [ -n "$UPGRADE_RECOVERY" ] && [ $UPGRADE_RECOVERY == true ]; then
Expand Down Expand Up @@ -327,7 +332,6 @@ fi

echo "Flush changes to disk"
sync
sync

if [ -n "$INTERACTIVE" ] && [ $INTERACTIVE == false ]; then
if grep -q 'cos.upgrade.power_off=true' /proc/cmdline; then
Expand Down

0 comments on commit 45ad3ca

Please sign in to comment.