feat: take tedge.toml backup on tedge config upgrade#4138
feat: take tedge.toml backup on tedge config upgrade#4138albinsuresh wants to merge 3 commits intothin-edge:mainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
Robot Results
Failed Tests
|
| eprintln!( | ||
| "Your original configuration has been backed up to: {} in case the old configuration must be restored.", | ||
| backup_path | ||
| ); | ||
| eprintln!( | ||
| "You may delete it after validating that your upgraded configuration is working." | ||
| ); |
There was a problem hiding this comment.
I'm wondering how loud we have to be about this backup file.
If we're opening communicating about the file, whilst it is good to make users aware of it, I'm wondering if just will prompt more questions from users. And the downgrade scenario.
For instance, to restore the file, we'd assume just need the tedge.toml from the tedge.toml.bak file, but; what services would need to be restarted, does the new version of the mapper really look at the values within the tedge.toml if there are c8y values present, and the mapper.toml file exists? How does the user know which file is controlling the mapper tedge.toml vs. mapper.toml?
@jarhodes314 any thoughts on this?
There was a problem hiding this comment.
It does feel a bit weird to suddenly require a filesystem interaction from the CLI we built largely to prevent the user hand editing files.
I'm also wondering:
- Do we always create this file, even if there is no change made to
tedge.toml(either through a lack of cloud configs or calling it after already upgrading tomapper.toml)? - Do we want to enable downgrading? If that's the motivating use case, we probably want to write tedge.toml.bak like we write to tedge.toml, just before we strip it of cloud configs. That way, we don't make this feature essentially pointless is a user runs
tedge config upgrademultiple times.
As for what config is read for a cloud, that should be specified in the tedge connect config summary. The logic is that if there are any cloud configs in tedge.toml, then use that (since we only update tedge.toml when the mapper.toml files have been written).
There was a problem hiding this comment.
If we're opening communicating about the file, whilst it is good to make users aware of it, I'm wondering if just will prompt more questions from users. And the downgrade scenario.
How about keeping these messages here in the config upgrade but remove the warnings about the backup file from config get/set to reduce the noise?
Do we always create this file, even if there is no change made to tedge.toml (either through a lack of cloud configs or calling it after already upgrading to mapper.toml)?
Currently, yes. That rationale was to enable config upgrade invocations from future tedge versions as well so that we always have the backup of the previous version. But yeah, that introduced the unexpected side effect of the already backed up "original v1 config" getting replaced by an "already migrated v2 config", if config upgrade is invoked multiple times with the same tedge version.
Do we want to enable downgrading? If that's the motivating use case, we probably want to write tedge.toml.bak like we write to tedge.toml, just before we strip it of cloud configs.
The backup_tedge_config logic is called right before migrate_mapper_config. We just need to avoid replacing an existing tedge.toml.bak, if that upgrade invocation did not result in any changes to the tedge.toml.
f2e68d6 to
a662c8f
Compare
Proposed changes
Take
tedge.tomlbackup duringtedge config upgradeand notify the user about the existence of any stale backup intedge config get/set.Types of changes
Paste Link to the issue
#4125
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments