Skip to content

Conversation

sunjayBhatia
Copy link
Member

@sunjayBhatia sunjayBhatia commented Jun 2, 2023

This is to support Gateway API conformance, release 0.7.1 dictates that HTTP method comes before length of header matches in the precendence order for choosing routes.

Since we currently implement method matching in the DAG by adding a :method header match, this solution finds any :method headers being matched on and first determines precedence of two routes being compared based on that. If method matches are equal (both present or not present), then we go ahead with comparing the remaining header matches.

Since HTTPProxy provides this ability as well, this will affect priority of routes from HTTPProxies, not just Gateway API HTTPRoute.

Alternately we could add a method field directly to the dag.Route struct and implement method matching that way. We may want to in that case also sanitize the header matches to make sure we properly collect matches on the :method header, or disallow using them in HTTPRoute, etc.

See gateway API docs: https://github.com/kubernetes-sigs/gateway-api/blob/v0.7.1/apis/v1beta1/httproute_types.go#L163-L167

@sunjayBhatia sunjayBhatia added the release-note/minor A minor change that needs about a paragraph of explanation in the release notes. label Jun 2, 2023
@sunjayBhatia sunjayBhatia requested a review from a team as a code owner June 2, 2023 00:04
@sunjayBhatia sunjayBhatia requested review from tsaarni, stevesloka and skriss and removed request for a team June 2, 2023 00:04
@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@d42b892). Click here to learn what that means.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5434   +/-   ##
=======================================
  Coverage        ?   78.21%           
=======================================
  Files           ?      138           
  Lines           ?    18517           
  Branches        ?        0           
=======================================
  Hits            ?    14483           
  Misses          ?     3757           
  Partials        ?      277           
Impacted Files Coverage Δ
internal/sorter/sorter.go 100.00% <100.00%> (ø)

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

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

LGTM, I think this makes sense. Let's just call out the potential change in route priority for this corner case in the release note.

This is to support Gateway API conformance, release 0.7.1 dictates that
HTTP method comes before length of header matches in the precendence
order for choosing routes.

Since we currently implement method matching in the DAG by adding a
:method header match, this solution finds any :method headers being
matched on and first determines precendence of two routes being compared
based on that. If method matches are equal (both present or not
present), then we go ahead with comparing the remaining header matches.

Since HTTPProxy provides this ability as well, this will affect priority
of routes from HTTPProxies, not just Gateway API HTTPRoute.

Alternately we could add a method field directly to the dag.Route struct
and implement method matching that way. We may want to in that case also
sanitize the header matches to make sure we properly collect matches on
the :method header, or disallow using them in HTTPRoute, etc.

Signed-off-by: Sunjay Bhatia <[email protected]>
@sunjayBhatia sunjayBhatia force-pushed the method-matching-precedence branch from 8848f64 to 62ca3e7 Compare June 6, 2023 14:25
Signed-off-by: Sunjay Bhatia <[email protected]>
@sunjayBhatia sunjayBhatia requested a review from skriss June 6, 2023 14:33
@skriss skriss merged commit a19e619 into projectcontour:main Jun 12, 2023
@sunjayBhatia sunjayBhatia deleted the method-matching-precedence branch June 12, 2023 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/minor A minor change that needs about a paragraph of explanation in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants