Skip to content
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

virtual: Support SSA patch requests for non-existent objects #1854

Merged
merged 8 commits into from
Sep 2, 2022

Conversation

astefanutti
Copy link
Member

Summary

This PR switches update operations made to the virtual workspace API server, to calling create operations on the forwarding API server, for non-existent objects. This enables support for server-side apply patch requests in that case.

Related issue(s)

Fixes #1852

@sttts
Copy link
Member

sttts commented Aug 31, 2022

/assign @davidfestal

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 31, 2022
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 31, 2022
@astefanutti
Copy link
Member Author

Added unit and e2e tests. Also added support for the forceAllowCreate argument to update operation.

@astefanutti
Copy link
Member Author

@sttts @davidfestal PTAL.

// for non-existent objects can still be processed.
if !apierrors.IsNotFound(err) ||
!forceAllowCreate &&
!(requestInfo != nil && requestInfo.Verb == "patch") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about patch requests which are not SSA requests ?
Will they try to create it as well ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For JSON or SMP patch requests, the corresponding patcher implementation returns a errors.NewNotFound error, so the response code is 404 as expected. The patchers execute as part of the objInfo.UpdatedObject(ctx, oldObj) call, and their implementations can be found at https://github.com/kubernetes/apiserver/blob/48405445f09218bb8b7a8a81eb21027cfd65761b/pkg/endpoints/handlers/patch.go, with the errors at:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.
Do you think you could add a comment in the code to explain this ? It's not easy to think of or guess when reading.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've added eb9e64d that hopefully covers it.

I've also pushed 6d1b968 to have the use case covered in e2e tests.

@sttts
Copy link
Member

sttts commented Sep 2, 2022

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 2, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 2, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2022
@openshift-merge-robot openshift-merge-robot merged commit 8b36fd7 into kcp-dev:main Sep 2, 2022
@astefanutti astefanutti deleted the pr-20 branch September 2, 2022 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Server-side apply requests to virtual workspace API server fail for non-existent objects
4 participants