thin-edge / thin-edge.io

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

Migrate plugin configuration files on initialization of generic config and log plugins #2396

Closed reubenmiller closed 12 months ago

reubenmiller commented 12 months ago

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

Since the introduction of the new generic tedge-log-plugin and tedge-configuration-plugin, the location and name of the configuraitons used by the older c8y-* named plugins has changed. This results in previously configured plugins settings being functionaly lost (from the user's point of view) requiring the user to reconfigure the plugins.

Describe the solution you'd like

On initialization (in the Rust code), the following changes should be made to the initialization/migration of the plugins' configuration files:

tedge-log-plugin

IF FILE_EXISTS(/etc/tedge/c8y/c8y-log-plugin.toml) AND NOT FILE_EXISTS(/etc/tedge/plugins/tedge-log-plugin.toml) THEN
    MOVE /etc/tedge/c8y/c8y-log-plugin.toml /etc/tedge/plugins/tedge-log-plugin.toml
ELSE
    CREATE_DEFAULT_FILE(/etc/tedge/plugins/tedge-log-plugin.toml)
END

tedge-configuration-plugin

IF FILE_EXISTS(/etc/tedge/c8y/c8y-configuration-plugin.toml) AND NOT FILE_EXISTS(/etc/tedge/plugins/tedge-configuration-plugin.toml) THEN
    MOVE /etc/tedge/c8y/c8y-configuration-plugin.toml /etc/tedge/plugins/tedge-configuration-plugin.toml
ELSE
    CREATE_DEFAULT_FILE(/etc/tedge/plugins/tedge-configuration-plugin.toml)
END

Describe alternatives you've considered

The migration logic could be implemented in the post installation scripts in the linux packages, however then the upgrade logic would not be called if users have just installed the thin-edge.io components from the tarball (which is supported by the newer thin-edge.io/install.sh script).

Additional context

reubenmiller commented 12 months ago

The referenced PR merged changes as suggested in this issue.

reubenmiller commented 12 months ago

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