@@ -133,7 +133,7 @@ func (sched *Scheduler) addPodToSchedulingQueue(obj interface{}) {
133
133
134
134
func (sched * Scheduler ) updatePodInSchedulingQueue (oldObj , newObj interface {}) {
135
135
start := time .Now ()
136
- defer metrics . EventHandlingLatency . WithLabelValues ( framework . UnscheduledPodUpdate . Label ). Observe ( metrics . SinceInSeconds ( start ))
136
+
137
137
logger := sched .logger
138
138
oldPod , newPod := oldObj .(* v1.Pod ), newObj .(* v1.Pod )
139
139
// Bypass update event that carries identical objects; otherwise, a duplicated
@@ -142,6 +142,13 @@ func (sched *Scheduler) updatePodInSchedulingQueue(oldObj, newObj interface{}) {
142
142
return
143
143
}
144
144
145
+ defer metrics .EventHandlingLatency .WithLabelValues (framework .UnscheduledPodUpdate .Label ).Observe (metrics .SinceInSeconds (start ))
146
+ for _ , evt := range framework .PodSchedulingPropertiesChange (newPod , oldPod ) {
147
+ if evt .Label != framework .UnscheduledPodUpdate .Label {
148
+ defer metrics .EventHandlingLatency .WithLabelValues (evt .Label ).Observe (metrics .SinceInSeconds (start ))
149
+ }
150
+ }
151
+
145
152
isAssumed , err := sched .Cache .IsAssumedPod (newPod )
146
153
if err != nil {
147
154
utilruntime .HandleError (fmt .Errorf ("failed to check whether pod %s/%s is assumed: %v" , newPod .Namespace , newPod .Name , err ))
@@ -246,7 +253,12 @@ func (sched *Scheduler) updatePodInCache(oldObj, newObj interface{}) {
246
253
}
247
254
248
255
events := framework .PodSchedulingPropertiesChange (newPod , oldPod )
256
+
257
+ // Save the time it takes to update the pod in the cache.
258
+ updatingDuration := metrics .SinceInSeconds (start )
259
+
249
260
for _ , evt := range events {
261
+ startMoving := time .Now ()
250
262
// SchedulingQueue.AssignedPodUpdated has a problem:
251
263
// It internally pre-filters Pods to move to activeQ,
252
264
// while taking only in-tree plugins into consideration.
@@ -257,10 +269,12 @@ func (sched *Scheduler) updatePodInCache(oldObj, newObj interface{}) {
257
269
// Here we use MoveAllToActiveOrBackoffQueue only when QueueingHint is enabled.
258
270
// (We cannot switch to MoveAllToActiveOrBackoffQueue right away because of throughput concern.)
259
271
if utilfeature .DefaultFeatureGate .Enabled (features .SchedulerQueueingHints ) {
260
- sched .SchedulingQueue .MoveAllToActiveOrBackoffQueue (logger , framework . AssignedPodUpdate , oldPod , newPod , nil )
272
+ sched .SchedulingQueue .MoveAllToActiveOrBackoffQueue (logger , evt , oldPod , newPod , nil )
261
273
} else {
262
274
sched .SchedulingQueue .AssignedPodUpdated (logger , oldPod , newPod , evt )
263
275
}
276
+ movingDuration := metrics .SinceInSeconds (startMoving )
277
+ metrics .EventHandlingLatency .WithLabelValues (evt .Label ).Observe (updatingDuration + movingDuration )
264
278
}
265
279
}
266
280
0 commit comments