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

handle Route conflicts with HTTPRoute.Matches #6188

Merged
merged 15 commits into from
Apr 17, 2024

Conversation

lubronzhan
Copy link
Contributor

@lubronzhan lubronzhan commented Feb 13, 2024

Fix #3608

Now if there is conflicts between HTTPRoute's match, then only the HTTPRoute with

  • older creationTimestamp
  • alphabetically smaller on namespace/name

, will be chosen as the valid HTTPRoute, other HTTPRoute will be marked as conflict condition

TODO:

  • Mark HTTPRoute as conflict condition if needed
  • E2E Test

Signed-off-by: lubronzhan lubronzhan@gmail.com

@lubronzhan lubronzhan requested a review from a team as a code owner February 13, 2024 07:37
@lubronzhan lubronzhan requested review from skriss and sunjayBhatia and removed request for a team February 13, 2024 07:37
@sunjayBhatia sunjayBhatia requested review from a team, davinci26 and clayton-gonsalves and removed request for a team February 13, 2024 07:37
@lubronzhan lubronzhan force-pushed the topic/lubron/fix-3608 branch 3 times, most recently from 0dbed73 to eb08c7f Compare February 13, 2024 17:55
@sunjayBhatia sunjayBhatia added the release-note/minor A minor change that needs about a paragraph of explanation in the release notes. label Feb 13, 2024
Copy link

codecov bot commented Feb 14, 2024

Codecov Report

Attention: Patch coverage is 87.71930% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 81.59%. Comparing base (3d85617) to head (2ae98cc).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6188   +/-   ##
=======================================
  Coverage   81.58%   81.59%           
=======================================
  Files         133      133           
  Lines       15815    15861   +46     
=======================================
+ Hits        12902    12941   +39     
- Misses       2618     2624    +6     
- Partials      295      296    +1     
Files Coverage Δ
internal/dag/dag.go 98.44% <100.00%> (+0.04%) ⬆️
internal/status/routeconditions.go 53.01% <ø> (ø)
internal/dag/gatewayapi_processor.go 93.19% <86.79%> (-0.32%) ⬇️

@lubronzhan lubronzhan marked this pull request as draft February 14, 2024 07:13
@lubronzhan lubronzhan marked this pull request as ready for review February 14, 2024 08:02
@lubronzhan lubronzhan marked this pull request as draft February 14, 2024 08:02
@sunjayBhatia sunjayBhatia requested a review from a team February 14, 2024 08:02
@lubronzhan lubronzhan changed the title [WIP]handle Route conflicts with HTTPProxy.Matches [WIP]handle Route conflicts with HTTPRoute.Matches Feb 14, 2024
@lubronzhan lubronzhan force-pushed the topic/lubron/fix-3608 branch 2 times, most recently from 0accf4f to c00ad0b Compare February 16, 2024 06:17
@lubronzhan
Copy link
Contributor Author

lubronzhan commented Feb 16, 2024

Only failure is context exceeded. I think it's unrelated to the change since the change that affects all route are sorting routes before compute

--- FAIL: TestGRPC (0.76s)
    --- FAIL: TestGRPC/StreamRoutes (0.15s)
        server_test.go:200: 
            	Error Trace:	/Users/runner/work/contour/contour/internal/xdscache/v3/server_test.go:298
            	            				/Users/runner/work/contour/contour/internal/xdscache/v3/server_test.go:200
            	            				/Users/runner/work/contour/contour/internal/xdscache/v3/server_test.go:276
            	Error:      	Received unexpected error:
            	            	rpc error: code = DeadlineExceeded desc = context deadline exceeded
            	Test:       	TestGRPC/StreamRoutes

All passed now

@lubronzhan lubronzhan marked this pull request as ready for review February 16, 2024 07:30
@lubronzhan lubronzhan changed the title [WIP]handle Route conflicts with HTTPRoute.Matches handle Route conflicts with HTTPRoute.Matches Feb 16, 2024
@lubronzhan lubronzhan force-pushed the topic/lubron/fix-3608 branch 4 times, most recently from e94563f to b38eabe Compare February 16, 2024 17:24
@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 8, 2024
@lubronzhan lubronzhan removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 8, 2024
@lubronzhan
Copy link
Contributor Author

Hi @projectcontour/maintainers any chance to get this merged?

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.

Thanks @lubronzhan, I think this change makes sense though it would definitely be nice to have an upstream Gateway API conformance test to verify against, maybe we can contribute that separately

