Skip to content

Commit

Permalink
add downstream_cx_active stats only when ExitOnZeroActiveConnections …
Browse files Browse the repository at this point in the history
…is used (istio#36081)

* enable downstream_cx_active stats only when ExitOnZeroActiveConnections is enabled

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>

* fix tests

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>

* ignore worker stats

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
  • Loading branch information
ramaraochavali committed Nov 15, 2021
1 parent acbe753 commit 0a5a486
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 53 deletions.
3 changes: 3 additions & 0 deletions pilot/pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ type NodeMetadata struct {
// Envoy prometheus port redirecting to admin port prometheus endpoint.
EnvoyPrometheusPort int `json:"ENVOY_PROMETHEUS_PORT,omitempty"`

// ExitOnZeroActiveConnections terminates Envoy if there are no active connections if set.
ExitOnZeroActiveConnections StringBool `json:"EXIT_ON_ZERO_ACTIVE_CONNECTIONS,omitempty"`

// Contains a copy of the raw metadata. This is needed to lookup arbitrary values.
// If a value is known ahead of time it should be added to the struct rather than reading from here,
Raw map[string]interface{} `json:"-"`
Expand Down
6 changes: 5 additions & 1 deletion pkg/bootstrap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,16 @@ func getStatsOptions(meta *model.BootstrapNodeMetadata) []option.Instance {
proxyConfigSuffixes = config.ProxyStatsMatcher.InclusionSuffixes
proxyConfigRegexps = config.ProxyStatsMatcher.InclusionRegexps
}
inclusionSuffixes := rbacEnvoyStatsMatcherInclusionSuffix
if meta.ExitOnZeroActiveConnections {
inclusionSuffixes = requiredEnvoyStatsMatcherInclusionSuffixes
}

return []option.Instance{
option.EnvoyStatsMatcherInclusionPrefix(parseOption(prefixAnno,
requiredEnvoyStatsMatcherInclusionPrefixes, proxyConfigPrefixes)),
option.EnvoyStatsMatcherInclusionSuffix(parseOption(suffixAnno,
requiredEnvoyStatsMatcherInclusionSuffixes, proxyConfigSuffixes)),
inclusionSuffixes, proxyConfigSuffixes)),
option.EnvoyStatsMatcherInclusionRegexp(parseOption(RegexAnno, "", proxyConfigRegexps)),
option.EnvoyExtraStatTags(extraStatTags),
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/bootstrap/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ func checkStatsMatcher(t *testing.T, got, want *bootstrap.Bootstrap, stats stats
stats.prefixes = v2Prefixes + stats.prefixes + "," + requiredEnvoyStatsMatcherInclusionPrefixes + v2Suffix
}
if stats.suffixes == "" {
stats.suffixes = requiredEnvoyStatsMatcherInclusionSuffixes
stats.suffixes = rbacEnvoyStatsMatcherInclusionSuffix
} else {
stats.suffixes += "," + requiredEnvoyStatsMatcherInclusionSuffixes
stats.suffixes += "," + rbacEnvoyStatsMatcherInclusionSuffix
}

if err := gsm.Validate(); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/all_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/auth_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/authsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/default_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/metrics_no_statsd_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/running_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/runningsds_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/stats_inclusion_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"safe_regex": {"google_re2":{}, "regex":"http.[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*_8080.downstream_rq_time"}
},
{
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_datadog_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_lightstep_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_opencensusagent_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_stackdriver_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_tls_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/tracing_zipkin_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
3 changes: 0 additions & 3 deletions pkg/bootstrap/testdata/xdsproxy_golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,6 @@
"suffix": "shadow_denied"
},
{
"suffix": "downstream_cx_active"
},
{
"prefix": "component"
}
]
Expand Down
5 changes: 3 additions & 2 deletions pkg/envoy/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ func (a *Agent) activeProxyConnections() int {
continue
}
// downstream_cx_active is accounted under "http." and "listener." for http listeners.
// Only consider listener stats.
if !strings.HasPrefix(parts[0], "listener.") {
// Only consider listener stats. Listener stats also will have per worker stats, we can
// ignore them.
if !strings.HasPrefix(parts[0], "listener.") || strings.Contains(parts[0], "worker_") {
continue
}
// If the stat is for a known Istio listener skip it.
Expand Down

0 comments on commit 0a5a486

Please sign in to comment.