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

fix(gateway): invalid Envoy resources with real MeshService backends and appProtocol: tcp #12017

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pkg/plugins/runtime/gateway/cluster_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ func (c *ClusterGenerator) generateRealBackendRefCluster(
systemNamespace string,
identifyingTags map[string]string,
) (*core_xds.Resource, string, error) {
service, destProtocol, _, ok := meshroute.GetServiceProtocolPortFromRef(meshCtx, backendRef)
service, _, _, ok := meshroute.GetServiceProtocolPortFromRef(meshCtx, backendRef)
if !ok {
return nil, "", nil
}
protocol := route.InferServiceProtocol(destProtocol, routeProtocol)
protocol := route.ProtocolOr(routeProtocol, core_mesh.ProtocolHTTP)

edsClusterBuilder := clusters.NewClusterBuilder(proxy.APIVersion, service).
Configure(
Expand Down Expand Up @@ -196,8 +196,7 @@ func (c *ClusterGenerator) generateMeshCluster(
upstreamServiceName string,
identifyingTags map[string]string,
) (*core_xds.Resource, error) {
destProtocol := core_mesh.ParseProtocol(dest.Destination[mesh_proto.ProtocolTag])
protocol := route.InferServiceProtocol(destProtocol, dest.RouteProtocol)
protocol := route.ProtocolOr(dest.RouteProtocol, core_mesh.ProtocolHTTP)

builder := newClusterBuilder(info.Proxy.APIVersion, dest.Destination[mesh_proto.ServiceTag], protocol, dest).Configure(
clusters.EdsCluster(),
Expand Down
17 changes: 8 additions & 9 deletions pkg/plugins/runtime/gateway/route/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ import (
util_protocol "github.com/kumahq/kuma/pkg/util/protocol"
)

func ProtocolOr(protocol, fallback core_mesh.Protocol) core_mesh.Protocol {
if protocol == core_mesh.ProtocolUnknown {
return fallback
}
return protocol
}

func InferServiceProtocol(serviceProtocol core_mesh.Protocol, routeProtocol core_mesh.Protocol) core_mesh.Protocol {
if serviceProtocol == core_mesh.ProtocolUnknown || serviceProtocol == "" {
switch routeProtocol {
case core_mesh.ProtocolHTTP:
return core_mesh.ProtocolHTTP
case core_mesh.ProtocolTCP:
return core_mesh.ProtocolTCP
default:
// HTTP is a better default than "unknown".
return core_mesh.ProtocolHTTP
}
return ProtocolOr(routeProtocol, core_mesh.ProtocolHTTP)
}
return serviceProtocol
}
Expand Down
Loading