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

support stats compression #47997

Merged
merged 6 commits into from
Nov 27, 2023
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
13 changes: 13 additions & 0 deletions pkg/bootstrap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ const (
v2Suffix = ",component,istio"
)

var envoyWellKnownCompressorLibrary = sets.String{
"gzip": {},
"zstd": {},
"brotli": {},
}

// Config for creating a bootstrap file.
type Config struct {
*model.Node
Expand Down Expand Up @@ -274,6 +280,12 @@ func getStatsOptions(meta *model.BootstrapNodeMetadata) []option.Instance {
}
}

var compression string
// TODO: move annotation to api repo
if statsCompression, ok := meta.Annotations["sidecar.istio.io/statsCompression"]; ok && envoyWellKnownCompressorLibrary.Contains(statsCompression) {
compression = statsCompression
}

return []option.Instance{
option.EnvoyStatsMatcherInclusionPrefix(parseOption(prefixAnno,
requiredEnvoyStatsMatcherInclusionPrefixes, proxyConfigPrefixes)),
Expand All @@ -282,6 +294,7 @@ func getStatsOptions(meta *model.BootstrapNodeMetadata) []option.Instance {
option.EnvoyStatsMatcherInclusionRegexp(parseOption(RegexAnno, requiredEnvoyStatsMatcherInclusionRegexes, proxyConfigRegexps)),
option.EnvoyExtraStatTags(extraStatTags),
option.EnvoyHistogramBuckets(buckets),
option.EnvoyStatsCompression(compression),
}
}

Expand Down
24 changes: 24 additions & 0 deletions pkg/bootstrap/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,30 @@ func TestGolden(t *testing.T) {
"ISTIO_META_LOAD_STATS_CONFIG_JSON": `{"api_type": "GRPC", "transport_api_version": "V3"}`,
},
},
{
base: "stats_compression_gzip",
annotations: map[string]string{
"sidecar.istio.io/statsCompression": "gzip",
},
},
{
base: "stats_compression_brotli",
annotations: map[string]string{
"sidecar.istio.io/statsCompression": "brotli",
},
},
{
base: "stats_compression_zstd",
annotations: map[string]string{
"sidecar.istio.io/statsCompression": "zstd",
},
},
{
base: "stats_compression_unknown",
annotations: map[string]string{
"sidecar.istio.io/statsCompression": "unknown",
},
},
}

test.SetForTest(t, &version.Info.Version, "binary-1.0")
Expand Down
4 changes: 4 additions & 0 deletions pkg/bootstrap/option/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,7 @@ type HistogramBucket struct {
func EnvoyHistogramBuckets(value []HistogramBucket) Instance {
return newOption("histogram_buckets", value)
}

func EnvoyStatsCompression(value string) Instance {
return newOption("stats_compression", value)
}
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/all_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/auth_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/authsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/default_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/lrs_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/metrics_no_statsd_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/running_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
3 changes: 2 additions & 1 deletion pkg/bootstrap/testdata/runningsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@
}
]
},
"http_filters": [{
"http_filters": [
{
"name": "envoy.filters.http.router",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
Expand Down
14 changes: 14 additions & 0 deletions pkg/bootstrap/testdata/stats_compression_brotli.proxycfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
config_path: "/etc/istio/proxy"
binary_path: "/usr/local/bin/envoy"
service_cluster: "istio-proxy"
drain_duration: {seconds: 5}
discovery_address: "mypilot:15011"
statsd_udp_address: "10.1.1.1:9125"
envoy_metrics_service: {address: "metrics-service:15000", tls_settings: { mode: MUTUAL, client_certificate: "/etc/istio/ms/client.pem", private_key: "/etc/istio/ms/key.pem", ca_certificates: "/etc/istio/ms/ca.pem"}}
envoy_access_log_service: {address: "accesslog-service:15000"}
proxy_admin_port: 15005
control_plane_auth_policy: MUTUAL_TLS
stat_name_length: 200
tracing: { zipkin: { address: "localhost:6000" } }

# Sets all relevant options to values different than default
Loading