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

implement assigning priorities to Kong routes translated from HTTPRoute #4296

Merged
merged 10 commits into from
Jul 13, 2023

Conversation

randmonkey
Copy link
Contributor

@randmonkey randmonkey commented Jul 7, 2023

What this PR does / why we need it:

Assign priorities to Kong routes translated from HTTPRoutes.

Which issue this PR fixes:

fixes #4249

Special notes for your reviewer:

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

@randmonkey randmonkey requested a review from a team as a code owner July 7, 2023 07:57
@randmonkey randmonkey added the area/feature New feature or request label Jul 7, 2023
@randmonkey randmonkey marked this pull request as draft July 7, 2023 07:58
@randmonkey randmonkey added the do not merge let the author merge this, don't merge for them. label Jul 7, 2023
@randmonkey randmonkey force-pushed the feat/assign_priority_routes_httproute branch from 01e5533 to d250d80 Compare July 10, 2023 10:13
@randmonkey randmonkey removed the do not merge let the author merge this, don't merge for them. label Jul 10, 2023
@randmonkey randmonkey marked this pull request as ready for review July 10, 2023 10:30
@randmonkey randmonkey changed the title [WIP] implement assigning priorities to Kong routes translated from HTTPRoute implement assigning priorities to Kong routes translated from HTTPRoute Jul 10, 2023
@randmonkey randmonkey added this to the KIC v2.11.0 milestone Jul 10, 2023
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

Some minor comments. I might not be an expert here but I believe splitted shouldn't be used and instead we should use split as past participle of split.

CHANGELOG.md Outdated Show resolved Hide resolved
internal/dataplane/parser/translate_httproute.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

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

Are we able to pre-process HTTPRoutes for validity and register errors regardless of whether we're using expression routes or not?

It's not quite obvious from the diff but it looks like this will introduce a separate validation path for expression and traditional mode, even though the issues aren't exclusive to one mode (e.g. ErrRouteValidationNoMatchRulesOrHostnamesSpecified and the results of validateHTTPRoute() depend only on the contents of the original resource, not which type of Kong route we're translating to).

If we have those checks separately in the mode translators, we're likely to miss checks in one or the other (we ran into this with CombinedRoutes) and need more test coverage, so if we can validate before translating, we should.

@randmonkey
Copy link
Contributor Author

randmonkey commented Jul 11, 2023

Are we able to pre-process HTTPRoutes for validity and register errors regardless of whether we're using expression routes or not?

It's not quite obvious from the diff but it looks like this will introduce a separate validation path for expression and traditional mode, even though the issues aren't exclusive to one mode (e.g. ErrRouteValidationNoMatchRulesOrHostnamesSpecified and the results of validateHTTPRoute() depend only on the contents of the original resource, not which type of Kong route we're translating to).

If we have those checks separately in the mode translators, we're likely to miss checks in one or the other (we ran into this with CombinedRoutes) and need more test coverage, so if we can validate before translating, we should.

Sounds good, but if we extract the validation code, it will affect the original translation code in multiple places. This would make the PR to be even larger and harder for a detailed review. I suggest to finish it in another PR. @rainest would you please create another issue to extract the validation and translation failure code (and add it to 2.11 milestone)?

@rainest's edit: logged it in #4321

@randmonkey randmonkey force-pushed the feat/assign_priority_routes_httproute branch from 676bf97 to c6502c7 Compare July 11, 2023 08:16
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Patch coverage: 88.5% and project coverage change: +0.4 🎉

Comparison is base (c8843de) 64.9% compared to head (7709eaa) 65.4%.

❗ Current head 7709eaa differs from pull request most recent head 9ac8af7. Consider uploading reports for the commit 9ac8af7 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #4296     +/-   ##
=======================================
+ Coverage   64.9%   65.4%   +0.4%     
=======================================
  Files        154     154             
  Lines      17384   17722    +338     
=======================================
+ Hits       11297   11603    +306     
- Misses      5367    5388     +21     
- Partials     720     731     +11     
Impacted Files Coverage Δ
internal/dataplane/parser/translate_httproute.go 78.3% <68.5%> (-2.2%) ⬇️
...rnal/dataplane/parser/translators/httproute_atc.go 96.0% <94.4%> (-2.2%) ⬇️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@mlavacca mlavacca left a comment

Choose a reason for hiding this comment

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

It looks good @randmonkey! Can you please re-enable the header matching conformance test to verify we are actually fixing that issue?

tests.HTTPRouteHeaderMatching.ShortName,

@randmonkey
Copy link
Contributor Author

randmonkey commented Jul 11, 2023

It looks good @randmonkey! Can you please re-enable the header matching conformance test to verify we are actually fixing that issue?

tests.HTTPRouteHeaderMatching.ShortName,

I think this conformance should be re-enabled when KIC can run with L4 proxy with expression router: #4312 because the TCPRoute, TLSRoute, UDPRoute cases will fail when L4 proxy cannot be supported.
Or we could run 2 sets of conformance tests for different router flavors. WDYT @mlavacca ?

@mlavacca
Copy link
Member

I think this conformance should be re-enabled when KIC can run with L4 proxy with expression router: #4312 because the TCPRoute, TLSRoute, UDPRoute cases will fail when L4 proxy cannot be supported.
Or we could run 2 sets of conformance tests for different router flavors. WDYT @mlavacca ?

There are no conformance tests for L4 routes so far. There are L7-only conformance tests upstream, so I don't think it is a problem 🤔

@randmonkey
Copy link
Contributor Author

randmonkey commented Jul 12, 2023

I think this conformance should be re-enabled when KIC can run with L4 proxy with expression router: #4312 because the TCPRoute, TLSRoute, UDPRoute cases will fail when L4 proxy cannot be supported.
Or we could run 2 sets of conformance tests for different router flavors. WDYT @mlavacca ?

There are no conformance tests for L4 routes so far. There are L7-only conformance tests upstream, so I don't think it is a problem thinking

There is ONE conformance test: tests.TLSRouteSimpleSameNamespace.ShortName depending on TLSRoute. But it is OK to re-enable the header match case, because we skip the TLSRoute case now.

mlavacca
mlavacca previously approved these changes Jul 13, 2023
test/conformance/gateway_conformance_test.go Show resolved Hide resolved
internal/dataplane/parser/translators/httproute_atc.go Outdated Show resolved Hide resolved
czeslavo
czeslavo previously approved these changes Jul 13, 2023
Copy link
Contributor

@czeslavo czeslavo left a comment

Choose a reason for hiding this comment

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

🚀

Co-authored-by: Mattia Lavacca <lavacca.mattia@gmail.com>
@randmonkey randmonkey dismissed stale reviews from czeslavo and mlavacca via 9ac8af7 July 13, 2023 12:38
@randmonkey randmonkey enabled auto-merge (squash) July 13, 2023 12:38
@randmonkey randmonkey merged commit ed49854 into main Jul 13, 2023
27 checks passed
@randmonkey randmonkey deleted the feat/assign_priority_routes_httproute branch July 13, 2023 13:15
@mlavacca
Copy link
Member

It looks like the conformance test is broken. No idea why it was passing 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/feature New feature or request size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assign priorities to Kong expression routes from HTTPRoutes
5 participants