Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare How-To Guide documentation page for performing an OTA update via the Update Manager #247

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions web/site/content/docs/how-to-guides/perform-ota-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
title: "Perform OTA update"
type: docs
description: >
Perform an OTA update on your edge device.
weight: 3
---

By following the steps below you will publish a simple desired state specification to a MQTT topic
and then the specification will be forwarded to the Update Manager, which will trigger an OTA update on
the edge device.

A simple listener for MQTT messages will track the progress and the status of the update process.
### Before you begin

To ensure that all steps in this guide can be executed, you need:

* Debian-based linux distribution and the `apt` command line tool

* If you don't have an installed and running Eclipse Kanto, follow {{% relrefn "install" %}} Install Eclipse Kanto {{% /relrefn %}}

* Ensure the Kanto container management & update manager services are up & running

* Ensure the Mosquitto service is up & running:
philip-fidanov marked this conversation as resolved.
Show resolved Hide resolved

* Run Mosquitto listener to track the desired state feedback messages by executing:
Copy link
Contributor

Choose a reason for hiding this comment

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

All other guides are using python scripts for monitoring and publishing data. This how-to guide should be implemented the same way. You can use the paho-mqtt library.

```shell
mosquitto_sub -t "deviceupdate/desiredstatefeedback" -v
```

### Publish the Desired State specification
philip-fidanov marked this conversation as resolved.
Show resolved Hide resolved

The starting point of the OTA update process is to publish the example Desired State specification below on the MQTT topic `deviceupdate\desiredstate`:
```
{
"activityId": "testActivitityId",
philip-fidanov marked this conversation as resolved.
Show resolved Hide resolved
"payload": {
"domains": [
{
"id": "containers",
"config": [],
"components": [
{
"id": "influxdb",
"version": "latest",
"config": [
{
"key": "image",
"value": "docker.io/library/influxdb:latest"
}
]
},
{
"id": "alpine",
"version": "latest",
"config": [
{
"key": "image",
"value": "docker.io/library/alpine:latest"
}
]
},
{
"id": "hello-world",
"version": "latest",
"config": [
{
"key": "image",
"value": "docker.io/library/hello-world:latest"
}
]
}
]
}
]
}
}
```
The desired state specification in this case consists of single domain section definition for the containers domain and a three container components - `influxdb`, `hello-world` and `alpine` image.

### Apply Desired State specification

The Update Manager receives the published desired state to the local Mosquitto broker, splits the specification (in this case into single domain) and then
distributes the processed specification to the domain agents which initiates the actual update process logic on the domain agents side.

The update process is organized into multiple phases, which are triggered by sending specific desired state commands (`DOWNLOAD/UPDTE/ACTIVATE`).
dimitar-dimitrow marked this conversation as resolved.
Show resolved Hide resolved

In the example scenario, the three images for the three container components will be pulled (if not available in the cache locally), created as containers during the `UPDATING` phase and
started in the `ACTIVATING` phase.

At last, the `CLEANUP` phase will be executed to do some clean up actions after the activation of the components.
philip-fidanov marked this conversation as resolved.
Show resolved Hide resolved

### Monitor OTA update progress

During the OTA update, the progress can be tracked and monitored by the Mosquitto listener for the desired state feedback messages, started in the prerequisite section above.

The Update Manager reports to the local Mosquitto broker at a time interval of a second the status of the active update process. For example:
```
{
"activityId": "testActivitityId",
"payload": {
"status": "RUNNING",
"actions": [
{
"component": {
"id": "containers:hello-world",
"version": "latest"
},
"status": "UPDATE_SUCCESS",
"message": "New container instance is started."
},
{
"component": {
"id": "containers:influxdb",
"version": "latest"
},
"status": "UPDATE_SUCCESS",
"message": "New container instance is started."
},
{
"component": {
"id": "containers:alpine",
"version": "latest"
},
"status": "UPDATING",
"message": "New container created."
}
]
}
}
```

### List containers

After the update process is completed, list the installed containers by executing the command `kanto-cm list` to the verify the desired state is applied correctly.

The output of the command should display the info about the three containers, described in the desired state specification. The `influxdb` is expected to be in `RUNNING` state and
the other containers in status `EXITED`. For example :
```
ID |Name |Image |Status |Finished At |Exit Code
|-------------------------------------|-------------|------------------------------------|----------------------|---------
7fe6b689-eb76-476d-a730-c2f422d6e8ea |influxdb |docker.io/library/influxdb:latest |Running | |0
c36523d7-8d17-4255-ae0c-37f11003f658 |hello-world |docker.io/library/hello-world:latest|Exited | |0
9b99978b-2593-4736-bb52-7a07be4a7ed1 |alpine |docker.io/library/alpine:latest |Exited | |0
```