Skip to content

Commit

Permalink
feat: set tcp proxy cluster buffer (#1325)
Browse files Browse the repository at this point in the history
Signed-off-by: bitliu <[email protected]>
  • Loading branch information
Xunzhuo authored Apr 19, 2023
1 parent ef98e16 commit 5d360cb
Show file tree
Hide file tree
Showing 39 changed files with 81 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/cmd/egctl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestExtractAllConfigDump(t *testing.T) {
}

for _, tc := range cases {
t.Run(tc.output, func(t *testing.T) {
t.Run(tc.expected, func(t *testing.T) {
configDump, err := extractConfigDump(fw, true)
assert.NoError(t, err)
got, err := marshalEnvoyProxyConfig(configDump, tc.output)
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestExtractSubResourcesConfigDump(t *testing.T) {
}

for _, tc := range cases {
t.Run(tc.output, func(t *testing.T) {
t.Run(tc.expected, func(t *testing.T) {
configDump, err := extractConfigDump(fw, false)
assert.NoError(t, err)
resource, err := findXDSResourceFromConfigDump(tc.resourceType, configDump)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ xds:
resourceApiVersion: V3
name: default-backend-rule-0-match-0-www.example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- '@type': type.googleapis.com/envoy.admin.v3.ListenersConfigDump
dynamicListeners:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ xds:
resourceApiVersion: V3
name: envoy-gateway-system-backend-rule-0-match-0-www.example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
},
"name": "default-backend-rule-0-match-0-www.example.com",
"outlierDetection": {},
"perConnectionBufferLimitBytes": 32768,
"type": "EDS"
}
}, {
Expand All @@ -245,6 +246,7 @@
},
"name": "default-backend-rule-0-match-0-www.grpc-example.com",
"outlierDetection": {},
"perConnectionBufferLimitBytes": 32768,
"type": "EDS",
"typedExtensionProtocolOptions": {
"envoy.extensions.upstreams.http.v3.HttpProtocolOptions": {
Expand All @@ -271,6 +273,7 @@
},
"name": "default-eg-tls-passthrough-backend",
"outlierDetection": {},
"perConnectionBufferLimitBytes": 32768,
"type": "EDS"
}
}, {
Expand All @@ -289,6 +292,7 @@
},
"name": "default-eg-tcp-backend",
"outlierDetection": {},
"perConnectionBufferLimitBytes": 32768,
"type": "EDS"
}
}, {
Expand All @@ -307,6 +311,7 @@
},
"name": "default-eg-udp-backend",
"outlierDetection": {},
"perConnectionBufferLimitBytes": 32768,
"type": "EDS"
}
}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ xds:
resourceApiVersion: V3
name: default-backend-rule-0-match-0-www.example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -162,6 +163,7 @@ xds:
resourceApiVersion: V3
name: default-backend-rule-0-match-0-www.grpc-example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
Expand All @@ -180,6 +182,7 @@ xds:
resourceApiVersion: V3
name: default-eg-tls-passthrough-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -193,6 +196,7 @@ xds:
resourceApiVersion: V3
name: default-eg-tcp-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -206,6 +210,7 @@ xds:
resourceApiVersion: V3
name: default-eg-udp-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- '@type': type.googleapis.com/envoy.admin.v3.ListenersConfigDump
dynamicListeners:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ xds:
resourceApiVersion: V3
name: default-backend-rule-0-match-0-www.example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -27,6 +28,7 @@ xds:
resourceApiVersion: V3
name: default-backend-rule-0-match-0-www.grpc-example.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
Expand All @@ -45,6 +47,7 @@ xds:
resourceApiVersion: V3
name: default-eg-tls-passthrough-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -58,6 +61,7 @@ xds:
resourceApiVersion: V3
name: default-eg-tcp-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
Expand All @@ -71,4 +75,5 @@ xds:
resourceApiVersion: V3
name: default-eg-udp-backend
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
5 changes: 4 additions & 1 deletion internal/xds/translator/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

const (
extensionOptionsKey = "envoy.extensions.upstreams.http.v3.HttpProtocolOptions"
// https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto#envoy-v3-api-field-config-cluster-v3-cluster-per-connection-buffer-limit-bytes
tcpClusterPerConnectionBufferLimitBytes = 32768
)

func buildXdsCluster(routeName string, tSocket *corev3.TransportSocket, protocol ProtocolType, endpointType EndpointType) *clusterv3.Cluster {
Expand All @@ -34,7 +36,8 @@ func buildXdsCluster(routeName string, tSocket *corev3.TransportSocket, protocol
CommonLbConfig: &clusterv3.Cluster_CommonLbConfig{
LocalityConfigSpecifier: &clusterv3.Cluster_CommonLbConfig_LocalityWeightedLbConfig_{
LocalityWeightedLbConfig: &clusterv3.Cluster_CommonLbConfig_LocalityWeightedLbConfig{}}},
OutlierDetection: &clusterv3.OutlierDetection{},
OutlierDetection: &clusterv3.OutlierDetection{},
PerConnectionBufferLimitBytes: wrapperspb.UInt32(tcpClusterPerConnectionBufferLimitBytes),
}

if tSocket != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- loadAssignment:
clusterName: mock-extension-injected-cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- loadAssignment:
clusterName: mock-extension-injected-cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route-www.test.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -19,6 +20,7 @@
resourceApiVersion: V3
name: second-route-www.test.com
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -38,6 +40,7 @@
locality: {}
name: localhost_443
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
respectDnsTtl: true
transportSocket:
name: envoy.transport_sockets.tls
Expand All @@ -58,6 +61,7 @@
resourceApiVersion: V3
name: "192_168_1_250_8080"
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
transportSocket:
name: envoy.transport_sockets.tls
typedConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -19,6 +20,7 @@
resourceApiVersion: V3
name: second-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -38,6 +40,7 @@
locality: {}
name: localhost_443
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
respectDnsTtl: true
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -19,6 +20,7 @@
resourceApiVersion: V3
name: second-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -30,6 +32,7 @@
resourceApiVersion: V3
name: third-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -49,6 +52,7 @@
locality: {}
name: ratelimit_cluster
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
respectDnsTtl: true
type: STRICT_DNS
typedExtensionProtocolOptions:
Expand All @@ -66,6 +70,7 @@
resourceApiVersion: V3
name: "192_168_1_250_443"
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
transportSocket:
name: envoy.transport_sockets.tls
typedConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -27,6 +28,7 @@
locality: {}
name: localhost_443
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
respectDnsTtl: true
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: direct-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
resourceApiVersion: V3
name: mirror-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
- commonLbConfig:
localityWeightedLbConfig: {}
Expand All @@ -19,4 +20,5 @@
resourceApiVersion: V3
name: mirror-route-mirror-0
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: redirect-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: regex-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: request-header-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: response-header-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: response-header-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: response-header-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: rewrite-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: rewrite-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: rewrite-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: rewrite-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
resourceApiVersion: V3
name: first-route
outlierDetection: {}
perConnectionBufferLimitBytes: 32768
type: EDS
Loading

0 comments on commit 5d360cb

Please sign in to comment.