Skip to content

Commit

Permalink
Merge pull request #49 from thin-edge/fix-self-update-from-older-vers…
Browse files Browse the repository at this point in the history
…ions

fix(self-update): add compatibility script to update from older versions
  • Loading branch information
reubenmiller authored Nov 28, 2024
2 parents f86e668 + c603944 commit 47b65d2
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ COPY files/tedge/launch-remote-access.sh /usr/bin/
# Self update workflow
COPY files/tedge/software_update.toml /etc/tedge/operations/
COPY files/tedge/self_update.toml /etc/tedge/operations/
# Self update compatibility script for updating from images <= 20241126.1855
COPY files/tedge/self_update.sh /usr/bin/
# Container log_upload customer handler
COPY files/tedge/container-logs.sh /usr/bin/
COPY files/tedge/log_upload.toml /etc/tedge/operations/
Expand Down
47 changes: 47 additions & 0 deletions files/tedge/self_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh
# Compatibility script for updating of images from older versions <= 20241126.1855
#

#
# Argument parsing
#
ACTION="$1"
shift

IMAGE=
CURRENT_CONTAINER_ID=

DOCKER_CMD=docker
if ! docker ps >/dev/null 2>&1; then
if command -V sudo >/dev/null 2>&1; then
DOCKER_CMD="sudo docker"
fi
fi

while [ $# -gt 0 ]; do
case "$1" in
--image)
IMAGE="$2"
shift
;;
--container-name)
# not used
shift
;;
--container-id)
CURRENT_CONTAINER_ID="$2"
shift
;;
esac
shift
done

case "$ACTION" in
update)
# In previous images, only docker was supported
echo "Calling legacy update script (upgrading from an image <= 20241126.1855)"
$DOCKER_CMD run -t --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
"$IMAGE" sudo tedge-container tools container-clone --container "$CURRENT_CONTAINER_ID" --image "$IMAGE"
;;
esac
4 changes: 3 additions & 1 deletion test-images/common/container-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ while [ $# -gt 0 ]; do
shift
;;
--image)
IMAGE="$2"
if [ -n "$2" ]; then
IMAGE="$2"
fi
shift
;;
--debug)
Expand Down
36 changes: 36 additions & 0 deletions tests/main/self-update-compat.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*** Settings ***
Resource ../resources/common.resource
Library DateTime

Test Teardown Stop Device

Test Tags self-update


*** Test Cases ***
Update From Legacy Versions
[Template] Upgrade From Base Image
ghcr.io/thin-edge/tedge-container-bundle:20241126.1855 tedge-container-bundle:20241126.1855


*** Keywords ***
Upgrade From Base Image
[Arguments] ${IMAGE} ${SOFTWARE_VERSION}
# pre-condition
Setup Device image=${IMAGE}

${major_version}= Execute Command
... podman --version | cut -d' ' -f3 | cut -d. -f1
... ignore_exit_code=${True}
... strip=${True}
Skip If '${major_version}' == '4' Legacy images didn't support podman 4.x

Device Should Have Installed Software
... {"name": "tedge", "version": "${SOFTWARE_VERSION}", "softwareType": "self"} timeout=10

${operation}= Cumulocity.Install Software
... {"name": "tedge", "version": "ghcr.io/thin-edge/tedge-container-bundle:99.99.1", "softwareType": "self"}

Cumulocity.Operation Should Be SUCCESSFUL ${operation} timeout=120
Device Should Have Installed Software
... {"name": "tedge", "version": "tedge-container-bundle:99.99.1", "softwareType": "self"}
4 changes: 3 additions & 1 deletion tests/resources/common.resource
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ Library DeviceLibrary bootstrap_script=/dev/null

*** Keywords ***
Setup Device
[Arguments] ${image}=
${DEVICE_ID}= DeviceLibrary.Setup skip_bootstrap=${True}

