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

policy: limit TCPRoute to one per policy response #13272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zaharidichev
Copy link
Member

Based on the feedback received on some proxy work and the fact that there is no real way to select over TCPRoute objects at the moment, this PR limits the amount of TCPRoutes that are returned per response to 1.

Signed-off-by: Zahari Dichev [email protected]

@zaharidichev zaharidichev requested a review from a team as a code owner November 5, 2024 09:16
pub(crate) fn protocol(
default_backend: outbound::Backend,
routes: impl Iterator<Item = (GroupKindNamespaceName, TcpRoute)>,
parent_info: &ParentInfo,
original_dst: Option<SocketAddr>,
) -> outbound::proxy_protocol::Kind {
let mut routes = routes
.take(MAXIMUM_ALLOWED_TCP_ROUTES)
Copy link
Member

Choose a reason for hiding this comment

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

Are the routes sorted in any particular way at this point when we take the first one? Is there a deterministic way to know which TCP route will take affect and which ones will be ignored?

If there are multiple TCP routes attached, should we be setting a RouteConflict and/or Accepted=false status on them?

Copy link
Member

Choose a reason for hiding this comment

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

I'd have to consult more of the impl to tell you how/where this is happening, but the routes must be sorted according to preference (i.e. according to the route sorting rules dictated by the gateway API--naming, creation timestamp, etc). This change, as it is, simply encodes what the proxy would already do: use the first matching route. The proxy has no concept of conflicts or accepted=false, so all of that ordering must be handled in the policy controller.

Given that this function is building the actual protobuf types, I believe that must have already happened.

Copy link
Member

Choose a reason for hiding this comment

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

The sorting happens before this is called:

tcp_routes.sort_by(timestamp_then_name);
tcp::protocol(

Copy link
Member Author

Choose a reason for hiding this comment

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

@adleong @olix0r

As pointed out sorting happens before this is called. In general the GW api spec does not prescribe setting conflict statuses in these cases. These are prescribed when there are routes with higher specificity (ie GRPC > HTTP). In cases when there are more than one route we need to follow disambiguation rules. In cases like HTTPRoute that would be more specific hostname, header and method matches. In the case of TCP these things are not present so we revert to sorting on route age and naming. For reference:

Proxy or Load Balancer routing configuration generated from HTTPRoutes MUST prioritize matches based on the following criteria, continuing on ties. Across all rules specified on applicable Routes, precedence must be given to the match having:

  • “Exact” path match.
  • “Prefix” path match with largest number of characters.
  • Method match.
  • Largest number of header matches.
  • Largest number of query param matches.

Note: The precedence of RegularExpression path matches are implementation-specific.

If ties still exist across multiple Routes, matching precedence MUST be determined in order of the following criteria, continuing on ties:

  • The oldest Route based on creation timestamp.
  • The Route appearing first in alphabetical order by “{namespace}/{name}”.

If ties still exist within an HTTPRoute, matching precedence MUST be granted to the FIRST matching rule (in list order) with a match meeting the above criteria.

When no rules matching a request have been successfully attached to the parent a request is coming from, a HTTP 404 status code MUST be returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants