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

Child device firmware management specification #1998 #2007

Merged
merged 4 commits into from
Jun 13, 2023

Conversation

albinsuresh
Copy link
Contributor

@albinsuresh albinsuresh commented Jun 7, 2023

Proposed changes

Specification for c8y-firmware-plugin.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@albinsuresh albinsuresh force-pushed the doc/1998/firmware-plugin-spec branch from 2505253 to 31913f9 Compare June 7, 2023 08:13
Copy link
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

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

Just some minor command and improvements

Copy link
Contributor

@PradeepKiruvale PradeepKiruvale left a comment

Choose a reason for hiding this comment

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

I feel there are two parts in this doc, one is about How to use the firmware plugin, and the second one is more details about the whole process. So, I feel it's better to move the first part to a how to doc and the second part can remain here. Also, How to doc can give a link to the second part for more info.

Copy link
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

Thanks for writing the specification finally!

Is missing

  • Content of operation files under $TEDGE_DATA_PATH/firmware/<op_id>.

In addition, I commented about some mismatched with current implementation.

Child Device Connector ->> C8Y Firmware Plugin: MQTT: firmware_update response with operation status: "successful"

C8Y Firmware Plugin ->> C8Y Cloud: MQTT: Update c8y_Firmware operation status to "SUCCESSFUL"
C8Y Firmware Plugin ->> C8Y Firmware Plugin: Remove the symlink from file-transfer repository but keep the cached firmware copy for reuse
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it removes symlink... instead deleting a firmware info file under FIRMWARE_OP_PATH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should be removing those symlinks as it makes it easier for the device admin to cleanup the firmware cache, when needed by just looking at the files that don't have any symlinks pointed to it.

docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
* `reason`: The reason for the failure, applicable only for `failed` status.
1. On reception of an operation status message, the plugin maps it to SmartREST and forwards it to the cloud.
* When a `success` or `failed` status message is finally received,
then the plugin cleans up the corresponding operation file at `$FIRMWARE_OP_PATH/$OP_ID` and
Copy link
Member

Choose a reason for hiding this comment

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

As I said above, the current plugin implementation doesn't clean up symlink. If we need it, we need to change the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to change the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

So a ticket needs to be created when this PR is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: #2023

docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
@albinsuresh albinsuresh force-pushed the doc/1998/firmware-plugin-spec branch from 24a9a18 to 12bebcf Compare June 9, 2023 07:14
@albinsuresh
Copy link
Contributor Author

@PradeepKiruvale

I feel there are two parts in this doc, one is about How to use the firmware plugin, and the second one is more details about the whole process. So, I feel it's better to move the first part to a how to doc and the second part can remain here.

It was intentional as this is a reference guide that must also define how the installation of the plugin and configuration of the plugin are also supported. The dev of the plugin should have used this doc to write all that installation and configuration code as well.

Also, How to doc can give a link to the second part for more info.

Done

@albinsuresh
Copy link
Contributor Author

@rina23q

Is missing

  • Content of operation files under $TEDGE_DATA_PATH/firmware/<op_id>.

Added the details

Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved. With one suggestion to improve the introduction.

docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved
docs/src/references/c8y-firmware-management.md Outdated Show resolved Hide resolved

1. The plugin, on recept of a `c8y_Firmware` request from Cumulocity for a child device named `$CHILD_DEVICE_ID`
in the format `515,$CHILD_DEVICE_ID,$FIRMWARE_NAME,$FIRMWARE_VERSION,$FIRMWARE_URL`
1. Validate if the same firmware update operation is already in progress
Copy link
Contributor

Choose a reason for hiding this comment

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

[This is not a change request, just a piece of advice for future docs].

A nice way to ease reading such prose, is to focus on the happy/simple path and to address exceptions/corner-cases as complements. For instance,

  1. thin-edge checks the request is new and the firmware not in cache.
  2. It downloads the firmware using the sha-256 digest as file name.
  3. It creates a file named after the operation id.
  4. ...

Then the alternative paths:

  1. If the operation is already in progress, then ...
  2. If the firmware is in cache ...

See Writing Effective Use Cases

@github-actions
Copy link
Contributor