Transfer To Device ${CURDIR}/../../test-images/common/container-bundle.sh /usr/bin/
Transfer To Device ${CURDIR}/../*.tar.gz /build/
Execute Command container-bundle.sh start --device-id '${DEVICE_ID}' --c8y-url '${C8Y_CONFIG.host}' --debug 2>&1
Execute Command
... container-bundle.sh start --device-id '${DEVICE_ID}' --c8y-url '${C8Y_CONFIG.host}' --image "${image}" --debug 2>&1

Set Suite Variable ${DEVICE_ID}
Cumulocity.External Identity Should Exist ${DEVICE_ID}
Expand Down

14 comments on commit 47b65d2

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
16 0 2 16 100 3m47.168322s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.042 s Operations
Service is up 0.155 s Operations
Get Logfile Request 2.354 s Operations
Get Configuration File 4.704 s Operations
Execute Shell Command 2.363 s Operations
Install application using docker compose 17.505 s Operations
Get Container Logs 2.364 s Operations
Get Container Logs without explicit container name 2.378 s Operations
Get Container Logs For Non-existent container 2.380 s Operations
Trigger self update via local command 24.243 s Self-Update
Self update should only update if there is a new image 20.019 s Self-Update
Self update using software update operation 100.428 s Self-Update
Rollback when trying to install a non-tedge based image 20.447 s Self-Update
Cloud Connection is Online 0.170 s Telemetry
Service status 0.267 s Telemetry
Sends measurements 2.487 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
16 0 2 16 100 3m47.015141s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.064 s Operations
Service is up 0.155 s Operations
Get Logfile Request 2.352 s Operations
Get Configuration File 4.734 s Operations
Execute Shell Command 2.377 s Operations
Install application using docker compose 17.436 s Operations
Get Container Logs 2.376 s Operations
Get Container Logs without explicit container name 2.370 s Operations
Get Container Logs For Non-existent container 2.368 s Operations
Trigger self update via local command 23.663 s Self-Update
Self update should only update if there is a new image 21.295 s Self-Update
Self update using software update operation 99.046 s Self-Update
Rollback when trying to install a non-tedge based image 21.434 s Self-Update
Cloud Connection is Online 0.170 s Telemetry
Service status 0.268 s Telemetry
Sends measurements 2.480 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m49.855721s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.047 s Operations
Service is up 0.149 s Operations
Get Logfile Request 2.349 s Operations
Get Configuration File 4.661 s Operations
Execute Shell Command 2.359 s Operations
Install application using docker compose 19.499 s Operations
Get Container Logs 2.354 s Operations
Get Container Logs without explicit container name 2.358 s Operations
Get Container Logs For Non-existent container 2.352 s Operations
Update From Legacy Versions 129.525 s Self-Update-Compat
Trigger self update via local command 25.156 s Self-Update
Self update should only update if there is a new image 20.965 s Self-Update
Self update using software update operation 105.046 s Self-Update
Rollback when trying to install a non-tedge based image 25.069 s Self-Update
Cloud Connection is Online 0.167 s Telemetry
Service status 0.249 s Telemetry
Sends measurements 2.503 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m48.900692s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.054 s Operations
Service is up 0.182 s Operations
Get Logfile Request 2.356 s Operations
Get Configuration File 4.715 s Operations
Execute Shell Command 2.371 s Operations
Install application using docker compose 19.549 s Operations
Get Container Logs 2.368 s Operations
Get Container Logs without explicit container name 2.373 s Operations
Get Container Logs For Non-existent container 2.361 s Operations
Update From Legacy Versions 128.376 s Self-Update-Compat
Trigger self update via local command 24.964 s Self-Update
Self update should only update if there is a new image 20.985 s Self-Update
Self update using software update operation 104.849 s Self-Update
Rollback when trying to install a non-tedge based image 25.440 s Self-Update
Cloud Connection is Online 0.167 s Telemetry
Service status 0.262 s Telemetry
Sends measurements 2.487 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m49.239095s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.048 s Operations
Service is up 0.148 s Operations
Get Logfile Request 2.350 s Operations
Get Configuration File 4.713 s Operations
Execute Shell Command 2.373 s Operations
Install application using docker compose 17.427 s Operations
Get Container Logs 2.362 s Operations
Get Container Logs without explicit container name 2.367 s Operations
Get Container Logs For Non-existent container 2.378 s Operations
Update From Legacy Versions 131.133 s Self-Update-Compat
Trigger self update via local command 25.067 s Self-Update
Self update should only update if there is a new image 20.484 s Self-Update
Self update using software update operation 103.251 s Self-Update
Rollback when trying to install a non-tedge based image 27.136 s Self-Update
Cloud Connection is Online 0.166 s Telemetry
Service status 0.269 s Telemetry
Sends measurements 2.528 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m52.560412s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.056 s Operations
Service is up 0.158 s Operations
Get Logfile Request 2.354 s Operations
Get Configuration File 4.696 s Operations
Execute Shell Command 2.372 s Operations
Install application using docker compose 17.806 s Operations
Get Container Logs 2.379 s Operations
Get Container Logs without explicit container name 2.373 s Operations
Get Container Logs For Non-existent container 2.368 s Operations
Update From Legacy Versions 131.678 s Self-Update-Compat
Trigger self update via local command 25.479 s Self-Update
Self update should only update if there is a new image 21.108 s Self-Update
Self update using software update operation 103.641 s Self-Update
Rollback when trying to install a non-tedge based image 28.135 s Self-Update
Cloud Connection is Online 0.169 s Telemetry
Service status 0.266 s Telemetry
Sends measurements 2.485 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m54.344139s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.043 s Operations
Service is up 0.177 s Operations
Get Logfile Request 2.449 s Operations
Get Configuration File 4.857 s Operations
Execute Shell Command 2.447 s Operations
Install application using docker compose 15.635 s Operations
Get Container Logs 2.441 s Operations
Get Container Logs without explicit container name 2.473 s Operations
Get Container Logs For Non-existent container 2.442 s Operations
Update From Legacy Versions 132.540 s Self-Update-Compat
Trigger self update via local command 27.465 s Self-Update
Self update should only update if there is a new image 23.167 s Self-Update
Self update using software update operation 107.314 s Self-Update
Rollback when trying to install a non-tedge based image 22.860 s Self-Update
Cloud Connection is Online 0.173 s Telemetry
Service status 0.287 s Telemetry
Sends measurements 2.536 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
16 0 2 16 100 3m58.706561s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.050 s Operations
Service is up 0.208 s Operations
Get Logfile Request 4.704 s Operations
Get Configuration File 5.039 s Operations
Execute Shell Command 2.545 s Operations
Install application using docker compose 16.055 s Operations
Get Container Logs 2.556 s Operations
Get Container Logs without explicit container name 2.897 s Operations
Get Container Logs For Non-existent container 2.546 s Operations
Trigger self update via local command 24.635 s Self-Update
Self update should only update if there is a new image 20.441 s Self-Update
Self update using software update operation 103.184 s Self-Update
Rollback when trying to install a non-tedge based image 24.776 s Self-Update
Cloud Connection is Online 0.234 s Telemetry
Service status 0.404 s Telemetry
Sends measurements 2.770 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
16 0 2 16 100 4m5.488303999s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.044 s Operations
Service is up 0.232 s Operations
Get Logfile Request 4.751 s Operations
Get Configuration File 5.132 s Operations
Execute Shell Command 2.590 s Operations
Install application using docker compose 20.603 s Operations
Get Container Logs 2.588 s Operations
Get Container Logs without explicit container name 2.596 s Operations
Get Container Logs For Non-existent container 2.585 s Operations
Trigger self update via local command 26.023 s Self-Update
Self update should only update if there is a new image 21.012 s Self-Update
Self update using software update operation 103.534 s Self-Update
Rollback when trying to install a non-tedge based image 23.593 s Self-Update
Cloud Connection is Online 0.226 s Telemetry
Service status 0.392 s Telemetry
Sends measurements 2.720 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m44.808221s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.036 s Operations
Service is up 0.143 s Operations
Get Logfile Request 2.340 s Operations
Get Configuration File 4.665 s Operations
Execute Shell Command 2.388 s Operations
Install application using docker compose 17.410 s Operations
Get Container Logs 2.380 s Operations
Get Container Logs without explicit container name 2.353 s Operations
Get Container Logs For Non-existent container 2.350 s Operations
Update From Legacy Versions 129.915 s Self-Update-Compat
Trigger self update via local command 24.932 s Self-Update
Self update should only update if there is a new image 20.460 s Self-Update
Self update using software update operation 102.547 s Self-Update
Rollback when trying to install a non-tedge based image 24.949 s Self-Update
Cloud Connection is Online 0.157 s Telemetry
Service status 0.275 s Telemetry
Sends measurements 2.459 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m44.609508s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.043 s Operations
Service is up 0.146 s Operations
Get Logfile Request 2.380 s Operations
Get Configuration File 4.687 s Operations
Execute Shell Command 2.370 s Operations
Install application using docker compose 17.430 s Operations
Get Container Logs 2.364 s Operations
Get Container Logs without explicit container name 2.365 s Operations
Get Container Logs For Non-existent container 2.366 s Operations
Update From Legacy Versions 128.361 s Self-Update-Compat
Trigger self update via local command 25.140 s Self-Update
Self update should only update if there is a new image 20.337 s Self-Update
Self update using software update operation 103.905 s Self-Update
Rollback when trying to install a non-tedge based image 24.774 s Self-Update
Cloud Connection is Online 0.172 s Telemetry
Service status 0.259 s Telemetry
Sends measurements 2.469 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m46.688128s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.057 s Operations
Service is up 0.141 s Operations
Get Logfile Request 2.350 s Operations
Get Configuration File 4.655 s Operations
Execute Shell Command 2.355 s Operations
Install application using docker compose 19.485 s Operations
Get Container Logs 2.376 s Operations
Get Container Logs without explicit container name 2.349 s Operations
Get Container Logs For Non-existent container 2.351 s Operations
Update From Legacy Versions 127.833 s Self-Update-Compat
Trigger self update via local command 24.862 s Self-Update
Self update should only update if there is a new image 20.436 s Self-Update
Self update using software update operation 104.429 s Self-Update
Rollback when trying to install a non-tedge based image 25.087 s Self-Update
Cloud Connection is Online 0.163 s Telemetry
Service status 0.247 s Telemetry
Sends measurements 2.463 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m51.046262s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.046 s Operations
Service is up 0.163 s Operations
Get Logfile Request 2.381 s Operations
Get Configuration File 4.737 s Operations
Execute Shell Command 2.394 s Operations
Install application using docker compose 15.443 s Operations
Get Container Logs 2.400 s Operations
Get Container Logs without explicit container name 2.397 s Operations
Get Container Logs For Non-existent container 2.408 s Operations
Update From Legacy Versions 130.205 s Self-Update-Compat
Trigger self update via local command 25.962 s Self-Update
Self update should only update if there is a new image 21.961 s Self-Update
Self update using software update operation 104.553 s Self-Update
Rollback when trying to install a non-tedge based image 27.915 s Self-Update
Cloud Connection is Online 0.176 s Telemetry
Service status 0.293 s Telemetry
Sends measurements 2.573 s Telemetry

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
17 0 1 17 100 5m53.176572999s

Passed Tests

Name ⏱️ Duration Suite
Grace period to allow container to startup 5.042 s Operations
Service is up 0.156 s Operations
Get Logfile Request 2.348 s Operations
Get Configuration File 4.705 s Operations
Execute Shell Command 2.380 s Operations
Install application using docker compose 15.287 s Operations
Get Container Logs 2.361 s Operations
Get Container Logs without explicit container name 2.356 s Operations
Get Container Logs For Non-existent container 2.385 s Operations
Update From Legacy Versions 131.453 s Self-Update-Compat
Trigger self update via local command 26.179 s Self-Update
Self update should only update if there is a new image 21.792 s Self-Update
Self update using software update operation 104.728 s Self-Update
Rollback when trying to install a non-tedge based image 29.037 s Self-Update
Cloud Connection is Online 0.168 s Telemetry
Service status 0.258 s Telemetry
Sends measurements 2.492 s Telemetry

Please sign in to comment.