Skip to content

Commit

Permalink
Merge pull request #52 from thin-edge/feat-ignore-cloud-remote-access…
Browse files Browse the repository at this point in the history
…-containers

feat: use predictable container names for remote access and self updates
  • Loading branch information
reubenmiller authored Dec 3, 2024
2 parents 88d8260 + 2a631cb commit 27a62da
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
20 changes: 8 additions & 12 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,29 @@ Self updates can be done by using `container` type.
c8y software versions create \
--software tedge \
--url " " \
--version "ghcr.io/thin-edge/tedge-container-bundle:20240929.1503"
--version "ghcr.io/thin-edge/tedge-container-bundle:20241201.0920"
```

```sh
c8y software versions create \
--software tedge \
--url " " \
--version "ghcr.io/thin-edge/tedge-container-bundle:latest"
```

3. Create an operation to install software
3. Create an operation to install software (go-c8y-cli >= v2.45.0)

```sh
c8y software versions install \
--device "subdevice01" \
--action install \
--software tedge \
--version "ghcr.io/thin-edge/tedge-container-bundle:latest"
--version "ghcr.io/thin-edge/tedge-container-bundle:20241201.0920"
```

Or if you haven't created a `tedge` software repository item, then you can install software without it, by specifying all of the required fields (including a empty space for the `--url` flag.)
```sh
c8y software versions install \
--device "subdevice01" \
--action install \
--software tedge \
--data softwareType=container \
--softwareType container \
--url " " \
--version "ghcr.io/thin-edge/tedge-container-bundle:latest"
--version "ghcr.io/thin-edge/tedge-container-bundle:20241201.0920"
```
Expand Down
2 changes: 1 addition & 1 deletion files/tedge/launch-remote-access.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ if [ "$REMOTE_ACCESS_DISABLE_CONTAINER_SPAWN" = 1 ] || ! has_container_api_acces
fi

echo "Launching session in an independent container"
$SUDO tedge-container tools run-in-context --rm -- c8y-remote-access-plugin --child "$@"
$SUDO tedge-container tools run-in-context --name-prefix remoteaccess-connect --rm -- c8y-remote-access-plugin --child "$@"
exit 0
7 changes: 6 additions & 1 deletion files/tedge/self_update.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on_exit.2 = "successful"
on_exit._ = "failed"

[update]
script = "sudo -E tedge-container tools container-clone --fork --image ${.payload.image} --container ${.payload.containerName} --stop-after 10s"
script = "sudo -E tedge-container tools container-clone --fork --image ${.payload.image} --container ${.payload.containerName} --fork-name ${.payload.containerName}-updater --stop-after 10s"
on_success = "wait-for-container-stop"
on_error = "failed"

Expand All @@ -31,6 +31,11 @@ on_exec = "resume-update"
[resume-update]
# Wait before verifying to give the container updater to verify the image
script = "sh -c 'sudo -E tedge-container self list && sleep 60'"
on_success = "collect-logs"
on_error = "collect-logs"

[collect-logs]
script = "sh -c 'sudo -E tedge-container tools container-logs ${.payload.containerName}-updater && sudo -E tedge-container tools container-remove ${.payload.containerName}-updater'"
on_success = "verify"
on_error = "verify"

Expand Down
3 changes: 3 additions & 0 deletions test-images/debian-systemd-podman-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ARG TARGETPLATFORM
# Allow ssh connection from container network
RUN sed -i 's|^ListenAddress 127.0.0.1|ListenAddress 0.0.0.0|g' /etc/ssh/sshd_config

# Disable tedge-container-plugin running on the host
RUN systemctl disable tedge-container-plugin

RUN tedge config unset c8y.proxy.client.host \
&& tedge config unset mqtt.client.host \
&& tedge config unset http.client.host
14 changes: 14 additions & 0 deletions tests/main/container.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*** Settings ***
Resource ../resources/common.resource

Test Setup Setup Device
Test Teardown Stop Device


*** Test Cases ***
Ignore Containers Marked With A Specific Label
${operation}= Cumulocity.Execute Shell Command
... text=sudo -E tedge-container engine docker run -d --label tedge.ignore=1 --network bridge --name manualapp10 docker.io/library/alpine:3.18 sleep infinity
Cumulocity.Operation Should Be SUCCESSFUL ${operation}
Sleep 5s
Should Have Services service_type=container name=manualapp10 max_count=0 min_count=0

7 comments on commit 27a62da

@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
18 0 2 18 100 5m53.076248999s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 26.059 s Container
Grace period to allow container to startup 5.044 s Operations
Service is up 0.169 s Operations
Get Logfile Request 2.347 s Operations
Get Configuration File 4.715 s Operations
Execute Shell Command 2.363 s Operations
Install application using docker compose 15.334 s Operations
Get Container Logs 2.361 s Operations
Get Container Logs without explicit container name 2.363 s Operations
Get Container Logs For Non-existent container 2.366 s Operations
Trigger self update via local command 25.238 s Self-Update
Self update should only update if there is a new image 20.055 s Self-Update
Self update using software update operation 100.097 s Self-Update
Rollback when trying to install a non-tedge based image 20.158 s Self-Update
Self update using software update operation using Container type 101.398 s Self-Update
Cloud Connection is Online 0.162 s Telemetry
Service status 0.249 s Telemetry
Sends measurements 2.704 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
18 0 2 18 100 6m12.610953s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 29.299 s Container
Grace period to allow container to startup 5.039 s Operations
Service is up 0.199 s Operations
Get Logfile Request 4.666 s Operations
Get Configuration File 5.039 s Operations
Execute Shell Command 2.526 s Operations
Install application using docker compose 16.773 s Operations
Get Container Logs 2.526 s Operations
Get Container Logs without explicit container name 2.532 s Operations
Get Container Logs For Non-existent container 2.528 s Operations
Trigger self update via local command 24.444 s Self-Update
Self update should only update if there is a new image 22.565 s Self-Update
Self update using software update operation 100.579 s Self-Update
Rollback when trying to install a non-tedge based image 24.912 s Self-Update
Self update using software update operation using Container type 103.847 s Self-Update
Cloud Connection is Online 0.210 s Telemetry
Service status 0.368 s Telemetry
Sends measurements 3.091 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
19 0 1 19 100 8m8.1832s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 25.684 s Container
Grace period to allow container to startup 5.040 s Operations
Service is up 0.148 s Operations
Get Logfile Request 4.449 s Operations
Get Configuration File 4.683 s Operations
Execute Shell Command 2.358 s Operations
Install application using docker compose 18.249 s Operations
Get Container Logs 4.460 s Operations
Get Container Logs without explicit container name 2.369 s Operations
Get Container Logs For Non-existent container 2.361 s Operations
Update From Legacy Versions 138.710 s Self-Update-Compat
Trigger self update via local command 24.985 s Self-Update
Self update should only update if there is a new image 20.493 s Self-Update
Self update using software update operation 102.820 s Self-Update
Rollback when trying to install a non-tedge based image 20.940 s Self-Update
Self update using software update operation using Container type 107.477 s Self-Update
Cloud Connection is Online 0.158 s Telemetry
Service status 0.269 s Telemetry
Sends measurements 2.492 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
19 0 1 19 100 8m10.527925s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 25.840 s Container
Grace period to allow container to startup 5.041 s Operations
Service is up 0.150 s Operations
Get Logfile Request 2.348 s Operations
Get Configuration File 4.703 s Operations
Execute Shell Command 2.365 s Operations
Install application using docker compose 17.449 s Operations
Get Container Logs 2.358 s Operations
Get Container Logs without explicit container name 2.364 s Operations
Get Container Logs For Non-existent container 2.366 s Operations
Update From Legacy Versions 137.706 s Self-Update-Compat
Trigger self update via local command 25.106 s Self-Update
Self update should only update if there is a new image 20.737 s Self-Update
Self update using software update operation 110.336 s Self-Update
Rollback when trying to install a non-tedge based image 21.182 s Self-Update
Self update using software update operation using Container type 107.552 s Self-Update
Cloud Connection is Online 0.159 s Telemetry
Service status 0.253 s Telemetry
Sends measurements 2.471 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
19 0 1 19 100 8m13.225289s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 26.298 s Container
Grace period to allow container to startup 5.041 s Operations
Service is up 0.151 s Operations
Get Logfile Request 2.346 s Operations
Get Configuration File 4.683 s Operations
Execute Shell Command 2.368 s Operations
Install application using docker compose 15.354 s Operations
Get Container Logs 2.360 s Operations
Get Container Logs without explicit container name 4.465 s Operations
Get Container Logs For Non-existent container 2.363 s Operations
Update From Legacy Versions 145.025 s Self-Update-Compat
Trigger self update via local command 25.541 s Self-Update
Self update should only update if there is a new image 20.998 s Self-Update
Self update using software update operation 104.090 s Self-Update
Rollback when trying to install a non-tedge based image 21.517 s Self-Update
Self update using software update operation using Container type 107.697 s Self-Update
Cloud Connection is Online 0.159 s Telemetry
Service status 0.248 s Telemetry
Sends measurements 2.471 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
19 0 1 19 100 8m9.097214s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 26.179 s Container
Grace period to allow container to startup 5.046 s Operations
Service is up 0.158 s Operations
Get Logfile Request 2.384 s Operations
Get Configuration File 4.753 s Operations
Execute Shell Command 2.397 s Operations
Install application using docker compose 19.681 s Operations
Get Container Logs 2.402 s Operations
Get Container Logs without explicit container name 2.417 s Operations
Get Container Logs For Non-existent container 2.394 s Operations
Update From Legacy Versions 140.106 s Self-Update-Compat
Trigger self update via local command 25.414 s Self-Update
Self update should only update if there is a new image 20.856 s Self-Update
Self update using software update operation 103.762 s Self-Update
Rollback when trying to install a non-tedge based image 21.336 s Self-Update
Self update using software update operation using Container type 106.695 s Self-Update
Cloud Connection is Online 0.182 s Telemetry
Service status 0.330 s Telemetry
Sends measurements 2.561 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
19 0 1 19 100 8m25.103587999s

Passed Tests

Name ⏱️ Duration Suite
Ignore Containers Marked With A Specific Label 28.081 s Container
Grace period to allow container to startup 5.048 s Operations
Service is up 0.214 s Operations
Get Logfile Request 4.703 s Operations
Get Configuration File 5.038 s Operations
Execute Shell Command 2.556 s Operations
Install application using docker compose 13.873 s Operations
Get Container Logs 2.542 s Operations
Get Container Logs without explicit container name 2.544 s Operations
Get Container Logs For Non-existent container 2.561 s Operations
Update From Legacy Versions 144.182 s Self-Update-Compat
Trigger self update via local command 25.849 s Self-Update
Self update should only update if there is a new image 22.262 s Self-Update
Self update using software update operation 106.631 s Self-Update
Rollback when trying to install a non-tedge based image 25.966 s Self-Update
Self update using software update operation using Container type 109.655 s Self-Update
Cloud Connection is Online 0.232 s Telemetry
Service status 0.383 s Telemetry
Sends measurements 2.723 s Telemetry

Please sign in to comment.