changelogs/unreleased/6188-lubronzhan-minor.md Outdated Show resolved Hide resolved
internal/dag/gatewayapi_processor.go Outdated Show resolved Hide resolved
test/e2e/gatewayapi_predicates.go Outdated Show resolved Hide resolved
test/e2e/gateway/http_route_conflict_match_test.go Outdated Show resolved Hide resolved
test/e2e/gateway/http_route_conflict_match_test.go Outdated Show resolved Hide resolved
test/e2e/gatewayapi_predicates.go Outdated Show resolved Hide resolved
test/e2e/gatewayapi_predicates.go Outdated Show resolved Hide resolved
Add logic to filter Route before adding it to vhost

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
…ompare with other match object

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
@lubronzhan
Copy link
Contributor Author

lubronzhan commented Apr 16, 2024

Thanks @lubronzhan, I think this change makes sense though it would definitely be nice to have an upstream Gateway API conformance test to verify against, maybe we can contribute that separately

Do you have any reference. Just saw we are referencing the conformance test here

Happy to put it into different PR

Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
@skriss
Copy link
Member

skriss commented Apr 16, 2024

Thanks @lubronzhan, I think this change makes sense though it would definitely be nice to have an upstream Gateway API conformance test to verify against, maybe we can contribute that separately

Do you have any reference. Just saw we are referencing the conformance test here

Happy to put it into different PR

Yeah it would be in the Gateway API repo, the conformance tests are here: https://github.com/kubernetes-sigs/gateway-api/tree/main/conformance/tests

You can see some of the past PRs to add tests here: https://github.com/kubernetes-sigs/gateway-api/pulls?q=is%3Apr+label%3Aarea%2Fconformance

Happy to pair/provide further pointers if needed

Comment on lines +1446 to +1447
// check all the routes whether there is conflict against previous rules
if !p.hasConflictRoute(listener, hosts, routes) {
Copy link
Member

Choose a reason for hiding this comment

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

One case I'm not totally clear on is: what if a rule in a given HTTPRoute has multiple matches defined, and only one of those matches conflicts with another HTTPRoute? Should the entire rule be dropped, or only the match that conflicted? (matches within a rule are logically OR'ed)

https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io%2fv1.RouteConditionType docs for PartiallyInvalid seem to imply that the entire rule should be dropped, but it's not crystal clear from the spec. I think this PR's implementation is good for now (dropping the entire rule), but this is an example of something that could be clarified and encoded in the upstream conformance test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sunjay also mentioned here, in upstream, it does indicate that we should drop at the rule level, if one rule is conflict, just drop it and leave other rules

// 1) Drop Rule(s): With this approach, implementations will drop the
// invalid Route Rule(s) until they are fully valid again. The message
// for this condition MUST start with the prefix "Dropped Rule" and
// include information about which Rules have been dropped. In this
// state, the "Accepted" condition MUST be set to "True" with the latest
// generation of the resource.

@lubronzhan
Copy link
Contributor Author

Thanks @lubronzhan, I think this change makes sense though it would definitely be nice to have an upstream Gateway API conformance test to verify against, maybe we can contribute that separately

Do you have any reference. Just saw we are referencing the conformance test here
Happy to put it into different PR

Yeah it would be in the Gateway API repo, the conformance tests are here: kubernetes-sigs/gateway-api@main/conformance/tests

You can see some of the past PRs to add tests here: kubernetes-sigs/gateway-api/pulls (label:area/conformance)

Happy to pair/provide further pointers if needed

Just found out that I did created an issue for tracking conformance test #6227

Thanks for the pointers, will create one for gateway-api

@skriss
Copy link
Member

skriss commented Apr 17, 2024

👍 I'm going to go ahead and merge this now so it doesn't run into any conflicts, can always circle back and address any post-merge feedback if needed before release. Thanks again @lubronzhan!

@skriss skriss merged commit 3c79035 into projectcontour:main Apr 17, 2024
26 checks passed
@lubronzhan lubronzhan deleted the topic/lubron/fix-3608 branch April 18, 2024 00:29
SamMHD pushed a commit to SamMHD/contour that referenced this pull request Sep 8, 2024
When there are conflicts between matches for
rules in multiple HTTPRoutes, use the Gateway
API conflict resolution rules to determine
precedence.

Closes projectcontour#3608.

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Signed-off-by: Saman Mahdanian <saman@mahdanian.xyz>
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.

Gateway API: handle Route conflicts with HTTPRoute.Matches
3 participants