-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ingredient and inline config should be merged, not updated #193
Comments
Original comment by Brent Tubbs (Bitbucket: btubbs, GitHub: btubbs): -1. Sometimes apps may rely on the presence/absence of a particular config key, and this merging could have harmful unforeseen consequences in that case. Imagine that your application has code like this in it somewhere:
|
Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco): I created vr.server pr 193 for consideration. |
Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco): @btubbs: So you're saying the ability to remove keys from a config in the swarm config, overriding ingredients that define those keys, is an important feature? In your example, it would be possible for the swarm config to contain
or
to disable production mode, which would be more explicit than simply omitting it. The code would to have been written like this for the key presence to be the only signal:
In that case, it would not be possible in a swarm config to override an ingredient to remove IMO, the power afforded by allowing for deep merging (using a well-defined, standard implementation) outweighs the disadvantages of not being able to clear keys, a feature which would indeed be lost in the implementation of this backward-incompatible change. |
Original comment by Brent Tubbs (Bitbucket: btubbs, GitHub: btubbs): I don't want the developer in my example to need to keep the subtleties of VR config merging in mind when writing that code. She should be able to treat it as a dumb dict. I dislike this feature for much the same reasons I disliked the priority-stacked config. I highly value having the system be easily understandable by new developers and ops people with lots of other things on their minds. I don't think the increased power is worth the increased complexity in reasoning about the config and the increased risk of deploying config that you didn't intend. |
Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco): Do you have a suggestion then for solving the issue described in the OP, where the design of the config is being influenced by VR, and the subtleties of VR config merging must be considered when writing that code? Not only is the developer forced to consider this in the design, but then she has to communicate to the user deploying the app how to chose names when providing this config in order to effectively disambiguate from current and future config elements. |
Original comment by Brent Tubbs (Bitbucket: btubbs, GitHub: btubbs): Ideally the application author isn't aware of config overrides/merging at all. They just get a dict. It sounds like you've stepped away from that in order to manage/compose config a certain way. I think that's fine. The workaround described in the OP seems like a lesser evil than the proposed fix. |
Originally reported by: Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco)
The VR config model is pretty generous when it comes to sharing config amongst applications or instances of an application through the ingredients model.
When it comes to nested config, however, VR implements a very simple model where config values are simply updated with others, so it's not possible for a swarm-level config to override a single item from a group of config, such as exemplified in this doc or for different ingredients to implement components of the same config.
This limitation creates an incentive for application developers to only ever solicit config values from top-level keys (which are merged across ingredients). For example, a recent application chose to look for config in
xrefs_*
keys where the value of the*
was an arbitrary disambiguator and the values of allxrefs_
prefixed configs were merged and processed identically.Ideally, VR should not be influencing the design of the application in this way.
If on the other hand, VR were to deep-merge ingredients, it would allow for less redundant overrides and more natural sharing of config across ingredients.
Following that above reference to its inspiration (lodash), I found pydash, which implements the same merge routine. It deep-merges dictionaries:
And merges lists:
I propose that VR should simply use this merge function when compiling config. In this proposal, I'm not suggesting to change the current expectation about priority of config (or the arbitrary ordering of config from selected ingredients).
@btubbs, @lbolla: Any concerns or objections?
The text was updated successfully, but these errors were encountered: