Skip to content

Commit

Permalink
clean: use info instead of error to log queue closed message when sch…
Browse files Browse the repository at this point in the history
…eduler exit

Signed-off-by: likakuli <[email protected]>
  • Loading branch information
likakuli committed May 31, 2023
1 parent a8ef109 commit 5a14573
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 5 additions & 6 deletions pkg/scheduler/internal/queue/scheduling_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
}
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/scheduler/internal/queue/scheduling_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5a14573

Please sign in to comment.