thin-edge / thin-edge.io

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

Handle unknown configuration gracefully #1623

Closed reubenmiller closed 1 year ago

reubenmiller commented 1 year ago

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

Soften strict parsing of tedge.toml and system.toml to handle unknown section or properties so that they do not prevent the service from starting. The unknown sections/properties could be printed out in warning log messages instead.

Since multiple services read the tedge.toml file; tedge-mapper, c8y-log-plugin and c8y-configuration-plugin. When a component is updated (and the configuration is automatically updated via tedge --init, then the other non-updated components will not start up as they will throw an exception (and not start) due to detecting an unknown configuration section.

Motivation

Scenario

The following scenario would leave to 2 services not starting.

  1. A new version of tedge and its components
  2. The user updates tedge via Cumulocity and forgets to update the other components like tedge_mapper, c8y_log_plugin and c8y_configuration_plugin)
  3. The user adds the new configuration option (introduced in the new tedge version)
  4. The user reboots the device (due to other activities)
  5. Now c8y-mapper-*, c8y-log-plugin and c8y-configuration-plugin services do not start because they complain about an unknown section in tedge.toml

Example error (from the tedge-mapper-c8y service

tedge-mapper-c8y.log
Error: TOML parse error
Caused by:
    unknown field `http`, expected one of `device`, `c8y`, `az`, `mqtt`, `software`, `tmp`, `logs`, `run` at line 21 column 1

Describe the solution you'd like

Describe alternatives you've considered

The dependency to the configuration file schema could be managed via the debian package dependency mechanisms. However this complicates the installation of different packages and would only be possible when using apt-get install rather than using dpkg -i.

And the dependency management system does not solve the robustness issue where users can break tedge by an accidental typo.

didier-wenzek commented 1 year ago

Another motivation is to let an external plugin use the same configuration file instead of coming with yet another configuration file.

6367f766 commented 1 year ago

Does this ticket require a system test? @didier-wenzek, @reubenmiller

reubenmiller commented 1 year ago

Does this ticket require a system test? @didier-wenzek, @reubenmiller

Yes please.

6367f766 commented 1 year ago

How to test:

Having an unknown key in the tedge.toml file should not prevent the startup of the services.

[another]
key = "value"
gligorisaev commented 1 year ago

Tested