Merge pull request #116583 from likakuli/fix-schedulerexiterr

feat: ignore queue close error log when scheduler exit
This commit is contained in:
Kubernetes Prow Robot 2023-05-30 22:43:44 -07:00 committed by GitHub
commit cc131a6c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -59,9 +59,6 @@ const (
// backoffQ or activeQ. If this value is empty, the default value (5min)
// will be used.
DefaultPodMaxInUnschedulablePodsDuration time.Duration = 5 * time.Minute
queueClosed = "scheduling queue is closed"
// Scheduling queue names
activeQName = "Active"
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,
// which causes this loop to continue and return from the Pop().
if p.closed {
return nil, fmt.Errorf(queueClosed)
klog.V(2).InfoS("Scheduling queue is closed")
return nil, nil
}
p.cond.Wait()
}
@ -1130,14 +1128,15 @@ func newPodNominator(podLister listersv1.PodLister) *nominator {
func MakeNextPodFunc(logger klog.Logger, queue SchedulingQueue) func() *framework.QueuedPodInfo {
return func() *framework.QueuedPodInfo {
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))
for plugin := range podInfo.UnschedulablePlugins {
metrics.UnschedulableReason(plugin, podInfo.Pod.Spec.SchedulerName).Dec()
}
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
}
}

View File

@ -1100,14 +1100,13 @@ func TestSchedulingQueue_Close(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
q := NewTestQueue(ctx, newDefaultQueueSort())
wantErr := fmt.Errorf(queueClosed)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
pod, err := q.Pop()
if err.Error() != wantErr.Error() {
t.Errorf("Expected err %q from Pop() if queue is closed, but got %q", wantErr.Error(), err.Error())
if err != nil {
t.Errorf("Expected nil err from Pop() if queue is closed, but got %q", err.Error())
}
if pod != nil {
t.Errorf("Expected pod nil from Pop() if queue is closed, but got: %v", pod)