Comments (3)
I'm not super familiar with the code base, please let me know if this analysis is not correct.
I think this raises a few questions:
- Do we actually want the current behavior?
a. If so, will we change the interface to make it clear merge options are not patch-scoped, but composed-resource-scoped?
b. If not, many compositions out there might already depend on this behavior to work correctly, how to tackle this? - How can we improve the merge options documentation to illustrate its nuances?
- How does this affect, if at all, server-side applies?
I'm willing to contribute with whatever is necessary, but at this point I think we need to further discuss what direction we should move to solve this.
from crossplane.
Great details to explain this behavior, how it can be reproduced, and some analysis of the code base - really impressive effort here @LCaparelli, that accelerates folks understanding of the issue!
I don't have the full deep context of the codebase, but I didn't catch anything obviously wrong with your analysis yet. One thing to note is that the behavior to consider the mergeOptions
for all patches on the composed resource goes back at least 3 years, if not longer:
https://github.com/crossplane/crossplane/blame/master/internal/controller/apiextensions/composite/merge.go#L75
So this behavior has indeed been present for awhile - I'm anticipating there's a good reason for it, perhaps to avoid conflicting behavior across patches, but I don't have the depth of context to really know why.
That being said, a couple questions for you:
- Have you happened to try this scenario with function-patch-and-transform yet? The
mergeOptions
in classic patch & transform have been replaced with apolicy.toFieldPath
approach. I don't fully expect the behavior to differ here, but it may be useful to try. - Have you considered a design change to your XRD/claim schema? Instead of separate
spec.image
andspec.additionalContainers
fields, would it be possible to just makespec.image
an array that can support multiple entries? e.g.:
image:
- name: argoproj/rollouts-demo
tag: blue
# claim user can optionally add additional entries to this array
- name: container2
tag: some-image:v0.0.1
from crossplane.
Thanks for taking the time to have a look at this @jbw976!
Have you considered a design change to your XRD/claim schema? Instead of separate spec.image and spec.additionalContainers fields, would it be possible to just make spec.image an array that can support multiple entries? e.g.:
We ended up setting a static limit to the number of additional containers (usually 5 sidecars is already quite a lot), so that we can have patches for specific indexes while still keeping the abstraction level we wanted for the main container (sidecars can be something we don't maintain ourselves, so we want that to be flexible and allow users to set whatever container fields they want).
# the static patches solve temporary issues regarding containers duplication
- type: FromCompositeFieldPath
fromFieldPath: spec.additionalContainers[0]
toFieldPath: spec.forProvider.manifest.spec.template.spec.containers[1]
- type: FromCompositeFieldPath
fromFieldPath: spec.additionalContainers[1]
toFieldPath: spec.forProvider.manifest.spec.template.spec.containers[2]
- type: FromCompositeFieldPath
fromFieldPath: spec.additionalContainers[2]
toFieldPath: spec.forProvider.manifest.spec.template.spec.containers[3]
- type: FromCompositeFieldPath
fromFieldPath: spec.additionalContainers[3]
toFieldPath: spec.forProvider.manifest.spec.template.spec.containers[4]
- type: FromCompositeFieldPath
fromFieldPath: spec.additionalContainers[4]
toFieldPath: spec.forProvider.manifest.spec.template.spec.containers[5]
Will probably solve this more elegantly with function-go-templating
(or similar) so we can iterate indefinetely.
Have you happened to try this scenario with function-patch-and-transform yet? The mergeOptions in classic patch & transform have been replaced with a policy.toFieldPath approach. I don't fully expect the behavior to differ here, but it may be useful to try.
I'll give that a swing (hopefully) soon, still hadn't had time to do it. 😅
Replying right now just to share the workaround we found.
from crossplane.
Related Issues (20)
- Proposal: New `Healthy` condition for claims and XRs HOT 4
- Condition message when a package has invalid dependencies is confusing
- Consistent contributor experience across repos HOT 1
- Refactoring compositions without deleting/recreating composed resources
- Promote claim server-side apply to beta HOT 2
- Report the use of components with vulnerabilities in crossplane HOT 1
- Selecting Array Elements with the Custom Columns Kubernetes CLI Output HOT 3
- Races in the `PackagedFunctionRunner`
- DynamoDB Table Resource Based Policy Support HOT 2
- Increase e2e test reliability HOT 3
- e2e tests should fail fast
- Update to go1.22.3 due to CVE HOT 5
- Improve the trace command for performance HOT 5
- [Feature Request] Crossplane CLI should support a standardized testing model for compositions
- Claim CRDs are Reconciled by the XR CRD Reconciler
- `crossplane xpkg init` doesn't close file
- `TestNewFromFlags` test will fail when `UP_ACCOUNT` is set HOT 2
- Externally Managed CRD Fields HOT 4
- `crossplane beta validate` should support `Configuration.meta` / `crossplane.yaml` for pulling dependencies
- `make generate` can not be run more than once
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crossplane.