diff --git a/plugin/pkg/scheduler/metrics/metrics.go b/plugin/pkg/scheduler/metrics/metrics.go index 77bd64bfb32..db6258a31d9 100644 --- a/plugin/pkg/scheduler/metrics/metrics.go +++ b/plugin/pkg/scheduler/metrics/metrics.go @@ -25,6 +25,8 @@ import ( const schedulerSubsystem = "scheduler" +var BindingSaturationReportInterval = 1 * time.Second + var ( E2eSchedulingLatency = prometheus.NewSummary( prometheus.SummaryOpts{ @@ -50,6 +52,13 @@ var ( MaxAge: time.Hour, }, ) + BindingRateLimiterSaturation = prometheus.NewGauge( + prometheus.GaugeOpts{ + Subsystem: schedulerSubsystem, + Name: "binding_ratelimiter_saturation", + Help: "Binding rateLimiter's saturation rate in percentage", + }, + ) ) var registerMetrics sync.Once @@ -61,6 +70,7 @@ func Register() { prometheus.MustRegister(E2eSchedulingLatency) prometheus.MustRegister(SchedulingAlgorithmLatency) prometheus.MustRegister(BindingLatency) + prometheus.MustRegister(BindingRateLimiterSaturation) }) } diff --git a/plugin/pkg/scheduler/scheduler.go b/plugin/pkg/scheduler/scheduler.go index 2362f1eb0d6..cbfcbc8fd62 100644 --- a/plugin/pkg/scheduler/scheduler.go +++ b/plugin/pkg/scheduler/scheduler.go @@ -77,6 +77,7 @@ type Config struct { Binder Binder // Rate at which we can create pods + // If this field is nil, we don't have any rate limit. BindPodsRateLimiter util.RateLimiter // NextPod should be a function that blocks until the next pod @@ -107,6 +108,12 @@ func New(c *Config) *Scheduler { // Run begins watching and scheduling. It starts a goroutine and returns immediately. func (s *Scheduler) Run() { + if s.config.BindPodsRateLimiter != nil { + go util.Forever(func() { + sat := s.config.BindPodsRateLimiter.Saturation() + metrics.BindingRateLimiterSaturation.Set(sat) + }, metrics.BindingSaturationReportInterval) + } go util.Until(s.scheduleOne, 0, s.config.StopEverything) }