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

internal/dag: allow routes with overlapping header conditions #2600

Merged
merged 1 commit into from
Jun 19, 2020

Conversation

skriss
Copy link
Member

@skriss skriss commented Jun 17, 2020

closes #2597

Fixes a bug where an HTTPProxy with multiple routes with the same prefixes
and conditions on the same headers, differing only on the condition operators
or values, would result in only the last route being configured in Envoy and
all others being dropped.

Signed-off-by: Steve Kriss krisss@vmware.com

Fixes a bug where an HTTPProxy with multiple routes with the same prefixes
and conditions on the same headers, differing only on the condition operators
or values, would result in only the last route being configured in Envoy and
all others being dropped.

Signed-off-by: Steve Kriss <krisss@vmware.com>
@codecov
Copy link

codecov bot commented Jun 17, 2020

Codecov Report

Merging #2600 into master will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2600      +/-   ##
==========================================
- Coverage   76.85%   76.83%   -0.02%     
==========================================
  Files          71       71              
  Lines        5499     5505       +6     
==========================================
+ Hits         4226     4230       +4     
- Misses       1187     1188       +1     
- Partials       86       87       +1     
Impacted Files Coverage Δ
internal/dag/dag.go 93.67% <100.00%> (+0.52%) ⬆️
internal/dag/cache.go 98.09% <0.00%> (-0.96%) ⬇️

@@ -79,7 +80,14 @@ type HeaderCondition struct {
}

func (hc *HeaderCondition) String() string {
return "header: " + hc.Name
details := strings.Join([]string{

Choose a reason for hiding this comment

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

Maybe there are cases where different routes are required. So maybe this is the way to go.

However an incoming request (method:GET, Prefix:/) will match both -

(HeaderName: ":method", MatchType: "Exact", HeaderValue: "GET")
(HeaderName: ":method", MatchType: "Contains", HeaderValue: "GET")

Allowing routes differing on MatchType may create duplicates.

Copy link
Member

Choose a reason for hiding this comment

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

I think ideally we could detect if routes created won't match and set the status on the route, just not sure how difficult determining all those scenarios are. We'd have to match on duplicate header types of different types as @chintan8saaras noted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems like there are a couple of related improvements we could make here:

  1. within a single route, determine when one condition is a proper subset of another (e.g. "exact: foo" and "contains: foo" on the same header), and collapse them into just a single condition (in this case, just "exact: foo").
  2. when two routes can be combined similarly to the above, collapse them into a single route
  3. when there are conflicting header conditions for a given route (e.g. both "contains: foo" and "notcontains: foo"), mark the proxy as invalid. This is already done for conflicting "exact" conditions, but we could strengthen this validation.

@skriss skriss requested review from jpeach and youngnick June 18, 2020 22:54
Copy link
Member

@youngnick youngnick left a comment

Choose a reason for hiding this comment

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

LGTM - comments aside, this clearly fixes the current issue. If we want to handle other edge cases, then we should do that under separate issues.

@skriss skriss merged commit e764e03 into projectcontour:master Jun 19, 2020
@skriss skriss deleted the fix-2597 branch June 19, 2020 16:19
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.

HTTPProxy: some routes are ignored when they differ only on header condition operator or value
4 participants