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

Bump kube-openapi with v3 marshal and requestBody required marking #120735

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

Jefftree
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

Includes

Updates the OpenAPI V3 to mark requestBody as required.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Certain requestBody params in the OpenAPI v3 are correctly marked as required

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 18, 2023
@Jefftree
Copy link
Member Author

/triage accepted

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Sep 18, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 18, 2023
@k8s-ci-robot k8s-ci-robot requested a review from a team September 18, 2023 17:06
@k8s-ci-robot k8s-ci-robot added area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kube-proxy area/kubectl sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 18, 2023
@bart0sh bart0sh added this to Triage in SIG Node PR Triage Sep 19, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Sep 19, 2023

/priority important-longterm

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 19, 2023
@bart0sh bart0sh moved this from Triage to Needs Approver in SIG Node PR Triage Sep 19, 2023
@Jefftree
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2023
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 27, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2023
@Jefftree
Copy link
Member Author

/assign @liggitt

@@ -26610,7 +26673,8 @@
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
}
}
}
},
"required": true
Copy link
Member

Choose a reason for hiding this comment

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

what is this used for? the schema for patch doesn't look right for apply (can be yaml, not required to be json) or application/json-patch+json (is a list, not an object)

Copy link
Member Author

Choose a reason for hiding this comment

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

communicating to the user that a requestbody is required for patch operations, this is something that we have in the openapi v2 schema. It's currently not used for anything other than for informational purposes.

As for the incorrect schema, cc @apelisse
Is the list here incorrect? https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/types/patch.go#L28
I see we only accept one format (json or yaml) for each of the patches, do we need to expand this list?

Copy link
Member

Choose a reason for hiding this comment

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

We don't take json for apply, so that's correct, but the schema type is wrong indeed, it should be the type of the object (same as returned type). I think that's already true about v2 though. I'll open an issue for that.

Copy link
Member Author

@Jefftree Jefftree Oct 11, 2023

Choose a reason for hiding this comment

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

After looking into the code a bit more, the idea of consuming a "Patch" object instead of the return object schema seems intentional.
Per https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L1200-L1201

// Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.

Due to limitations with go-restful, we're not able to specify different return types for different patch types. I'm testing out a PR to change the patch return type, though not sure if the OpenAPI is more accurate.

Copy link
Member

Choose a reason for hiding this comment

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

yeah... I don't think that's more accurate. merge and apply patches take a sparse schema, meaning they would not actually require fields marked required in the specific type schemas.

strategic-merge-patch takes other directive properties that aren't present in the specific type schemas

jsonpatch takes an array of json patch items, which don't resemble the specific type schema at all

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't disagree.

Copy link
Member Author

Choose a reason for hiding this comment

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

How do we want to proceed with this PR in the meantime? @liggitt's comments describe the ideal state, I can create an issue to track this but it'll take some time to land because a go-restful update is probably needed. For this PR, are we okay with adding the "required" field? It just serves for informational purposes for the user. The goal was to address kubernetes/kube-openapi#427 and be consistent with OpenAPI V2. I can revert this for now if it's not desirable to add the field without the fixes described above.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize openapi v2 was already publishing body parameters with required: true

if that's been the case for multiple releases already, bringing this to parity seems ok. I checked and v2 has indicated body param is required (including the patch one) since at least 1.25

@liggitt
Copy link
Member

liggitt commented Oct 9, 2023

lgtm overall, the existing schema types don't look correct for a couple patch types... I'm not sure what the implications of marking the requestBody as required would be if that's the case

@Jefftree
Copy link
Member Author

(latest push is purely a rebase)

@liggitt
Copy link
Member

liggitt commented Oct 12, 2023

/lgtm
/approve

based on #120735 (comment)

please open a follow up issue to fix the incorrect patch schemas

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 12, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 9210ed8400f1cd6e272346bddb80f82507f9f96d

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, Jefftree, liggitt

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit e93e8ea into kubernetes:master Oct 12, 2023
19 checks passed
SIG Node PR Triage automation moved this from Needs Approver to Done Oct 12, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 12, 2023
@Jefftree Jefftree deleted the request-body branch January 25, 2024 22:22
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. area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kube-proxy area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

8 participants