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

Use absolute path instead requestURI in openapiv3 discovery #117495

Merged
merged 1 commit into from
Apr 29, 2023

Conversation

ardaguclu
Copy link
Member

@ardaguclu ardaguclu commented Apr 20, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

Currently, openapiv3 discovery uses requestURI to discover resources. However, that does not work when the rest endpoint contains prefixes (e.g. http://localhost/test-endpoint/).
Because requestURI overwrites prefixes also in rest endpoint (e.g. http://localhost/openapiv3/apis/apps/v1).

Since absPath keeps the prefixes in the rest endpoint, this PR changes to absPath instead requestURI(e.g. http://localhost/test-endpoint/openapiv3/apis/apps/v1).

Which issue(s) this PR fixes:

Fixes #117463

Does this PR introduce a user-facing change?

Fixes a 1.26 regression in kubectl and client-go discovery when configured with a server URL other than the root of a server.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 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 Apr 20, 2023
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 20, 2023
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 20, 2023
@ardaguclu
Copy link
Member Author

/cc @alexzielenski @apelisse
What do you think about this change?

@ardaguclu
Copy link
Member Author

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 20, 2023
@ardaguclu
Copy link
Member Author

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 20, 2023
@apelisse
Copy link
Member

Can we actually test this?

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

I think the code is fine as it is, but I'd really like to see a test added.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 25, 2023
@ardaguclu
Copy link
Member Author

I think the code is fine as it is, but I'd really like to see a test added.

Thanks for review @apelisse. I added unit tests to assure that patch fixes the issue.

@apelisse
Copy link
Member

OK I think that's fine, thank you. We should ask someone else's opinion since my knowledge in that area is more limited.

Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

/approve

a few nits on the test case names and one duplicate test we don't need, lgtm otherwise

@liggitt liggitt added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 27, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, 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 Apr 27, 2023
@liggitt
Copy link
Member

liggitt commented Apr 27, 2023

since we'll be cherry-picking this, I'd probably recommend squashing to a single commit here rather than having tide squash for you

Currently, openapiv3 discovery uses requestURI to discover resources.
However, that does not work when the rest endpoint contains prefixes
(e.g. `http://localhost/test-endpoint/`).
Because requestURI overwrites prefixes also in rest endpoint
(e.g. `http://localhost/openapiv3/apis/apps/v1`).

Since `absPath` keeps the prefixes in the rest endpoint,
this PR changes to absPath instead requestURI.
@liggitt
Copy link
Member

liggitt commented Apr 29, 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 Apr 29, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: fad7d1e664821ee5762e1d6d23dd86008fbc79d8

@liggitt
Copy link
Member

liggitt commented Apr 29, 2023

Once this merges, can you open a cherry-pick to release-1.27 (and maybe 1.26 if applicable)

@k8s-ci-robot k8s-ci-robot merged commit d94c733 into kubernetes:master Apr 29, 2023
12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone Apr 29, 2023
@ardaguclu ardaguclu deleted the openapiv3-absolute-path branch April 29, 2023 16:04
@liggitt liggitt added the kind/regression Categorizes issue or PR as related to a regression from a prior release. label Apr 29, 2023
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 29, 2023
k8s-ci-robot added a commit that referenced this pull request Apr 29, 2023
…17495-upstream-release-1.27

Automated cherry pick of #117495: Use absolute path instead requestURI in openapiv3 discovery
k8s-ci-robot added a commit that referenced this pull request Apr 29, 2023
…17495-upstream-release-1.26

Automated cherry pick of #117495: Use absolute path instead requestURI in openapiv3 discovery
rayowang pushed a commit to rayowang/kubernetes that referenced this pull request Feb 9, 2024
…es#117495)

Currently, openapiv3 discovery uses requestURI to discover resources.
However, that does not work when the rest endpoint contains prefixes
(e.g. `http://localhost/test-endpoint/`).
Because requestURI overwrites prefixes also in rest endpoint
(e.g. `http://localhost/openapiv3/apis/apps/v1`).

Since `absPath` keeps the prefixes in the rest endpoint,
this PR changes to absPath instead requestURI.
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. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI spec fetching ignores apiserver URL path
4 participants