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

🐛 MatchingLabels: Make sure requests with invalid labels fail #882

Merged
merged 1 commit into from
Apr 2, 2020

Conversation

alvaroaleman
Copy link
Member

Fixes #740

Following up on an idea by @lavalamp this PR makes MatchingLabels construct an invalid selector rather than a (valid) match all selector in case of invalid input, which means the server will reject the request.

/assign @alexeldeib @vincepri

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 2, 2020
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 2, 2020
@alexeldeib
Copy link
Contributor

Nice fix. Do you think it's worth adding an invalid call against a real server in client_test.go to catch regressions? I realize your unit test essentially is the server side behavior, so it's really a nit, but can't hurt? I'll defer to you.

/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 2, 2020
@alvaroaleman
Copy link
Member Author

Nice fix. Do you think it's worth adding an invalid call against a real server in client_test.go to catch regressions? I realize your unit test essentially is the server side behavior, so it's really a nit, but can't hurt? I'll defer to you.

I think its fine, the important part is that we verify that even on invalid input a selector is populated rather than getting an empty selector back. Even if this had an integration test, an actual apiserver could behave differently than the one used in the integration test.

@vincepri
Copy link
Member

vincepri commented Apr 2, 2020

code LGTM, should this be a breaking change though?

@alvaroaleman
Copy link
Member Author

code LGTM, should this be a breaking change though?

No, the previous behavior of "Return empty label selector that matches everything on invalid selector" is a bug and very unexpected.

@vincepri
Copy link
Member

vincepri commented Apr 2, 2020

fair, we'll add some more details in the release notes for users

@vincepri
Copy link
Member

vincepri commented Apr 2, 2020

/approve

@vincepri vincepri added this to the v0.5.x milestone Apr 2, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, vincepri

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 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit df180ac into kubernetes-sigs:master Apr 2, 2020
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Listing objects with a label selector that exceeds 63 characters returns non-matching objects and no error
4 participants