Skip to content

Commit 7ac8bd6

Browse files
committed
Minor nits
1 parent 065cf6d commit 7ac8bd6

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

cmd/cni-metrics-helper/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func main() {
9797

9898
cwENV, found := os.LookupEnv("USE_CLOUDWATCH")
9999
if found {
100+
cwENV = strings.ToLower(cwENV)
100101
if strings.Compare(cwENV, "yes") == 0 || strings.Compare(cwENV, "true") == 0 {
101102
options.submitCW = true
102103
}
@@ -107,6 +108,7 @@ func main() {
107108

108109
prometheusENV, found := os.LookupEnv(envEnablePrometheusMetrics)
109110
if found {
111+
prometheusENV = strings.ToLower(prometheusENV)
110112
if strings.Compare(prometheusENV, "yes") == 0 || strings.Compare(prometheusENV, "true") == 0 {
111113
options.submitPrometheus = true
112114
prometheusRegister()

cmd/cni-metrics-helper/metrics/metrics.go

+21-27
Original file line numberDiff line numberDiff line change
@@ -322,36 +322,28 @@ func produceCloudWatchMetrics(t metricsTarget, families map[string]*dto.MetricFa
322322
for _, action := range convertMetrics.actions {
323323
switch metricType {
324324
case dto.MetricType_COUNTER:
325-
if t.submitCloudWatch() {
326-
dataPoint := &cloudwatch.MetricDatum{
327-
MetricName: aws.String(action.cwMetricName),
328-
Unit: aws.String(cloudwatch.StandardUnitCount),
329-
Value: aws.Float64(action.data.curSingleDataPoint),
330-
}
331-
cw.Publish(dataPoint)
325+
dataPoint := &cloudwatch.MetricDatum{
326+
MetricName: aws.String(action.cwMetricName),
327+
Unit: aws.String(cloudwatch.StandardUnitCount),
328+
Value: aws.Float64(action.data.curSingleDataPoint),
332329
}
330+
cw.Publish(dataPoint)
333331
case dto.MetricType_GAUGE:
334-
if t.submitCloudWatch() {
335-
dataPoint := &cloudwatch.MetricDatum{
336-
MetricName: aws.String(action.cwMetricName),
337-
Unit: aws.String(cloudwatch.StandardUnitCount),
338-
Value: aws.Float64(action.data.curSingleDataPoint),
339-
}
340-
cw.Publish(dataPoint)
332+
dataPoint := &cloudwatch.MetricDatum{
333+
MetricName: aws.String(action.cwMetricName),
334+
Unit: aws.String(cloudwatch.StandardUnitCount),
335+
Value: aws.Float64(action.data.curSingleDataPoint),
341336
}
337+
cw.Publish(dataPoint)
342338
case dto.MetricType_SUMMARY:
343-
if t.submitCloudWatch() {
344-
dataPoint := &cloudwatch.MetricDatum{
345-
MetricName: aws.String(action.cwMetricName),
346-
Unit: aws.String(cloudwatch.StandardUnitCount),
347-
Value: aws.Float64(action.data.curSingleDataPoint),
348-
}
349-
cw.Publish(dataPoint)
339+
dataPoint := &cloudwatch.MetricDatum{
340+
MetricName: aws.String(action.cwMetricName),
341+
Unit: aws.String(cloudwatch.StandardUnitCount),
342+
Value: aws.Float64(action.data.curSingleDataPoint),
350343
}
344+
cw.Publish(dataPoint)
351345
case dto.MetricType_HISTOGRAM:
352-
if t.submitCloudWatch() {
353-
produceHistogram(action, cw)
354-
}
346+
produceHistogram(action, cw)
355347
}
356348
}
357349
}
@@ -378,7 +370,6 @@ func producePrometheusMetrics(t metricsTarget, families map[string]*dto.MetricFa
378370
}
379371
}
380372
}
381-
382373
}
383374

384375
func resetMetrics(interestingMetrics map[string]metricsConvert) {
@@ -451,8 +442,11 @@ func Handler(ctx context.Context, t metricsTarget) {
451442
t.getLogger().Infof("Skipping 1st poll after reset, error: %v", err)
452443
}
453444

454-
cw := t.getCWMetricsPublisher()
455-
produceCloudWatchMetrics(t, families, interestingMetrics, cw)
445+
if t.submitCloudWatch() {
446+
cw := t.getCWMetricsPublisher()
447+
produceCloudWatchMetrics(t, families, interestingMetrics, cw)
448+
}
449+
456450
if t.submitPrometheus() {
457451
producePrometheusMetrics(t, families, interestingMetrics)
458452
}

pkg/ipamd/introspect.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/aws/amazon-vpc-cni-k8s/pkg/k8sapi"
2727
"github.com/aws/amazon-vpc-cni-k8s/pkg/networkutils"
2828
"github.com/aws/amazon-vpc-cni-k8s/pkg/utils/retry"
29+
"github.com/aws/amazon-vpc-cni-k8s/utils"
2930
)
3031

3132
const (
@@ -199,7 +200,7 @@ func logErr(_ int, err error) {
199200

200201
// disableIntrospection returns true if we should disable the introspection
201202
func disableIntrospection() bool {
202-
return getEnvBoolWithDefault(envDisableIntrospection, false)
203+
return utils.GetBoolAsStringEnvVar(envDisableENIProvisioning, false)
203204
}
204205

205206
func getEnvBoolWithDefault(envName string, def bool) bool {

0 commit comments

Comments
 (0)