github-actions bot commented Jun 13, 2023

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
221 0 5 221 100

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.023 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.335 s C8Y Child Alarms Rpi
Normal case when the child device already exists 1.106 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.7429999999999999 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 65.537 s C8Y Child Alarms Rpi
Prerequisite Parent 15.852 s Child Conf Mgmt Plugin
Prerequisite Child 0.312 s Child Conf Mgmt Plugin
Child device bootstrapping 14.169 s Child Conf Mgmt Plugin
Snapshot from device 62.808 s Child Conf Mgmt Plugin
Child device config update 62.352 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 48.91 s Inotify Crate
Check lock file existence in default folder 1.659 s Lock File
Check PID number in lock file 1.494 s Lock File
Check PID number in lock file after restarting the services 3.017 s Lock File
Check starting same service twice 1.577 s Lock File
Switch off lock file creation 2.129 s Lock File
Set configuration when file exists 14.22 s Configuration Operation
Set configuration when file does not exist 5.654 s Configuration Operation
Set configuration with broken url 5.253 s Configuration Operation
Get configuration 5.335 s Configuration Operation
Get non existent configuration file 5.022 s Configuration Operation
Get non existent configuration type 4.306 s Configuration Operation
Update configuration plugin config via cloud 5.058 s Configuration Operation
Modify configuration plugin config via local filesystem modify inplace 2.3449999999999998 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 2.999 s Configuration Operation
Update configuration plugin config via local filesystem copy 4.156 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 3.945 s Configuration Operation
Update configuration plugin config via local filesystem move (same directory) 4.119 s Configuration Operation
Successful firmware operation 69.363 s Firmware Operation
Install with empty firmware name 47.271 s Firmware Operation
Prerequisite Parent 17.712 s Firmware Operation Child Device
Prerequisite Child 8.424 s Firmware Operation Child Device
Child device firmware update 4.571 s Firmware Operation Child Device
Child device firmware update with cache 6.039 s Firmware Operation Child Device
Firmware plugin supports restart via service manager #1932 5.358 s Firmware Operation Child Device Retry
Update Inventory data via inventory.json 1.268 s Inventory Update
Inventory includes the agent fragment with version information 1.1179999999999999 s Inventory Update
Retrieve a JWT tokens 51.228 s Jwt Request
Check running collectd 1.263 s Monitor Device Collectd
Is collectd publishing MQTT messages? 2.965 s Monitor Device Collectd
Check thin-edge monitoring 3.891 s Monitor Device Collectd
Check grouping of measurements 9.035 s Monitor Device Collectd
Update the custom operation dynamically 43.18 s Dynamically Reload Operation
Main device registration 1.958 s Device Registration
Child device registration 2.549 s Device Registration
Supports restarting the device 55.738 s Restart Device
Update tedge version from previous using Cumulocity 78.289 s Tedge Self Update
Test if all c8y services are up 47.844 s Service Monitoring
Test if all c8y services are down 104.585 s Service Monitoring
Test if all c8y services are using configured service type 52.989 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 107.208 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 25.838 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 27.551 s Service Monitoring
Check health status of child device service 24.358 s Service Monitoring
Successful shell command with output 3.651 s Shell Operation
Check Successful shell command with literal double quotes output 3.357 s Shell Operation
Execute multiline shell command 3.3449999999999998 s Shell Operation
Failed shell command 3.5789999999999997 s Shell Operation
Software list should be populated during startup 43.122 s Software
Install software via Cumulocity 47.056 s Software
Software list should only show currently installed software and not candidates 32.23 s Software
Child devices support sending simple measurements 1.439 s Child Device Telemetry
Child devices support sending custom measurements 1.169 s Child Device Telemetry
Child devices support sending custom events 1.092 s Child Device Telemetry
Child devices support sending custom events overriding the type 1.138 s Child Device Telemetry
Child devices support sending custom alarms #1699 1.193 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 0.964 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.5699999999999998 s Child Device Telemetry
Check retained alarms 225.266 s Raise Alarms
Thin-edge devices support sending simple measurements 1.292 s Thin-Edge Device Telemetry
Thin-edge devices support sending simple measurements with custom type 1.415 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom measurements 1.46 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events 1.219 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events overriding the type 1.035 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom alarms #1699 1.161 s Thin-Edge Device Telemetry
Thin-edge device supports sending custom Thin-edge device measurements directly to c8y 1.567 s Thin-Edge Device Telemetry
Thin-edge device support sending inventory data via c8y topic 1.417 s Thin-Edge Device Telemetry
thin-edge components support a custom config-dir location via flags 27.463 s Config Dir
Validate updated data path used by tedge-agent 0.804 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.68 s Data Path Config
Stop tedge-agent service 0.199 s Log Path Config
Customize the log path 0.123 s Log Path Config
Initialize tedge-agent 0.117 s Log Path Config
Check created folders 0.089 s Log Path Config
Remove created custom folders 0.123 s Log Path Config
Install thin-edge via apt 36.186 s Install Apt
Install latest via script (from current branch) 23.953 s Install Tedge
Install specific version via script (from current branch) 16.762 s Install Tedge
Install latest tedge via script (from main branch) 20.371 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 56.999 s Install Tedge
Support starting and stopping services 34.704 s Service-Control
Supports a reconnect 48.253 s Test-Commands
Supports disconnect then connect 36.924 s Test-Commands
Update unknown setting 39.729 s Test-Commands
Update known setting 37.692 s Test-Commands
Stop c8y-configuration-plugin 0.178 s Health C8Y-Configuration-Plugin
Update the service file 0.166 s Health C8Y-Configuration-Plugin
Reload systemd files 0.421 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.167 s Health C8Y-Configuration-Plugin
Start watchdog service 10.208 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.164 s Health C8Y-Configuration-Plugin
Kill the PID 0.25 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.335 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.084 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.067 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.131 s Health C8Y-Log-Plugin
Update the service file 0.205 s Health C8Y-Log-Plugin
Reload systemd files 0.401 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.141 s Health C8Y-Log-Plugin
Start watchdog service 10.138 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.119 s Health C8Y-Log-Plugin
Kill the PID 0.245 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.537 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.158 s Health C8Y-Log-Plugin
Remove entry from service file 0.147 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.142 s Health Tedge Mapper C8Y
Update the service file 0.154 s Health Tedge Mapper C8Y
Reload systemd files 0.412 s Health Tedge Mapper C8Y
Start tedge-mapper 0.244 s Health Tedge Mapper C8Y
Start watchdog service 10.332 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.187 s Health Tedge Mapper C8Y
Kill the PID 0.496 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.553 s Health Tedge Mapper C8Y
Compare PID change 0.006 s Health Tedge Mapper C8Y
Stop watchdog service 0.125 s Health Tedge Mapper C8Y
Remove entry from service file 0.104 s Health Tedge Mapper C8Y
Stop tedge-agent 0.153 s Health Tedge-Agent
Update the service file 0.109 s Health Tedge-Agent
Reload systemd files 0.365 s Health Tedge-Agent
Start tedge-agent 0.124 s Health Tedge-Agent
Start watchdog service 10.122 s Health Tedge-Agent
Check PID of tedge-mapper 0.064 s Health Tedge-Agent
Kill the PID 0.362 s Health Tedge-Agent
Recheck PID of tedge-agent 6.466 s Health Tedge-Agent
Compare PID change 0.014 s Health Tedge-Agent
Stop watchdog service 0.352 s Health Tedge-Agent
Remove entry from service file 0.136 s Health Tedge-Agent
Stop tedge-mapper-az 0.13 s Health Tedge-Mapper-Az
Update the service file 0.098 s Health Tedge-Mapper-Az
Reload systemd files 0.329 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.106 s Health Tedge-Mapper-Az
Start watchdog service 10.137 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.188 s Health Tedge-Mapper-Az
Kill the PID 0.351 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.529 s Health Tedge-Mapper-Az
Compare PID change 0.005 s Health Tedge-Mapper-Az
Stop watchdog service 0.168 s Health Tedge-Mapper-Az
Remove entry from service file 0.137 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.13 s Health Tedge-Mapper-Collectd
Update the service file 0.104 s Health Tedge-Mapper-Collectd
Reload systemd files 0.615 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.215 s Health Tedge-Mapper-Collectd
Start watchdog service 10.244 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.217 s Health Tedge-Mapper-Collectd
Kill the PID 0.199 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.31 s Health Tedge-Mapper-Collectd
Compare PID change 0 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.084 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.125 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.483 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.718 s MQTT health endpoints
c8y-configuration-plugin health status 5.553 s MQTT health endpoints
Publish on a local insecure broker 0.382 s Basic Pub Sub
Publish on a local secure broker 3.844 s Basic Pub Sub
Publish on a local secure broker with client authentication 3.288 s Basic Pub Sub
Check remote mqtt broker #1773 3.142 s Remote Mqtt Broker
Apply name filter 0.342 s Filter Packages List Output
Apply maintainer filter 0.224 s Filter Packages List Output
Apply both filters 0.263 s Filter Packages List Output
No filters 0.122 s Filter Packages List Output
Both filters but name filter as empty string 0.168 s Filter Packages List Output
Both filters but maintainer filter as empty string 0.347 s Filter Packages List Output
Both filters as empty string 0.185 s Filter Packages List Output
Wrong package name 0.121 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.174 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.764 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.46 s Tedge Connect Test
tedge_connect_test_negative 1.193 s Tedge Connect Test
tedge_connect_test_sm_services 9.263 s Tedge Connect Test
tedge_disconnect_test_sm_services 1.112 s Tedge Connect Test
Install thin-edge.io 13.939 s Call Tedge
call tedge -V 0.181 s Call Tedge
call tedge -h 0.267 s Call Tedge
call tedge -h -V 0.303 s Call Tedge
call tedge help 0.339 s Call Tedge
tedge config list 0.063 s Call Tedge Config List
tedge config list --all 0.085 s Call Tedge Config List
set/unset device.type 0.34 s Call Tedge Config List
set/unset device.key_path 0.311 s Call Tedge Config List
set/unset device.cert_path 0.257 s Call Tedge Config List
set/unset c8y.root_cert_path 0.263 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.255 s Call Tedge Config List
set/unset az.root_cert_path 0.271 s Call Tedge Config List
set/unset aws.url 0.24 s Call Tedge Config List
set/unset aws.root_cert_path 0.273 s Call Tedge Config List
set/unset aws.mapper.timestamp 0.305 s Call Tedge Config List
set/unset az.mapper.timestamp 0.289 s Call Tedge Config List
set/unset mqtt.bind.address 0.251 s Call Tedge Config List
set/unset mqtt.bind.port 0.294 s Call Tedge Config List
set/unset http.bind.port 0.295 s Call Tedge Config List
set/unset tmp.path 0.291 s Call Tedge Config List
set/unset logs.path 0.332 s Call Tedge Config List
set/unset run.path 0.292 s Call Tedge Config List
set/unset firmware.child.update.timeout 0.262 s Call Tedge Config List
set/unset c8y.url 0.389 s Call Tedge Config List
set/unset az.url 0.491 s Call Tedge Config List
set/unset mqtt.external.bind.port 0.361 s Call Tedge Config List
mqtt.external.bind.address 0.446 s Call Tedge Config List
mqtt.external.bind.interface 0.552 s Call Tedge Config List
set/unset mqtt.external.ca_path 0.518 s Call Tedge Config List
set/unset mqtt.external.cert_file 0.528 s Call Tedge Config List
set/unset mqtt.external.key_file 0.651 s Call Tedge Config List
set/unset software.plugin.default 0.683 s Call Tedge Config List
Get Put Delete 1.516 s Http File Transfer Api
Set keys should return value on stdout 0.12 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.255 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.24 s Tedge Config Get
Set configuration via environment variables 1.284 s Tedge Config Get
Set unknown configuration via environment variables 0.076 s Tedge Config Get

@albinsuresh albinsuresh temporarily deployed to Test Pull Request June 13, 2023 12:18 — with GitHub Actions Inactive
@albinsuresh albinsuresh temporarily deployed to Test Pull Request June 13, 2023 13:06 — with GitHub Actions Inactive
@albinsuresh albinsuresh merged commit 7850dd9 into thin-edge:main Jun 13, 2023
@albinsuresh albinsuresh deleted the doc/1998/firmware-plugin-spec branch June 14, 2023 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants