Skip to content

Commit 1bfc5a4

Browse files
committed
refact: code structure and error handling + report
1 parent c72a2b2 commit 1bfc5a4

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎system/cuos/do-update-lxc.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ IMAGE_VERSION_STRING="${LXC_IMAGE}@${LXC_IMAGE_DIGEST}"
2626

2727
if [[ "${IMAGE_VERSION_STRING}" == "$(cat /etc/image)" ]]; then
2828
echo "No new image version available. Exiting."
29+
report_info "cuos:update:not_needed" "The system is up-to-date"
2930
exit 22
3031
fi
3132

3233
AVAIL_BYTES=$(df -B1 "/" | awk 'NR==2 {print $4}')
3334
REQUIRED_BYTES=$((2 * 1024 * 1024 * 1024))
3435
if [ "$AVAIL_BYTES" -le "$REQUIRED_BYTES" ]; then
3536
echo "Not enough free space in ${TARGET_ROOT} (required: >2GB, available: $((AVAIL_BYTES/1024/1024)) MB). Aborting update." >&2
37+
report_info "cuos:update:no_space" "Not enough free disk space available"
3638
exit 21
3739
fi
3840

@@ -49,6 +51,7 @@ fi
4951

5052
if [[ "${IMAGE_VERSION}@${NEW_DIGEST}" == "$(cat /etc/image)" ]]; then
5153
echo "No new image version available (post). Exiting."
54+
report_info "cuos:update:not_needed" "The system is up-to-date"
5255
exit 22
5356
fi
5457

‎system/cuos/do-update.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ OS_DIGEST="$(jq -r --arg arch "${OS_ARCH}" '.[$arch+"_image_digest"] // .os_imag
3030
IMAGE_VERSION_STRING="${OS_IMAGE}@${OS_DIGEST}"
3131

3232
if [[ "${IMAGE_VERSION_STRING}" == "$(cat /etc/image)" ]]; then
33-
echo "No new image version available. Exiting."
33+
echo "No new image version available. Exiting (pre)"
34+
report_info "cuos:update:not_needed" "The system is up-to-date"
3435
exit 22
3536
fi
3637

@@ -81,10 +82,11 @@ if [[ "${DOCKER_EXIT_CODE}" = "0" ]]; then
8182

8283
sync
8384
reboot
84-
elif [[ "${DOCKER_EXIT_CODE}" = "20" ]]; then
85+
elif [[ "${DOCKER_EXIT_CODE}" = "102" ]]; then
8586
echo "No new image version available."
86-
report_info "cuos:update:not_needed" "No new image version available"
87-
elif [[ "${DOCKER_EXIT_CODE}" = "22" ]]; then
87+
report_info "cuos:update:not_needed" "The system is up-to-date"
88+
89+
elif [[ "${DOCKER_EXIT_CODE}" = "101" ]]; then
8890
echo "Not enough free disk space available"
8991
report_info "cuos:update:no_space" "Not enough free disk space available"
9092
else

‎updater/perform_update.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fi
7373
IMAGE_VERSION_STRING="${IMAGE}@${NEW_DIGEST}"
7474

7575
if [[ "${IMAGE_VERSION_STRING}" == "$(cat /etc/image 2>/dev/null)" ]]; then
76-
raise_info 102 "No OS update failable"
76+
raise_info 102 "No OS update available"
7777
fi
7878

7979
echo "INFO: Updating OS slot ${SLOT} to ${IMAGE}"

0 commit comments

Comments
 (0)