Skip to content

Commit

Permalink
Merge pull request #1898 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1895-to-release-1.15

[release-1.15] [metrics] Fix panic during metrics manager startup
  • Loading branch information
k8s-ci-robot authored Jan 6, 2025
2 parents 0a13c0b + 17b7dc0 commit 8dba0a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ const (
)

var (
gkeComponentVersion *metrics.GaugeVec
pdcsiOperationErrorsMetric *metrics.CounterVec
)

func initMetrics() {
// This metric is exposed only from the controller driver component when GKE_PDCSI_VERSION env variable is set.
gkeComponentVersion = metrics.NewGaugeVec(&metrics.GaugeOpts{
Name: "component_version",
Expand All @@ -58,7 +53,7 @@ func initMetrics() {
StabilityLevel: metrics.ALPHA,
},
[]string{"driver_name", "method_name", "grpc_status_code", "disk_type", "enable_confidential_storage", "enable_storage_pools"})
}
)

type MetricsManager struct {
registry metrics.KubeRegistry
Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/metrics_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ package metrics
// Test-only method used for resetting metric counts.
func (mm *MetricsManager) ResetMetrics() {
// Re-initialize metrics
initMetrics()
gkeComponentVersion.Reset()
pdcsiOperationErrorsMetric.Reset()
}

0 comments on commit 8dba0a7

Please sign in to comment.