thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
219 stars 54 forks source link

Workflow definitions are not backward compatible #3077

Open didier-wenzek opened 3 weeks ago

didier-wenzek commented 3 weeks ago

Describe the bug

Updating thin-edge on a device breaks any workflow which definition contains deprecated definition.

Notably, the restart action has been deprecated with the introduction of sub-operation workflows and this change has been reported in the rugpi firmware update workflow:

[restart]
- action = "restart"
- on_exec = "restarting"  # Internal state used by the "restart" action
+ operation = "restart"
+ on_exec = "await_restart"
+
+ [await_restart]
+ action = "await-operation-completion"
on_success = "restarted"
on_error = { status = "failed_restart", reason = "Failed to restart device" }

Then updating tedge-agent on a device running a firmware that is older than this change, will break firmware updates. Subsequent firmware updates will stay in the init state for ever, being ignored by the update agent which ignores the old syntax.

To Reproduce

Expected behavior

The firmware command should proceed from init to scheduled, executing ... as defined by the /etc/tedge/operations/firmware_update.toml workflow.

Upgrading thin-edge must not invalidate previously valid operation workflows

Screenshots

Environment (please complete the following information):

Additional context

reubenmiller commented 2 weeks ago

Though just a comment, it is highly advised that when using a firmware image (e.g. using Rugpi or Yocto) that the thin-edge.io version is only updated via a firmware operation as the operation support rolling back incase of any unexpected errors (such as invalid workflows). I'm fairly confident that upgrading devices across thin-edge.io 1.0.1 -> 1.2.0 version is supported as the firmware_update.toml workflow is actually a symlink enabling the syntax to change across the firmware images (but I'll double check the update to be sure).

didier-wenzek commented 2 weeks ago

I'm fairly confident that upgrading devices across thin-edge.io 1.0.1 -> 1.2.0 version is supported as the firmware_update.toml workflow is actually a symlink enabling the syntax to change across the firmware images (but I'll double check the update to be sure).

I'm confident of that too. The current issue has been observed in a case where thin-edge has been updated manually:

  1. Install firmware with thin-edge 1.01
  2. Upgrade thin-edge to 1.1.0 (this is the offending step)
  3. Upgrade to firmware with thin-edge 1.2.0.