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

Separate OpenAPI V2 and V3 config in V3 builder #431

Merged
merged 3 commits into from
Oct 9, 2023

Conversation

Jefftree
Copy link
Member

Decouple v2 and v3 configs to support #420 properly

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 27, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 /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 Sep 27, 2023
@Jefftree Jefftree changed the title Separate OpenAPI V3 config in V3 builder [WIP] Separate OpenAPI V3 config in V3 builder Sep 27, 2023
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 27, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 5, 2023
@Jefftree Jefftree changed the title [WIP] Separate OpenAPI V3 config in V3 builder Separate OpenAPI V3 config in V3 builder Oct 5, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 5, 2023
@Jefftree Jefftree changed the title Separate OpenAPI V3 config in V3 builder Separate OpenAPI V2 and V3 config in V3 builder Oct 5, 2023
@Jefftree
Copy link
Member Author

Jefftree commented Oct 5, 2023

/assign @apelisse
Would appreciate your thoughts on this, thanks!

@Jefftree
Copy link
Member Author

Jefftree commented Oct 5, 2023

k/k PR is a bit more involved: kubernetes/kubernetes#121010

@@ -315,12 +315,12 @@ func (o *openAPI) buildOpenAPISpec(webServices []common.RouteContainer) error {
// BuildOpenAPISpec builds OpenAPI v3 spec given a list of route containers and common.Config to customize it.
//
// Deprecated: BuildOpenAPISpecFromRoutes should be used instead.
func BuildOpenAPISpec(webServices []*restful.WebService, config *common.Config) (*spec3.OpenAPI, error) {
func BuildOpenAPISpec(webServices []*restful.WebService, config *common.OpenAPIV3Config) (*spec3.OpenAPI, error) {
Copy link
Member

Choose a reason for hiding this comment

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

how breaking is this? We have to wonder how much we break now when we make these changes. I'm assuming that only the apiserver is using that code though.

Copy link
Member Author

Choose a reason for hiding this comment

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

cc @ryantxu since this will affect your workflow.

My understanding is that only apiserver uses this code, and the v3 path is less used than v2. It's also technically "wrong" to use the v2 config for v3 and I don't want to encourage people going down/sticking to that path. Things like PostProcessSpec(*spec.Swagger) ... (https://github.com/kubernetes/kube-openapi/blob/master/pkg/common/common.go#L114-L115) that takes a v2 spec is ignored when building v3.

I'm happy to create a new function if we want though.

Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, the standard codegen tools do not produce code that calls this directly. The breaking change will be in kubernetes/kubernetes#121010 😬
image

But honestly it feels more like a bug fix since the v2 options do not cleanly apply to v3

o := openAPI{
config: common.ConvertConfigToV3(config),
Copy link
Member

Choose a reason for hiding this comment

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

Should we consider removing this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@apelisse
Copy link
Member

apelisse commented Oct 9, 2023

Yeah, I think the breaking change is fine here. LGTM, just one question.

@apelisse
Copy link
Member

apelisse commented Oct 9, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2023
@k8s-ci-robot k8s-ci-robot merged commit f62364c into kubernetes:master Oct 9, 2023
2 checks passed
jan--f added a commit to jan--f/cluster-monitoring-operator that referenced this pull request Dec 11, 2023
Added some klog fixes as well, as they seemed to be needed.
The replace k8s.io/kube-openapi => k8s.io/kube-openapi
v0.0.0-20230928195430-ce36a0c3bb67 statement is added to work around an
issue caused by kubernetes/kube-openapi#431

Signed-off-by: Jan Fajerski <[email protected]>
jan--f added a commit to jan--f/cluster-monitoring-operator that referenced this pull request Dec 12, 2023
Added some klog fixes as well, as they seemed to be needed.
The replace k8s.io/kube-openapi => k8s.io/kube-openapi
v0.0.0-20230928195430-ce36a0c3bb67 statement is added to work around an
issue caused by kubernetes/kube-openapi#431

Signed-off-by: Jan Fajerski <[email protected]>
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-monitoring-operator that referenced this pull request Dec 13, 2023
Added some klog fixes as well, as they seemed to be needed.
The replace k8s.io/kube-openapi => k8s.io/kube-openapi
v0.0.0-20230928195430-ce36a0c3bb67 statement is added to work around an
issue caused by kubernetes/kube-openapi#431

Signed-off-by: Jan Fajerski <[email protected]>
jan--f added a commit to jan--f/cluster-monitoring-operator that referenced this pull request Dec 13, 2023
Added some klog fixes as well, as they seemed to be needed.
The replace k8s.io/kube-openapi => k8s.io/kube-openapi
v0.0.0-20230928195430-ce36a0c3bb67 statement is added to work around an
issue caused by kubernetes/kube-openapi#431

Signed-off-by: Jan Fajerski <[email protected]>
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants