Merge pull request #116583 from likakuli/fix-schedulerexiterr
feat: ignore queue close error log when scheduler exit
This commit is contained in:
		@@ -59,9 +59,6 @@ const (
 | 
				
			|||||||
	// backoffQ or activeQ. If this value is empty, the default value (5min)
 | 
						// backoffQ or activeQ. If this value is empty, the default value (5min)
 | 
				
			||||||
	// will be used.
 | 
						// will be used.
 | 
				
			||||||
	DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute
 | 
						DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute
 | 
				
			||||||
 | 
					 | 
				
			||||||
	queueClosed = "scheduling queue is closed"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Scheduling queue names
 | 
						// Scheduling queue names
 | 
				
			||||||
	activeQName       = "Active"
 | 
						activeQName       = "Active"
 | 
				
			||||||
	backoffQName      = "Backoff"
 | 
						backoffQName      = "Backoff"
 | 
				
			||||||
@@ -601,7 +598,8 @@ func (p *PriorityQueue) Pop() (*framework.QueuedPodInfo, error) {
 | 
				
			|||||||
		// When Close() is called, the p.closed is set and the condition is broadcast,
 | 
							// When Close() is called, the p.closed is set and the condition is broadcast,
 | 
				
			||||||
		// which causes this loop to continue and return from the Pop().
 | 
							// which causes this loop to continue and return from the Pop().
 | 
				
			||||||
		if p.closed {
 | 
							if p.closed {
 | 
				
			||||||
			return nil, fmt.Errorf(queueClosed)
 | 
								klog.V(2).InfoS("Scheduling queue is closed")
 | 
				
			||||||
 | 
								return nil, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		p.cond.Wait()
 | 
							p.cond.Wait()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -1130,14 +1128,15 @@ func newPodNominator(podLister listersv1.PodLister) *nominator {
 | 
				
			|||||||
func MakeNextPodFunc(logger klog.Logger, queue SchedulingQueue) func() *framework.QueuedPodInfo {
 | 
					func MakeNextPodFunc(logger klog.Logger, queue SchedulingQueue) func() *framework.QueuedPodInfo {
 | 
				
			||||||
	return func() *framework.QueuedPodInfo {
 | 
						return func() *framework.QueuedPodInfo {
 | 
				
			||||||
		podInfo, err := queue.Pop()
 | 
							podInfo, err := queue.Pop()
 | 
				
			||||||
		if err == nil {
 | 
							if err == nil && podInfo != nil {
 | 
				
			||||||
			logger.V(4).Info("About to try and schedule pod", "pod", klog.KObj(podInfo.Pod))
 | 
								logger.V(4).Info("About to try and schedule pod", "pod", klog.KObj(podInfo.Pod))
 | 
				
			||||||
			for plugin := range podInfo.UnschedulablePlugins {
 | 
								for plugin := range podInfo.UnschedulablePlugins {
 | 
				
			||||||
				metrics.UnschedulableReason(plugin, podInfo.Pod.Spec.SchedulerName).Dec()
 | 
									metrics.UnschedulableReason(plugin, podInfo.Pod.Spec.SchedulerName).Dec()
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return podInfo
 | 
								return podInfo
 | 
				
			||||||
 | 
							} else if err != nil {
 | 
				
			||||||
 | 
								logger.Error(err, "Error while retrieving next pod from scheduling queue")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		logger.Error(err, "Error while retrieving next pod from scheduling queue")
 | 
					 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1100,14 +1100,13 @@ func TestSchedulingQueue_Close(t *testing.T) {
 | 
				
			|||||||
	ctx, cancel := context.WithCancel(context.Background())
 | 
						ctx, cancel := context.WithCancel(context.Background())
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
	q := NewTestQueue(ctx, newDefaultQueueSort())
 | 
						q := NewTestQueue(ctx, newDefaultQueueSort())
 | 
				
			||||||
	wantErr := fmt.Errorf(queueClosed)
 | 
					 | 
				
			||||||
	wg := sync.WaitGroup{}
 | 
						wg := sync.WaitGroup{}
 | 
				
			||||||
	wg.Add(1)
 | 
						wg.Add(1)
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		defer wg.Done()
 | 
							defer wg.Done()
 | 
				
			||||||
		pod, err := q.Pop()
 | 
							pod, err := q.Pop()
 | 
				
			||||||
		if err.Error() != wantErr.Error() {
 | 
							if err != nil {
 | 
				
			||||||
			t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", wantErr.Error(), err.Error())
 | 
								t.Errorf("Expected nil err from Pop() if queue is closed, but got %q", err.Error())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if pod != nil {
 | 
							if pod != nil {
 | 
				
			||||||
			t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod)
 | 
								t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user