Overview of the Issue
Two issues we have with HTTPRoute services is that we:
- Seem to have failed to normalize the weight of a given service to 1 by default (it stays 0 if unspecified)
- Additionally, when a service is skipped in our discoverychain construction code:
|
if service.Weight == 0 { |
|
continue |
|
} |
we can potentially wind up with no service splits (if we have no services with non-zero weight), and we fail to append a corresponding splitter here:
|
if len(splitter.Splits) > 0 { |
|
splitters = append(splitters, splitter) |
|
} |
that winds up with our synthetic router referencing a service route for a splitter that doesn't exist:
|
router.Routes = append(router.Routes, structs.ServiceRoute{ |
|
Match: &structs.ServiceRouteMatch{HTTP: httpRouteMatchToServiceRouteHTTPMatch(match)}, |
|
Destination: &destination, |
|
}) |
and we wind up with envoy spitting out tcp/http mismatch protocol errors (due to the compiled discovery chain thinking that the referenced, non-existent splitter should be treated as a TCP-resolver discovery node).
Reproduction Steps
Create and attach an HTTPRoute with referencing two services in a routing rule where each has 0 weight, such as:
Rules = [
{
Services = [
{
Name = "service-one"
},
{
Name = "service-two"
}
]
}
]
Attach to a gateway and watch Consul logs for protocol mismatch errors.
This should be fixed in two ways:
- We should normalize to,
Weight = 1, and
- We shouldn't add a route to the router if no corresponding splitter was added.
Overview of the Issue
Two issues we have with HTTPRoute services is that we:
consul/agent/consul/discoverychain/gateway_httproute.go
Lines 131 to 133 in 73b9b40
we can potentially wind up with no service splits (if we have no services with non-zero weight), and we fail to append a corresponding splitter here:
consul/agent/consul/discoverychain/gateway_httproute.go
Lines 156 to 158 in 73b9b40
that winds up with our synthetic router referencing a service route for a splitter that doesn't exist:
consul/agent/consul/discoverychain/gateway_httproute.go
Lines 168 to 171 in 73b9b40
and we wind up with envoy spitting out tcp/http mismatch protocol errors (due to the compiled discovery chain thinking that the referenced, non-existent splitter should be treated as a TCP-resolver discovery node).
Reproduction Steps
Create and attach an HTTPRoute with referencing two services in a routing rule where each has 0 weight, such as:
Attach to a gateway and watch Consul logs for protocol mismatch errors.
This should be fixed in two ways:
Weight = 1, and