-
Notifications
You must be signed in to change notification settings - Fork 253
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
List of structs containing references are patched without references #1291
List of structs containing references are patched without references #1291
Comments
/lifecycle frozen |
@RedbackThomson @brycahta @vijtrip2 seems to me that the root of the problem is that the runtime reconciler is modifying the |
Description of changes: Refactors the `resolveReferenceFor<Field>` Go template code into direct Go code. This way we can be more intelligent about nested field references and support unit testing its output. Breaking change: The previous Go template produced valid, but ultimately faulty, code for references within lists of structs. These are not supported (see aws-controllers-k8s/community#1291). As such, this update produces a panic when it detects those types of references. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Continuation of #401 Refactors the resolveReferenceFor<Field> Go template code into direct Go code. This way we can be more intelligent about nested field references and support unit testing its output. Breaking change: The previous Go template produced valid, but ultimately faulty, code for references within lists of structs. These are not supported (see aws-controllers-k8s/community#1291). As such, this update produces a panic when it detects those types of references. Co-authored-by: Amine <hilalyamine@gmail.com>
Describe the bug
After the controllers resolve resource references contained within a list of structs (such as EC2's
RouteTable.Routes
), they incorrectly patch thespec
, adding the concrete field. I have narrowed this down to thepatchResourceMetadataAndSpec
method. When you passr.kc.Patch
a resource with a list of structs containing resolved references, it will overwrite all of the elements within any slices in the target resource. This is a behaviour from controller-runtime's patching mechanism - https://github.com/kubernetes-sigs/controller-runtime/blob/2f77235e25b1e42d9e4957199f3cd0f2c3fb0d72/pkg/client/patch.go#L143-L149. UsingStrategicMergePatch
would be the solution, as that can update structs within lists, however this is not supported for custom resources.Steps to reproduce
RouteTable.Routes
, adding the following reference:RouteTable
and seeSpec.Routes[0].GatewayRef
does not exist anymore, butSpec.Routes[0].GatewayID
has the concrete valueExpected outcome
I would expect that the reference would remain within the spec, so that changes to the gateway are reflected within the route table - as expected in a GitOps compliant system.
The text was updated successfully, but these errors were encountered: