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
Use OpenAPI V3 for client side SMP #120707
Conversation
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/meta.go
Outdated
Show resolved
Hide resolved
|
||
// TODO: GVK parser should be moved elsewhere | ||
// Is this duplicated somewhere? | ||
func gvkMatches(targetGVK schema.GroupVersionKind, ext spec.Extensions) bool { |
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.
There's a strong possibility that Alex has already written a piece of code to do that, I also suspect maybe sean has written a layer that goes on top of the OpenAPI client to find the object directly.
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 saw Sean's snippet in query params verifier v3. It's really concise and I'm going to opt to duplicate it because patch requires checking for two different kinds of gvks. Schemas can have a list of gvks while the patch endpoint can only have a single gvk.
if gvkSupported, _ := p.gvkSupportsPatchOpenAPIV3(p.Mapping.GroupVersionKind); gvkSupported { | ||
patch, err = p.buildStrategicMergePatchFromOpenAPIV3(original, modified, current) |
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.
it seems like these two things are running together yet they have a lot of common code? Can we actually return the PatchMeta
if we find one?
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 like keeping the two separate because they look at different components of the OpenAPI. gvkSupportsPatchOpenAPIV3
looks at the PATCH verb for a resource path (does not look at schema at all) while buildStrategicMergePatchFromOpenAPIV3
looks at Component definitions and traverses the schema resource.
if ext == nil { | ||
return false | ||
} | ||
f, ok := ext["x-kubernetes-group-version-kind"] |
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.
Is there a constant somewhere for this string (x-kubernetes-group-version-kind
)?
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.
There is in util/openapi
in kubectl but that's coupled with OpenAPI V2 and I was hoping we can keep OpenAPI V2 and V3 coupling to a minimum. I declared a constant in this file instead.
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 think this approach looks good. I would hope for more kubectl
tests.
@seans3 I added kubectl testing by extending the existing apply tests and showing that OpenAPI V3 produces the same result. Let me know if there are other cases you'd like to see. |
/triage accepted |
How would we disable the feature if this doesn't work though? Like if openapi v3 generates the wrong patch, is there a way to revert back to v2? |
fa5150b
to
1b78deb
Compare
Only minor nits, feel free to push back. |
5b5d595
to
fbbf215
Compare
363e417
to
3b44bdd
Compare
3b44bdd
to
eb32969
Compare
I'll send a follow up PR to for linter hints since it involves changing invocations of existing tests. It's a non blocking CI. |
@Jefftree: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/lgtm |
LGTM label has been added. Git tree hash: 045d3242f41da2d99c5b92e9bf31da352b9bb1d9
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, Jefftree 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Use OpenAPI V3 for client side apply
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: