-
Notifications
You must be signed in to change notification settings - Fork 90
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
Use granular merge strategy for singleton lists #380
Use granular merge strategy for singleton lists #380
Conversation
…ment support for singleton lists. Move applying SSA merge default config to provider. Use correct Computed value for list merge keys Signed-off-by: Jonathan Oddy <[email protected]>
9380ba1
to
eac88d3
Compare
Hi @JonathanO,
My concerns with defaulting an SSA merge strategy of
So, my proposal would be:
What do you think @JonathanO? |
That would be the ideal solution, but I raised this PR as a possible stop-gap solution until such a time that converting to embedded objects is implemented. If converting to embedded objects is likely to be available in the very near future then I agree that this PR is not necessary. The atomic merge behaviour creates problems, and today the fix is to add ListTypeMap merge configuration to individual resources in providers. That's quite a frustrating user experience (because you discover the incorrect merge strategy only after running into problems), and will also need to be undone once the conversion to embedded objects is available. Covering your other concerns:
As you go on to mention, this is not a problem for the case where
It's an API change and would need a new CRD version (which will be the same as if the singleton list had been converted to an embedded object.) Fortunately this seems unlikely to happen often given how these blocks are used in the Terraform.
I agree, but at the moment we're raising PRs against providers to add these injected fields on a case-by-case basis - they're slowly ending up (inconsistently) in provider APIs already. |
In today's Upjet SIG meeting, we discussed not going ahead with this PR with @JonathanO. The team from Upbound will implement a solution where singleton lists (lists of only one (required or optional) object) are converted to embedded objects. We hope to roll out this solution in the next few weeks. |
Description of your changes
Many TF providers nest blocks using a ListType with MaxItems=1, which upjet converts into a list containing a map. The default server side apply merge strategy for lists is atomic, resulting in conflicts between the provider and composition functions. This can be fixed on a case-by-case basis in the providers (crossplane-contrib/provider-upjet-gcp#457), but it seems likely that all of these should be treated as if they were maps (which default to granular merge.)
While it would be great to fix this by flattening the unnecessary array, that would force an API change on all the providers.
This PR instead adjusts the ServerSideApplyMergeStrategies in the config to use ListTypeMap with a defaulted key for a singleton list. It works by altering the config, rather than during creation of Fields, to avoid duplicating the implementation used for ServerSideApplyMergeStrategies.
It also moves the existing server side apply marker defaulting for scalar sets and maps to work in the same way for consistency. I'm not sure that it's necessary to apply the granular strategy in the TypeMap case, as I think that's the k8s default, but I've left it in place to avoid additional changes to the output.
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Generated updated GCP provider, which was run in Kind.