Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tcp:
- name: "tcp-listener-with-no-routes"
address: "::"
port: 10080
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
udp:
- name: "udp-route-with-no-routes"
address: "::"
port: 10080
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: EmptyCluster
type: STATIC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- address:
socketAddress:
address: '::'
portValue: 10080
filterChains:
- filters:
- name: envoy.filters.network.tcp_proxy
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
cluster: EmptyCluster
statPrefix: tcp-10080
name: EmptyCluster
name: tcp-listener-with-no-routes
perConnectionBufferLimitBytes: 32768
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: EmptyCluster
type: STATIC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- address:
socketAddress:
address: '::'
portValue: 10080
protocol: UDP
listenerFilters:
- name: envoy.filters.udp_listener.udp_proxy
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig
matcher:
onNoMatch:
action:
name: route
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.Route
cluster: EmptyCluster
statPrefix: service
name: udp-route-with-no-routes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
61 changes: 37 additions & 24 deletions internal/xds/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@

const (
AuthorityHeaderKey = ":authority"
// The dummy cluster for TCP listeners that have no routes
// The dummy cluster name for TCP/UDP listeners that have no routes
emptyClusterName = "EmptyCluster"
)

// The dummy cluster for TCP/UDP listeners that have no routes
var emptyRouteCluster = &clusterv3.Cluster{
Name: emptyClusterName,
ClusterDiscoveryType: &clusterv3.Cluster_Type{Type: clusterv3.Cluster_STATIC},
}

// Translator translates the xDS IR into xDS resources.
type Translator struct {
// ControllerNamespace is the namespace of the Gateway API controller
Expand Down Expand Up @@ -731,11 +737,6 @@
// If there are no routes, add a route without a destination to the listener to create a filter chain
// This is needed because Envoy requires a filter chain to be present in the listener, otherwise it will reject the listener and report a warning
if len(tcpListener.Routes) == 0 {
emptyRouteCluster := &clusterv3.Cluster{
Name: emptyClusterName,
ClusterDiscoveryType: &clusterv3.Cluster_Type{Type: clusterv3.Cluster_STATIC},
}

if findXdsCluster(tCtx, emptyClusterName) == nil {
if err := tCtx.AddXdsResource(resourcev3.ClusterType, emptyRouteCluster); err != nil {
errs = errors.Join(errs, err)
Expand Down Expand Up @@ -770,29 +771,41 @@
// There won't be multiple UDP listeners on the same port since it's already been checked at the gateway api
// translator
if udpListener.Route != nil {
route := udpListener.Route

xdsListener, err := buildXdsUDPListener(route.Destination.Name, udpListener, accesslog)
if err != nil {
// skip this listener if failed to build xds listener
errs = errors.Join(errs, err)
continue
}
if err := tCtx.AddXdsResource(resourcev3.ListenerType, xdsListener); err != nil {
// skip this listener if failed to add xds listener to the resource version table
errs = errors.Join(errs, err)
continue
}

// 1:1 between IR UDPRoute and xDS Cluster
if err := processXdsCluster(tCtx,
route.Destination.Name,
route.Destination.Settings,
&UDPRouteTranslator{route},
udpListener.Route.Destination.Name,
udpListener.Route.Destination.Settings,
&UDPRouteTranslator{udpListener.Route},
&ExtraArgs{metrics: metrics},
route.Destination.Metadata); err != nil {
udpListener.Route.Destination.Metadata); err != nil {
errs = errors.Join(errs, err)
}
} else {
udpListener.Route = &ir.UDPRoute{
Name: emptyClusterName,
Destination: &ir.RouteDestination{
Name: emptyClusterName,
},
}

// Add empty cluster for UDP listener which have no Route, when empty cluster is not found.
if findXdsCluster(tCtx, emptyClusterName) == nil {
if err := tCtx.AddXdsResource(resourcev3.ClusterType, emptyRouteCluster); err != nil {
errs = errors.Join(errs, err)
}

Check warning on line 795 in internal/xds/translator/translator.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/translator.go#L794-L795

Added lines #L794 - L795 were not covered by tests
}
}

xdsListener, err := buildXdsUDPListener(udpListener.Route.Destination.Name, udpListener, accesslog)
if err != nil {
// skip this listener if failed to build xds listener
errs = errors.Join(errs, err)
continue

Check warning on line 803 in internal/xds/translator/translator.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/translator.go#L801-L803

Added lines #L801 - L803 were not covered by tests
}
if err := tCtx.AddXdsResource(resourcev3.ListenerType, xdsListener); err != nil {
// skip this listener if failed to add xds listener to the resource version table
errs = errors.Join(errs, err)
continue
}
}
return errs
Expand Down
1 change: 1 addition & 0 deletions release-notes/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ new features: |

bug fixes: |
Fixed issue where WASM cache init failure caused routes with WASM-less EnvoyExtensionPolicies to have 500 direct responses.
Fixed issue which UDP listeners were not created in the Envoy proxy config when Gateway was created.

# Enhancements that improve performance.
performance improvements: |
Expand Down