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

Enable users to configure location of tedge-agent current operation state folder (.agent) #2488

Closed
reubenmiller opened this issue Nov 30, 2023 · 2 comments
Assignees
Labels
idea ideas/opportunities/feature requests which need to be further investigated before implementation
Milestone

Comments

@reubenmiller
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Doing firmware updates requires certain tedge-agent state to be persisted across partition swaps in order for the agent to know that it was in the middle of processing a firmware update operation (even before any kind of restore backup state can be executed).

This "current operation" state is stored in the /etc/tedge/.agent folder.

Describe the solution you'd like

Make the /etc/tedge/.agent folder configurable via the tedge.toml.

Below shows an example of the desired tedge.toml setting.

file: /etc/tedge/tedge.toml

agent.state.path = "/data/tedge/.agent"

Another slight variant of the above value would be to have a configurable fallback settings, which

agent.state.persistent.path = "/data/tedge/.agent"

On startup, the tedge-agent would check if the persistent folder exists and if it does use that folder, otherwise use the default /etc/tedge/.agent (e.g. the path controlled via the --config-dir flag of the tedge-agent)

STATE_DIR=/etc/tedge/.agent
IF PATH_EXISTS(get_value(agent.state.persistent.path)) THEN
    STATE_DIR = get_value(agent.state.persistent.path)
END

The later would have the advantage that this setting would be baked into the defaults of the thin-edge.io agent making it slightly less open to misconfiguration, as the value has a sensible default value, where the behaviour can be modified by just creating the folder at /data/tedge/.agent (for example). Other misconfigurations would be very easy as the user could be changing some other settings in the tedge.toml file during the build process, and this would result in the firmware operation not resuming after a partition swap (with no possibility of a rollback happening without the assistance of an independent rollback service)

Notes

  • For this to work the agent.state.path value needs to be set both before and after the firmware update. In practice this value will part of the initial firmware (OS) image and included in all subsequent firmware (OS) images, otherwise it will not work.

Describe alternatives you've considered

The current workaround is to configure the /etc/tedge/.agent folder to be a symlink to /data/tedge/.agent (where the /data is mounted to a persisted partition which is available from both A/B partitions). A symlink is hard to maintain as it also has to be based up in order to preserve it across firmware updates, and this is even more complicated to manage since the folder is mixed in with other important settings under the /etc/tedge/ folder (e.g. operation definitions, child device info, sm-plugins etc.)

Another solution to storing the whole /etc/tedge folder under /data/tedge, however this would present many problems for additional tooling which expects that the agent config is always stored under /etc/tedge. Technically this folder is configurable, but only via command line options (--config-dir <dir>), however there is no way to set this globally so that all thin-edge.io components use the same directory, and there is no clear way to communicate to other 3rd party components that the folder is located elsewhere (e.g. how does the user know where to put the operations and sm-plugins (as these are part of the public thin-edge.io interface)?)

Additional context

@reubenmiller reubenmiller added the idea ideas/opportunities/feature requests which need to be further investigated before implementation label Nov 30, 2023
@didier-wenzek didier-wenzek self-assigned this Nov 30, 2023
@didier-wenzek
Copy link
Contributor

What has been finally implemented (by #2492):

  • A new tedge-config setting has been added: agent.state.path
  • This path is used to store the tedge-agent state across restarts
    • currently two files are stored there restart-current-operation and software-current-operation
    • restart-current-operation is created when a device restart is requested
    • software-current-operation is created either when a software update or list is requested.
  • If for some reasons this directory cannot be used (doesn't exist or is not writable),
    then the tedge-agent use /etc/tedge/.agent as a fallback.
  • The default value for agent.state.path is /data/tedge/agent.

@reubenmiller reubenmiller added this to the 1.0.0 milestone Dec 5, 2023
@gligorisaev
Copy link
Contributor

QA has thoroughly checked the feature and here are the results:

  • Test for ticket exists in the test suite.
  • QA has tested the function and it's functioning according description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea ideas/opportunities/feature requests which need to be further investigated before implementation
Projects
None yet
Development

No branches or pull requests

3 participants