-
Notifications
You must be signed in to change notification settings - Fork 108
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
SetClaimReference must pass to underlying object just claimRef allowed fields #552
Conversation
@pedjak Do you think it would be possible to switch to using a type without the extraneous fields? That seems ideal to me, since it would also update our claim OpenAPI schemas to better communicate that we don't actually pay any attention to all the extraneous fields (e.g. UID). In some places we've started defining our own types instead of ObjectReference, per #49. |
Namespace: ref.Namespace, | ||
Name: ref.Name, | ||
} | ||
_ = fieldpath.Pave(c.Object).SetValue("spec.claimRef", claimRef) |
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.
lgtm.
Just curious, why do we use a type if it is not supported?
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 also wonder if this method needs to live in crossplane-runtime at all, because it is only consumed in crossplane?
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.
That's a different question. What @negz and I mean is that corev1.ObjectReference
is the wrong type. We should have a ClaimReference
type instead that only has the fields that are allowed to be set.
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.
can you change this, i.e. introduce that type?
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 can, if we are ok with having breaking API change? @negz ?
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.
Does anything actually write (or read) the UID field in a claimRef today? If no, I feel fine making the change since while technically breaking at the API level it would functionally be a no-op.
Not sure if I got it right: would you like to change the signature of IMHO, it is quite alright to pass |
55a6e58
to
0b31516
Compare
Blast radius is minimal:
|
0b31516
to
b2bda45
Compare
…Reference `spec.claimRef` schema is just subset of corev1.ObjectReference, and hence `SetClaimReference` might get a reference that have more fields set, e.g. UID. The fields that do not exist in claimRef schema must be not set on the underlying object, otherwise K8s API server complains about non-existing field when client sends a patch request. * Introduced `claim.Reference` type that corresponds to `spec.claimRef` schema. * `composite.SetClaimReference` signature changed to accept an instance of `claim.Reference` * appropriate tests updated/new tests added Signed-off-by: Predrag Knezevic <[email protected]>
b2bda45
to
81b21d4
Compare
Description of your changes
spec.claimRef
schema is just subset ofcorev1.ObjectReference
, and henceSetClaimReference
might get a reference that have more fields set, e.g. UID. The fields that do not exist in claimRef schema must be not set on the underlying object, otherwise K8s API server complains about non-existing field when client sends a patch request.claim.Reference
type that corresponds tospec.claimRef
schema.composite.SetClaimReference
signature changed to accept an instance ofclaim.Reference
Discovered while working on crossplane/crossplane#4047
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Adjusted unit test to catch regression.