mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Remove the deprecated metrics from scheduler
Deprecated metrics are removed and suggest to use the Histogram metrics got from scheduler extension points. Signed-off-by: Dave Chen <dave.chen@arm.com> Co-authored-by: wawa0210 <xiaozhang0210@hotmail.com>
This commit is contained in:
		@@ -23,7 +23,6 @@ import (
 | 
				
			|||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"sort"
 | 
						"sort"
 | 
				
			||||||
	"sync/atomic"
 | 
						"sync/atomic"
 | 
				
			||||||
	"time"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/klog/v2"
 | 
						"k8s.io/klog/v2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -89,10 +88,8 @@ func New(dpArgs runtime.Object, fh framework.Handle) (framework.Plugin, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// PostFilter invoked at the postFilter extension point.
 | 
					// PostFilter invoked at the postFilter extension point.
 | 
				
			||||||
func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.CycleState, pod *v1.Pod, m framework.NodeToStatusMap) (*framework.PostFilterResult, *framework.Status) {
 | 
					func (pl *DefaultPreemption) PostFilter(ctx context.Context, state *framework.CycleState, pod *v1.Pod, m framework.NodeToStatusMap) (*framework.PostFilterResult, *framework.Status) {
 | 
				
			||||||
	preemptionStartTime := time.Now()
 | 
					 | 
				
			||||||
	defer func() {
 | 
						defer func() {
 | 
				
			||||||
		metrics.PreemptionAttempts.Inc()
 | 
							metrics.PreemptionAttempts.Inc()
 | 
				
			||||||
		metrics.DeprecatedSchedulingAlgorithmPreemptionEvaluationDuration.Observe(metrics.SinceInSeconds(preemptionStartTime))
 | 
					 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nnn, err := pl.preempt(ctx, state, pod, m)
 | 
						nnn, err := pl.preempt(ctx, state, pod, m)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,26 +67,6 @@ var (
 | 
				
			|||||||
			StabilityLevel: metrics.ALPHA,
 | 
								StabilityLevel: metrics.ALPHA,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	DeprecatedSchedulingAlgorithmPreemptionEvaluationDuration = metrics.NewHistogram(
 | 
					 | 
				
			||||||
		&metrics.HistogramOpts{
 | 
					 | 
				
			||||||
			Subsystem:         SchedulerSubsystem,
 | 
					 | 
				
			||||||
			Name:              "scheduling_algorithm_preemption_evaluation_seconds",
 | 
					 | 
				
			||||||
			Help:              "Scheduling algorithm preemption evaluation duration in seconds",
 | 
					 | 
				
			||||||
			Buckets:           metrics.ExponentialBuckets(0.001, 2, 15),
 | 
					 | 
				
			||||||
			StabilityLevel:    metrics.ALPHA,
 | 
					 | 
				
			||||||
			DeprecatedVersion: "1.20.0",
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
	DeprecatedBindingLatency = metrics.NewHistogram(
 | 
					 | 
				
			||||||
		&metrics.HistogramOpts{
 | 
					 | 
				
			||||||
			Subsystem:         SchedulerSubsystem,
 | 
					 | 
				
			||||||
			Name:              "binding_duration_seconds",
 | 
					 | 
				
			||||||
			Help:              "Binding latency in seconds",
 | 
					 | 
				
			||||||
			Buckets:           metrics.ExponentialBuckets(0.001, 2, 15),
 | 
					 | 
				
			||||||
			StabilityLevel:    metrics.ALPHA,
 | 
					 | 
				
			||||||
			DeprecatedVersion: "1.20.0",
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
	PreemptionVictims = metrics.NewHistogram(
 | 
						PreemptionVictims = metrics.NewHistogram(
 | 
				
			||||||
		&metrics.HistogramOpts{
 | 
							&metrics.HistogramOpts{
 | 
				
			||||||
			Subsystem: SchedulerSubsystem,
 | 
								Subsystem: SchedulerSubsystem,
 | 
				
			||||||
@@ -191,8 +171,6 @@ var (
 | 
				
			|||||||
		scheduleAttempts,
 | 
							scheduleAttempts,
 | 
				
			||||||
		e2eSchedulingLatency,
 | 
							e2eSchedulingLatency,
 | 
				
			||||||
		SchedulingAlgorithmLatency,
 | 
							SchedulingAlgorithmLatency,
 | 
				
			||||||
		DeprecatedBindingLatency,
 | 
					 | 
				
			||||||
		DeprecatedSchedulingAlgorithmPreemptionEvaluationDuration,
 | 
					 | 
				
			||||||
		PreemptionVictims,
 | 
							PreemptionVictims,
 | 
				
			||||||
		PreemptionAttempts,
 | 
							PreemptionAttempts,
 | 
				
			||||||
		pendingPods,
 | 
							pendingPods,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -379,9 +379,8 @@ func (sched *Scheduler) assume(assumed *v1.Pod, host string) error {
 | 
				
			|||||||
// The precedence for binding is: (1) extenders and (2) framework plugins.
 | 
					// The precedence for binding is: (1) extenders and (2) framework plugins.
 | 
				
			||||||
// We expect this to run asynchronously, so we handle binding metrics internally.
 | 
					// We expect this to run asynchronously, so we handle binding metrics internally.
 | 
				
			||||||
func (sched *Scheduler) bind(ctx context.Context, fwk framework.Framework, assumed *v1.Pod, targetNode string, state *framework.CycleState) (err error) {
 | 
					func (sched *Scheduler) bind(ctx context.Context, fwk framework.Framework, assumed *v1.Pod, targetNode string, state *framework.CycleState) (err error) {
 | 
				
			||||||
	start := time.Now()
 | 
					 | 
				
			||||||
	defer func() {
 | 
						defer func() {
 | 
				
			||||||
		sched.finishBinding(fwk, assumed, targetNode, start, err)
 | 
							sched.finishBinding(fwk, assumed, targetNode, err)
 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bound, err := sched.extendersBinding(assumed, targetNode)
 | 
						bound, err := sched.extendersBinding(assumed, targetNode)
 | 
				
			||||||
@@ -412,7 +411,7 @@ func (sched *Scheduler) extendersBinding(pod *v1.Pod, node string) (bool, error)
 | 
				
			|||||||
	return false, nil
 | 
						return false, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (sched *Scheduler) finishBinding(fwk framework.Framework, assumed *v1.Pod, targetNode string, start time.Time, err error) {
 | 
					func (sched *Scheduler) finishBinding(fwk framework.Framework, assumed *v1.Pod, targetNode string, err error) {
 | 
				
			||||||
	if finErr := sched.SchedulerCache.FinishBinding(assumed); finErr != nil {
 | 
						if finErr := sched.SchedulerCache.FinishBinding(assumed); finErr != nil {
 | 
				
			||||||
		klog.Errorf("scheduler cache FinishBinding failed: %v", finErr)
 | 
							klog.Errorf("scheduler cache FinishBinding failed: %v", finErr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -421,7 +420,6 @@ func (sched *Scheduler) finishBinding(fwk framework.Framework, assumed *v1.Pod,
 | 
				
			|||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	metrics.DeprecatedBindingLatency.Observe(metrics.SinceInSeconds(start))
 | 
					 | 
				
			||||||
	fwk.EventRecorder().Eventf(assumed, nil, v1.EventTypeNormal, "Scheduled", "Binding", "Successfully assigned %v/%v to %v", assumed.Namespace, assumed.Name, targetNode)
 | 
						fwk.EventRecorder().Eventf(assumed, nil, v1.EventTypeNormal, "Scheduled", "Binding", "Successfully assigned %v/%v to %v", assumed.Namespace, assumed.Name, targetNode)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,9 +51,7 @@ var (
 | 
				
			|||||||
		Metrics: []string{
 | 
							Metrics: []string{
 | 
				
			||||||
			"scheduler_scheduling_algorithm_predicate_evaluation_seconds",
 | 
								"scheduler_scheduling_algorithm_predicate_evaluation_seconds",
 | 
				
			||||||
			"scheduler_scheduling_algorithm_priority_evaluation_seconds",
 | 
								"scheduler_scheduling_algorithm_priority_evaluation_seconds",
 | 
				
			||||||
			"scheduler_binding_duration_seconds",
 | 
					 | 
				
			||||||
			"scheduler_e2e_scheduling_duration_seconds",
 | 
								"scheduler_e2e_scheduling_duration_seconds",
 | 
				
			||||||
			"scheduler_scheduling_algorithm_preemption_evaluation_seconds",
 | 
					 | 
				
			||||||
			"scheduler_pod_scheduling_duration_seconds",
 | 
								"scheduler_pod_scheduling_duration_seconds",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user