Persistence upgrader: Fix unmanaged config not respected - #5213
Conversation
Signed-off-by: Florian Hotze <dev@florianhotze.com>
| logger.debug("found {} managed persistence configurations: {}", managedConfigs.size(), | ||
| String.join(",", managedConfigs)); |
There was a problem hiding this comment.
This is minor but the log introduces confusion about what is managedConfigs, this is not the managed persistence configurations but rather the persistence services for which a managed persistence configuration is required because there is no unmanaged persistence configuration
There was a problem hiding this comment.
I've added a missing in brackets. This is debug logging, so users normally won't see that, and when running repeatedly, those are just managed configs, not missing managed configs.
Signed-off-by: Florian Hotze <dev@florianhotze.com>
|
Thanks for the fix - let me quickly test it locally before merging as well. Do you think we should/can address this issue as well, i.e. the fact that the newly created file is created with root permissions, which could potentially cause access issues for the runtime? |
Tests successful! 👍 |
The upgradetool currently created the file with the executor of the tool as owner. It however seems that when it's run by apt, it is run by root and hence the permissions. |
|
I think the update script in distro is the better place, as permissions are very platform specific and I am not confident I will get it right for Windows (I have no Windows system to test): openhab/openhab-distro#1847 I just triggered a new distro build, will test my changes with it and then mark my distro PR ready. |
That should be fine. Windows wouldn't support the POSIX attributes, and therefore it wouldn't be applied to Windows. It's possible to work out a solution as well for windows (updating the ACL's) but I also thought it is not needed. I agree, changing the user is in general the better way. The only challenge with that is that it will not work if the UpgradeTool is run manually and not from the script, as described here: https://www.openhab.org/docs/installation/?#upgrading |
|
Probably the easiest way to „fix“ this would be to update the docs and recommend running openhab-cli reset-ownership afterwards. |
Yes, that would indeed be a good solution. |
|
Do you want to create a docs PR? |
|
Just forgot one thing: openhab-cli isn’t available on Windows, it comes with the linuxpkg and the Homebrew package. |
I just created a PR. I have also completed the documentation on the upgrade tool while touching it. |
|
@mherwege I would tend to prefer openhab/openhab-distro#1847 over #5215, wdyt? |
Yes, I agree. I just wanted to help cleaning up the mess the hurried fixes left. |
|
What will happen to users that upgraded to 5.1 RC1 and who have now an unexpected JSON file ? |
If all services are unmanaged, the easiest fix (and I believe already stated on the forum), will be to stop OH, remove the newly created json file, and starting OH again. You could also remove the persistence definitions from the UI. If there is a mix of managed and unmanaged, one would have to remove the parts for the unmanaged persistence services from the json file (instead of completely removing). Services without any configuration before should be considered as managed. |
|
just for your information. |
|
Still reported as not working in RC2 by one user! |
Most likely the cleanup was not done. RC2 wouldn’t automatically correct the wrong configuration from RC1. |
|
I can confirm, that permissions are correct for persistence configuration during update from RC1 to RC2. Also filebased configuration for persistence services is used: Permissions before upgrade: After upgrade: |
|
FYI: When testing RC2, I had to force the execution of the upgrade tool. The persistence updater had been executed before, so it was skipped. Rpi /deb package. |
|
I’ve already throught about whether we could do some automatic clean-up in the upgrade tool for the RC1 issue. WDYT? I always consider such things a bit risky, but normally there shouldn’t be both managed and unmanaged config. If a user however creates a unmanaged config for any reason this will remove his managed config. |
I am not sure you had to. Was anything broken with your persistence configuration? Did running he upgrade tool change anything? If not, it was not required. If so, you needed to do manual fixes anyway. |
I am not sure it is worth it. You would have to force run the upgrade tool to pick it up anyway. In that case you can just as well do the changes manually as already documented. What could make more sense is to flag it in the health check. That would then also flag a user mistake of having 2 conflicting configurations, independent of the upgrade tool. But that could be an enhancement after release. |
That would indeed be a nice feature 👍 |
First draft PR created to extend the REST endpoint: #5217 |
Unmanaged configs were not respected because they were not recognized due to an invalid file extension check.
Looks good to me now: