diff --git a/agent/xds/routes.go b/agent/xds/routes.go index 9f4f1befe1..1954d7f970 100644 --- a/agent/xds/routes.go +++ b/agent/xds/routes.go @@ -186,13 +186,6 @@ func makeUpstreamRouteForDiscoveryChain( } func makeRouteMatchForDiscoveryRoute(discoveryRoute *structs.DiscoveryRoute, protocol string) envoyroute.RouteMatch { - switch protocol { - case "http", "http2": - // The only match stanza is HTTP. - default: - return makeDefaultRouteMatch() - } - match := discoveryRoute.Definition.Match if match == nil || match.IsEmpty() { return makeDefaultRouteMatch() diff --git a/agent/xds/routes_test.go b/agent/xds/routes_test.go index a5d738a8ba..5c3d15c3ff 100644 --- a/agent/xds/routes_test.go +++ b/agent/xds/routes_test.go @@ -79,6 +79,32 @@ func TestRoutesFromSnapshot(t *testing.T) { }, setup: nil, }, + { + name: "connect-proxy-with-grpc-router", + create: func(t testinf.T) *proxycfg.ConfigSnapshot { + return proxycfg.TestConfigSnapshotDiscoveryChainWithEntries(t, + &structs.ProxyConfigEntry{ + Kind: structs.ProxyDefaults, + Name: structs.ProxyConfigGlobal, + Config: map[string]interface{}{ + "protocol": "grpc", + }, + }, + &structs.ServiceRouterConfigEntry{ + Kind: structs.ServiceRouter, + Name: "db", + Routes: []structs.ServiceRoute{ + { + Match: httpMatch(&structs.ServiceRouteHTTPMatch{ + PathExact: "/fgrpc.PingServer/Ping", + }), + Destination: toService("prefix"), + }, + }, + }, + ) + }, + }, { name: "connect-proxy-with-chain-and-router", create: func(t testinf.T) *proxycfg.ConfigSnapshot { diff --git a/agent/xds/testdata/routes/connect-proxy-with-grpc-router.golden b/agent/xds/testdata/routes/connect-proxy-with-grpc-router.golden new file mode 100644 index 0000000000..244a2e7ef5 --- /dev/null +++ b/agent/xds/testdata/routes/connect-proxy-with-grpc-router.golden @@ -0,0 +1,38 @@ +{ + "versionInfo": "00000001", + "resources": [ + { + "@type": "type.googleapis.com/envoy.api.v2.RouteConfiguration", + "name": "db", + "virtualHosts": [ + { + "name": "db", + "domains": [ + "*" + ], + "routes": [ + { + "match": { + "path": "/fgrpc.PingServer/Ping" + }, + "route": { + "cluster": "prefix.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + } + }, + { + "match": { + "prefix": "/" + }, + "route": { + "cluster": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul" + } + } + ] + } + ], + "validateClusters": true + } + ], + "typeUrl": "type.googleapis.com/envoy.api.v2.RouteConfiguration", + "nonce": "00000001" +} \ No newline at end of file