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

api: add RouteReasonNotAllowedByListeners #1155

Merged

Conversation

rainest
Copy link
Contributor

@rainest rainest commented May 9, 2022

What type of PR is this?
/kind feature

Optionally add one or more of the following kinds if applicable:
/kind api-change

What this PR does / why we need it:
Adds two RouteConditionReason constants for RouteConditionAccepted==false:

  • NotAllowedByListeners indicates that none of the Gateway's Listeners have an allowedRoutes that permits the route.
  • NoMatchingListenerHostname indicates that none of the Gateway's compatible Listeners have a Hostname that matches one of the route's hostnames (and implicitly that there is no compatible Listener without a Hostname, which would match any route).

Which issue(s) this PR fixes:
Related to #1077

Does this PR introduce a user-facing change?:

adds RouteReasonNotAllowedByListeners and RouteReasonNoMatchingListenerHostname RouteConditionReason constants

Add a RouteConditionReason constant, "NotAllowedByListeners", for use
when a route fails to match any of the allowedRoutes conditions on a
Gateway's Listeners.
Add a RouteConditionReason constant, "NoMatchingListenerHostname", for
when a Gateway has no compatible Listeners with a Hostname that matches
one of the route hostnames.
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 9, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @rainest. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @rainest!

/ok-to-test
/approve

apis/v1alpha2/shared_types.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 9, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rainest, robscott

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 May 9, 2022
@rainest
Copy link
Contributor Author

rainest commented May 9, 2022

I had a brief discussion with @mikemorris re separating NotAllowedByListeners into separate constants for AllowedRoutes Kind and Namespace sections to be more specific and allow more targeted conformance tests, but I don't think we can do this since we're checking a route against all available Listeners, and can encounter scenarios like:

namespaceFoo/TCPRoute

ListenerA.allowedRoutes: (namespace selector for some label present on namespaceFoo), (kind UDPRoute)
ListenerB.allowedRoutes: (namespace selector that _does not_ match namespaceFoo), (kind TCPRoute)

where the answer to "was the route denied because of AllowedRoutes.Kinds or because of AllowedRoutes.Namespaces?" is "Both?".

Therefore, conformance tests should probably test that each of "only rejected because of Kind criteria", "only rejected because of (each type of) Namespace criteria", and mixed cases like the above result in the same NotAllowedByListeners.

Intuitively, I'd expect that Hostname checks, and receiving status NoMatchingListenerHostname, are performed after AllowedRoutes checks, and that routes should not expect to see NoMatchingListenerHostname if they also qualify for NotAllowedByListeners. However, I don't think this actually matters in practice, so conformance tests should not test behavior when a route is neither allowed by AllowedRoutes nor matches any Hostnames. Conformance tests for NotAllowedByListeners should probably omit Hostnames and tests for NoMatchingListenerHostname should probably omit AllowedRoutes (or rather, provide Listeners with compatible protocols and the implied AllowedRoutes.Kinds) from test Listeners as such.

@rainest rainest requested a review from robscott May 9, 2022 23:41
@youngnick
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 19, 2022
@k8s-ci-robot k8s-ci-robot merged commit 7417485 into kubernetes-sigs:master May 19, 2022
@rainest rainest deleted the api/allowed-routes-reason branch June 6, 2022 21:14
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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

4 participants