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
Fix synchronization between claim and the counterpart composite #4896
Conversation
@@ -125,35 +126,37 @@ func ConfigureComposite(_ context.Context, cm resource.CompositeClaim, cp resour | |||
} | |||
|
|||
claimSpecFilter := xcrd.GetPropFields(wellKnownClaimFields) | |||
ucp.Object["spec"] = filter(spec, claimSpecFilter...) | |||
cpPatch.(*composite.Unstructured).Object["spec"] = filter(spec, claimSpecFilter...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ugly. Why not use that type for cpPatch
directly? A type cast is always suspicious, unguarded even more so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see why you do that. Still ugly, but I don't see a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither, but I see this sort of casting often in this part of the codebase. This gives me a signal that we have just one implementation of resource.Composite
or resource.CompositeClaim
interface and perhaps it would be better to use it directly where needed. Using casts mean that we have single data model, and hence there is no much benefit of hiding it behind some interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed type casting in this commit. Let me know what do you think. I like it.
if err := merge(ucm.Object["status"], ucp.Object["status"], | ||
udesiredCm, ok := cmPatch.(*claim.Unstructured) | ||
if !ok { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this mean? Similar to above: don't cast. Use the proper types directly.
e44abc9
to
44eb7ed
Compare
ab2cef4
to
53a3081
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried an upgrade test and noticed that the composite keep getting updates, see below:
updates.mp4
Reproduction steps:
- Install Crossplane v1.14.2
- Follow the steps here.
- Upgrade Crossplane to a local build from this branch.
- Run
kubectl get xnopresources.nop.example.org -w
Could you investigate that?
Well, actually this is true for just regular install as well without upgrading Crossplane:
Reproduction steps:
- Install Crossplane with a local build from this branch.
- Follow the steps here.
- Run
kubectl get xnopresources.nop.example.org -w
install.mp4
It become True/True only after around 5mins:
53a3081
to
71f75c4
Compare
@turkenh I have addressed your comments. PTAL. |
Removing of a claim annotation, label, field and/or array member is properly propagated to the counterpart composite by using [k8s server-side apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/) feature. The same approach is used by propagating composite changes back to the claim. Implementing the server-side apply requested the following changes on the claim reconciler: * Given that a submitted patch needs to contain all fields that a reconciler care about and wants to take the ownership, the existing configurators and binders cannot perform updates. Instead, they are only adding the requested changes to the patch, that gets applied in one shot. * The claim configurator requires access to actual claim and composite, but produces a claim patch, similar goes for the composite configurator. Hence, `Configurator` was not applicable anymore got removed. * Given that `WithClaimConfigurator` and `WithCompositeConfigurator` are used only for mocking in the unit tests, their visibility is reduced. * Field manager name follows the convention: `crossplane-claim-controller/<CLAIM_GROUP_KIND_LOWERCASE>` * Claim status subresource is still modified by sending UPDATE requests, because the controller should own it completely. That is expressed explicitly by setting the status field ownership. * Given that `Applicator` is not used anymore, `Reconciler.client` is redeclared to `client.Client` * unit tests reworked/updated to verify the new implementation Following the proposal stated in crossplane#4581, the following composite fields are propagated back to the claim: * `spec.compositionRef` * `spec.compositionSelector` * `spec.compositionUpdatePolicy` * `spec.compositionRevisionSelector` * `status` minus `status.conditions` Signed-off-by: Predrag Knezevic <predrag.knezevic@upbound.io>
44d4181
to
f0f7c14
Compare
Yes, fixed, but please double check. |
Signed-off-by: Predrag Knezevic <predrag.knezevic@upbound.io>
f0f7c14
to
b390a75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @pedjak, see how many (long running issues) fixed by this single PR 💪
Thanks for bearing with me during reviews 🙌
Description of your changes
Removing of a claim annotation, label, field and/or array member is properly propagated to the counterpart composite by using k8s server-side apply feature. The same approach is used by propagating composite changes back to the claim.
Implementing the server-side apply requested the following changes on the claim reconciler:
Configurator
was not applicable anymore got removed.WithClaimConfigurator
andWithCompositeConfigurator
are used only for mocking in the unit tests, their visibility is reduced.crossplane-claim-controller/<CLAIM_GROUP_KIND_LOWERCASE>
Applicator
is not used anymore,Reconciler.client
is redeclared toclient.Client
Following the proposal stated in #4581, the following composite fields are propagated back to the claim:
spec.compositionRef
spec.compositionSelector
spec.compositionUpdatePolicy
spec.compositionRevisionSelector
status
minusstatus.conditions
Fixes:
An e2e test added for verifying the above fixes and catching future regressions.
Part of #4047 epic.
Implements: #4581
I have:
make reviewable
to ensure this PR is ready for review.[ ] Linked a PR or a docs tracking issue to document this change.[ ] Addedbackport release-x.y
labels to auto-backport this PR.