Skip to content

Commit

Permalink
Merge pull request #7567 from towca/jtuznik/handle-fix
Browse files Browse the repository at this point in the history
CA: Fix a data race in framework.NewHandle
  • Loading branch information
k8s-ci-robot authored Dec 6, 2024
2 parents 4d092e5 + 16983d2 commit c88f72f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cluster-autoscaler/simulator/framework/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package framework
import (
"context"
"fmt"
"sync"

"k8s.io/client-go/informers"
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
Expand All @@ -29,6 +30,10 @@ import (
schedulermetrics "k8s.io/kubernetes/pkg/scheduler/metrics"
)

var (
initMetricsOnce sync.Once
)

// Handle is meant for interacting with the scheduler framework.
type Handle struct {
Framework schedulerframework.Framework
Expand All @@ -50,7 +55,9 @@ func NewHandle(informerFactory informers.SharedInformerFactory, schedConfig *sch
}
sharedLister := NewDelegatingSchedulerSharedLister()

schedulermetrics.InitMetrics()
initMetricsOnce.Do(func() {
schedulermetrics.InitMetrics()
})
framework, err := schedulerframeworkruntime.NewFramework(
context.TODO(),
schedulerplugins.NewInTreeRegistry(),
Expand Down

0 comments on commit c88f72f

Please sign in to comment.