-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Warn if uploading configuration will overwrite someone elses changes #113
Comments
How would this work? Since presumably every time you update a config you're making changes (otherwise why are you updating it!). Are you thinking we'd establish some kind of "authentic" changes line based on what is in git? I'm struggling to imagine how to solve this cleanly. One way I thought of would be to store the last pushed So the flow would be:
Is that your line of thinking @garethbowen? |
Yeah that's exactly what I was thinking, I just don't like to put any implementation details in issues until they are ready to be worked on. You would also need to store revs of forms and resources and so on. I think it would work for number 3 because it would protect you from overwriting and prompt you to export it locally before making your changes and uploading again. You'd lose who made the original changes and why but at least you wouldn't lose the changes! |
Related: medic/cht-core#1616 |
Ready for AT in |
@wtekeu I'm getting document update conflicts on app-settings when running the same command a second time. Starting with a fresh webapp.
|
Also, should we add a assume yes argument so the user doesn't have to press |
@newtewt I have updated the branch. Also, I am not sure I understand the second comment. It is either you press |
Thanks I'll review again. As to the second comment. I was thinking similar to how apt-get has an assume yes option. So anytime a user would be prompted to select yes/ no it would just automatically answer yes. Not really apart of this ticket but might be a nice to have. http://manpages.ubuntu.com/manpages/cosmic/man8/apt-get.8.html |
@garethbowen @SCdF There is an issue where the API updates app_settings after they've been uploaded. This means that if you were to run an upload from medic-conf 2 times in a row with no changes you'd be notified every time that you're going to overwrite changes because the rev has changed in couch. @wtekeu says this is because API doesn't delete existing fields it only overwrites existing and then saves. This seems to only occur if you're updating app_settings. Should we adjust API and how it saves or drop the app_settings check or something else? |
Unfortunately we can't change that API without bumping the API version because other scripts rely on it operating the way it does. We could introduce a new option to make it overwrite completely which would solve this issue but it wouldn't be backwards compatible so old APIs would still be affected. I wouldn't want to drop the rev check on the app_settings either because it's probably the most likely part to be updated outside of medic-conf (eg: through the admin UI). @wtekeu How about we adjust the API to return the new rev. Then after it's called we can update the locally stored rev with the latest version? |
@garethbowen It looks like the main issue is that the api listens to settings changes and then compare it the default settings ( Which is why the rev do never match whenever an attempt to re-upload the settings is executed. And since there is a diff, it displays the prompt. |
Ahh of course! That's a really old "feature" from back in the days when the In addition, as part of 3.7.0 @kennsippell is working on medic/cht-core#5914 which will replace this Feel free to delete the config merging code in API. There's a chance that the code is relying on some property being defined in settings but if that happens we should fix the code to be null safe rather than updating the settings to have a default property. |
I think merging |
You're right - new permissions are why we need this... Thanks! It still feels clunky to me to merge default every time the settings changes or api starts so I'd like to do something to fix it. Firstly, I think we should reduce the default to just what's needed. I think this is just permissions but it's worth reviewing the file. Secondly, should it be applied as it is now, or done as a migration when new permissions are added, or applied to permissions when accessed so the settings doc remains unchanged. I think I'm leaning towards doing it in a migration so it happens once and only once on upgrade, and adding a migration now to make sure everyone's caught up with the current default permissions. What do you think @dianabarsan ? |
In theory, I think it's enough, in practice .. debatable. |
Do you think we should keep the current merging behaviour, perhaps with just the permissions and nothing else? |
Just the permissions and only when necessary would be perfect! |
@garethbowen please note that this will not prevent the rev delta as the extra permissions will result in an update (which means new rev) |
@wtekeu Yes. I think the other thing that should change is the default permissions should be applied in the |
👍 |
@garethbowen I was reviewing it more carefully and it looks like it is impossible to know whether the change was the consequence of a direct update or that of an api request. Also, you say that |
@wtekeu the app settings portion of this is working. The bad news is that I believe that now that we are generating forms server side. Forms are being edited and the rev is different on the server vs local. So every time you upload app forms you're being informed that you are overwriting a change. This feature seems like a whack-a-mole effort and I'm betting we'll run into this in future versions. |
Sorry, I should've seen this coming... I think Nick may be right and using the Alternatively there may be other simpler solutions that I haven't thought of... |
I think this may also fix medic/cht-core#3050 |
This has been destabalised by other merges so we've decided to put it off to 3.8.0 to give us more time to come up with a good solution. |
This change allow TLs to upload app settings without always getting the prompt notifying of a change when it is only the result of rev change due to the API change listener updating the settings after overwriting the settings with default one. medic/cht-conf#113 #3050
@wtekeu How are you getting on with this? |
Ready for AT in |
This was already partially ATed by Nick so read through the history to see what changed. The big addition from what was previous version is now we correctly detect if you're overwriting enketo forms. Steps for testing the new part:
|
LTGM (warning displayed, changes in conf detected)
Two issues however -
|
|
Technical users use medic-conf to make configuration changes to instances and hopefully remember to commit the changes to git to track, back up, and share their work.
This can overwrite other configuration changes if...
In any of these cases the configuration will be overwritten.
Instead medic-conf should warn when the configuration is different from when it was last executed. The user should be given the option to overwrite the changes (
force
) or update their configuration to be in sync (eg:git stash
, export configuration,git stash pop
).The text was updated successfully, but these errors were encountered: