Skip to content

Commit

Permalink
chore: remove deprecated Cluster.Http2ProtocolOptions (#4528)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont authored Jun 30, 2022
1 parent c4e0fe0 commit 9d5029e
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 55 deletions.
81 changes: 47 additions & 34 deletions pkg/xds/bootstrap/template_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import (
envoy_type_matcher_v3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"

util_proto "github.com/kumahq/kuma/pkg/util/proto"
clusters_v3 "github.com/kumahq/kuma/pkg/xds/envoy/clusters/v3"
"github.com/kumahq/kuma/pkg/xds/envoy/tls"
)

func genConfig(parameters configParameters, useTokenPath bool) (*envoy_bootstrap_v3.Bootstrap, error) {
staticClusters, err := buildStaticClusters(parameters, useTokenPath)
if err != nil {
return nil, err
}

res := &envoy_bootstrap_v3.Bootstrap{
Node: &envoy_core_v3.Node{
Id: parameters.Id,
Expand Down Expand Up @@ -120,7 +126,7 @@ func genConfig(parameters configParameters, useTokenPath bool) (*envoy_bootstrap
},
},
},
Clusters: buildStaticClusters(parameters, useTokenPath),
Clusters: staticClusters,
},
}
for _, r := range res.StaticResources.Clusters {
Expand Down Expand Up @@ -298,33 +304,30 @@ func buildGrpcService(params configParameters, useTokenPath bool) *envoy_core_v3
}
}

func buildStaticClusters(parameters configParameters, useTokenPath bool) []*envoy_cluster_v3.Cluster {
clusters := []*envoy_cluster_v3.Cluster{
{
// TODO does timeout and keepAlive make sense on this as it uses unix domain sockets?
Name: "access_log_sink",
ConnectTimeout: util_proto.Duration(parameters.XdsConnectTimeout),
Http2ProtocolOptions: &envoy_core_v3.Http2ProtocolOptions{},
LbPolicy: envoy_cluster_v3.Cluster_ROUND_ROBIN,
UpstreamConnectionOptions: &envoy_cluster_v3.UpstreamConnectionOptions{
TcpKeepalive: &envoy_core_v3.TcpKeepalive{
KeepaliveProbes: util_proto.UInt32(3),
KeepaliveTime: util_proto.UInt32(10),
KeepaliveInterval: util_proto.UInt32(10),
},
func buildStaticClusters(parameters configParameters, useTokenPath bool) ([]*envoy_cluster_v3.Cluster, error) {
accessLogSink := &envoy_cluster_v3.Cluster{
// TODO does timeout and keepAlive make sense on this as it uses unix domain sockets?
Name: "access_log_sink",
ConnectTimeout: util_proto.Duration(parameters.XdsConnectTimeout),
LbPolicy: envoy_cluster_v3.Cluster_ROUND_ROBIN,
UpstreamConnectionOptions: &envoy_cluster_v3.UpstreamConnectionOptions{
TcpKeepalive: &envoy_core_v3.TcpKeepalive{
KeepaliveProbes: util_proto.UInt32(3),
KeepaliveTime: util_proto.UInt32(10),
KeepaliveInterval: util_proto.UInt32(10),
},
ClusterDiscoveryType: &envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_STATIC},
LoadAssignment: &envoy_config_endpoint_v3.ClusterLoadAssignment{
ClusterName: "access_log_sink",
Endpoints: []*envoy_config_endpoint_v3.LocalityLbEndpoints{
{
LbEndpoints: []*envoy_config_endpoint_v3.LbEndpoint{
{
HostIdentifier: &envoy_config_endpoint_v3.LbEndpoint_Endpoint{
Endpoint: &envoy_config_endpoint_v3.Endpoint{
Address: &envoy_core_v3.Address{
Address: &envoy_core_v3.Address_Pipe{Pipe: &envoy_core_v3.Pipe{Path: parameters.AccessLogPipe}},
},
},
ClusterDiscoveryType: &envoy_cluster_v3.Cluster_Type{Type: envoy_cluster_v3.Cluster_STATIC},
LoadAssignment: &envoy_config_endpoint_v3.ClusterLoadAssignment{
ClusterName: "access_log_sink",
Endpoints: []*envoy_config_endpoint_v3.LocalityLbEndpoints{
{
LbEndpoints: []*envoy_config_endpoint_v3.LbEndpoint{
{
HostIdentifier: &envoy_config_endpoint_v3.LbEndpoint_Endpoint{
Endpoint: &envoy_config_endpoint_v3.Endpoint{
Address: &envoy_core_v3.Address{
Address: &envoy_core_v3.Address_Pipe{Pipe: &envoy_core_v3.Pipe{Path: parameters.AccessLogPipe}},
},
},
},
Expand All @@ -334,12 +337,17 @@ func buildStaticClusters(parameters configParameters, useTokenPath bool) []*envo
},
},
}
if err := (&clusters_v3.Http2Configurer{}).Configure(accessLogSink); err != nil {
return nil, err
}

clusters := []*envoy_cluster_v3.Cluster{accessLogSink}

if parameters.DataplaneTokenPath == "" || !useTokenPath {
clusters = append(clusters, &envoy_cluster_v3.Cluster{
Name: "ads_cluster",
ConnectTimeout: util_proto.Duration(parameters.XdsConnectTimeout),
Http2ProtocolOptions: &envoy_core_v3.Http2ProtocolOptions{},
LbPolicy: envoy_cluster_v3.Cluster_ROUND_ROBIN,
adsCluster := &envoy_cluster_v3.Cluster{
Name: "ads_cluster",
ConnectTimeout: util_proto.Duration(parameters.XdsConnectTimeout),
LbPolicy: envoy_cluster_v3.Cluster_ROUND_ROBIN,
UpstreamConnectionOptions: &envoy_cluster_v3.UpstreamConnectionOptions{
TcpKeepalive: &envoy_core_v3.TcpKeepalive{
KeepaliveProbes: util_proto.UInt32(3),
Expand Down Expand Up @@ -372,7 +380,12 @@ func buildStaticClusters(parameters configParameters, useTokenPath bool) []*envo
},
},
},
})
}
if err := (&clusters_v3.Http2Configurer{}).Configure(adsCluster); err != nil {
return nil, err
}

clusters = append(clusters, adsCluster)
}
return clusters
return clusters, nil
}
12 changes: 10 additions & 2 deletions pkg/xds/bootstrap/testdata/bootstrap.k8s.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ node:
staticResources:
clusters:
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -62,13 +61,17 @@ staticResources:
path: /tmp/kuma-al-dp-1.default-default.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -90,6 +93,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
12 changes: 10 additions & 2 deletions pkg/xds/bootstrap/testdata/bootstrap.overridden.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ node:
staticResources:
clusters:
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -69,13 +68,17 @@ staticResources:
path: /tmp/kuma-al-dp-1.default-default.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -97,6 +100,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
12 changes: 10 additions & 2 deletions pkg/xds/bootstrap/testdata/bootstrap.universal.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ node:
staticResources:
clusters:
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -62,13 +61,17 @@ staticResources:
path: /tmp/kuma-al-dp-1-default.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -90,6 +93,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ node:
staticResources:
clusters:
- connectTimeout: 2s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -63,13 +62,17 @@ staticResources:
path: /tmp/kuma-al-name.namespace-mesh.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 2s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -91,6 +94,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
12 changes: 10 additions & 2 deletions pkg/xds/bootstrap/testdata/generator.custom-config.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ node:
staticResources:
clusters:
- connectTimeout: 2s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -96,13 +95,17 @@ staticResources:
path: /tmp/kuma-al-name.namespace-mesh.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 2s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -124,6 +127,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ node:
staticResources:
clusters:
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -56,13 +55,17 @@ staticResources:
path: /tmp/kuma-al-name.namespace-mesh.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
keepaliveProbes: 3
keepaliveTime: 10
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: ads_cluster
endpoints:
Expand All @@ -84,6 +87,11 @@ staticResources:
name: cp_validation_ctx
sni: localhost
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ node:
staticResources:
clusters:
- connectTimeout: 1s
http2ProtocolOptions: {}
loadAssignment:
clusterName: access_log_sink
endpoints:
Expand All @@ -91,6 +90,11 @@ staticResources:
path: /tmp/kuma-al-name.namespace-mesh.sock
name: access_log_sink
type: STATIC
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
upstreamConnectionOptions:
tcpKeepalive:
keepaliveInterval: 10
Expand Down
Loading

0 comments on commit 9d5029e

Please sign in to comment.