⚠️ Add subresource apply support#3321
Conversation
This reverts commit 6e1e8b2.
| } | ||
|
|
||
| func (sw *fakeSubResourceClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.SubResourceApplyOption) error { | ||
| if sw.subResource != "status" { |
There was a problem hiding this comment.
This is different from Patch, including when using apply through patch which will just patch the main object rather than a subresource when used with subresources other than status.
IMHO it is better to error out rather than to silenly do the wrong thing. We could fo a follow-up to do the same in Patch for consistency (and/or implement the subresources we support through Update there as well)
There was a problem hiding this comment.
I think tracking a follow-up would be good
There was a problem hiding this comment.
Added a point to the tracking issue
| } | ||
|
|
||
| // ApplyOpts applies the given options. | ||
| func (ao *SubResourceApplyOptions) ApplyOpts(opts []SubResourceApplyOption) *SubResourceApplyOptions { |
There was a problem hiding this comment.
This differs from our typical naming convention of naming these ApplyOptions because that name is already used for the embedded field. I chose to embedd the field, because there is prior art of doing that in the SubResourcePatchOptions and it seems ergonomical to do it that way, because modifying options doesn't requier to know whether they are defined in ApplyOptions or SubResourceApplyOptions.
| } | ||
|
|
||
| func (sw *fakeSubResourceClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.SubResourceApplyOption) error { | ||
| if sw.subResource != "status" { |
There was a problem hiding this comment.
I think tracking a follow-up would be good
7b761bb to
ca3c62d
Compare
|
Thank you very much!! /lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
LGTM label has been added. DetailsGit tree hash: 03c2f8f3a242f767d8199893f46d8087361a97a0 |
Replace Create+AlreadyExists pattern with SSA for ResourceQuota, PDB, and workload deployment in debug_session_reconciler.go. Add ApplyTypedObject helper that converts typed k8s objects to unstructured for SSA. This is cleaner than Create+AlreadyExists and provides proper create-or-update semantics. Note: API Creates (BreakglassSession, DebugSession) are kept as-is: - AddBreakglassSession uses GenerateName (SSA needs known name) - CreateDebugSession needs AlreadyExists detection for 409 response Refs: kubernetes-sigs/controller-runtime#2981 Refs: kubernetes-sigs/controller-runtime#3321 Refs: kubernetes-sigs/controller-runtime#3253
Replace Create+AlreadyExists pattern with SSA for ResourceQuota, PDB, and workload deployment in debug_session_reconciler.go. Add ApplyTypedObject helper that converts typed k8s objects to unstructured for SSA. This is cleaner than Create+AlreadyExists and provides proper create-or-update semantics. Note: API Creates (BreakglassSession, DebugSession) are kept as-is: - AddBreakglassSession uses GenerateName (SSA needs known name) - CreateDebugSession needs AlreadyExists detection for 409 response Refs: kubernetes-sigs/controller-runtime#2981 Refs: kubernetes-sigs/controller-runtime#3321 Refs: kubernetes-sigs/controller-runtime#3253
This change adds subresource apply support to the client. It is breaking, as that entails extending the interface.
The fake client currently only supports the
statussubresource for apply and will error out if it is used for any other subresource.Ref #3183
/hold