Skip to content

[API Gateway] HTTPRoute - when all services have 0 weight, we get protocol mismatches #16454

@andrewstucki

Description

@andrewstucki

Overview of the Issue

Two issues we have with HTTPRoute services is that we:

  1. Seem to have failed to normalize the weight of a given service to 1 by default (it stays 0 if unspecified)
  2. 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:

  1. We should normalize to, Weight = 1, and
  2. We shouldn't add a route to the router if no corresponding splitter was added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions