-
Notifications
You must be signed in to change notification settings - Fork 690
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
Conversation
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 Report
@@ 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
|
@@ -79,7 +80,14 @@ type HeaderCondition struct { | |||
} | |||
|
|||
func (hc *HeaderCondition) String() string { | |||
return "header: " + hc.Name | |||
details := strings.Join([]string{ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- 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").
- when two routes can be combined similarly to the above, collapse them into a single route
- 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.
There was a problem hiding this 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.
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