From 5e6177897dc6c9f9ee056155a7080dba8e44426b Mon Sep 17 00:00:00 2001 From: jindezgm <51435987+jindezgm@users.noreply.github.com> Date: Mon, 14 Dec 2020 22:39:08 +0800 Subject: [PATCH 1/2] Refresh Timestamp when pod is not present in the three sub-queues The pInfo.Timestamp is refreshed but the sort in activeQ or podBackoffQ is not be updated when pod is already present in the backoff or active queue. AddUnschedulableIfNotPresent() return error if pod is already present in the backoff or active queue, and there is no re-add. So refresh pInfo.Timestamp when the pod is not present in the three sub-queues, otherwise need to update the order of the pod in the active or backoff queue, for example p.activeQ.Update(pInfo) --- pkg/scheduler/internal/queue/scheduling_queue.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index 56504cf77b5..65c7b757159 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -302,14 +302,15 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI return fmt.Errorf("pod: %v is already present in unschedulable queue", nsNameForPod(pod)) } - // Refresh the timestamp since the pod is re-added. - pInfo.Timestamp = p.clock.Now() if _, exists, _ := p.activeQ.Get(pInfo); exists { return fmt.Errorf("pod: %v is already present in the active queue", nsNameForPod(pod)) } if _, exists, _ := p.podBackoffQ.Get(pInfo); exists { return fmt.Errorf("pod %v is already present in the backoff queue", nsNameForPod(pod)) } + + // Refresh the timestamp since the pod is re-added. + pInfo.Timestamp = p.clock.Now() // If a move request has been received, move it to the BackoffQ, otherwise move // it to unschedulableQ. From 17b084938aaf7fe3d0e0b7b8c07242976474218f Mon Sep 17 00:00:00 2001 From: "jinde.zgm" <51435987+jindezgm@users.noreply.github.com> Date: Tue, 15 Dec 2020 20:07:47 +0800 Subject: [PATCH 2/2] fix gofmt bug --- pkg/scheduler/internal/queue/scheduling_queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scheduler/internal/queue/scheduling_queue.go b/pkg/scheduler/internal/queue/scheduling_queue.go index 65c7b757159..4050392eb76 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue.go +++ b/pkg/scheduler/internal/queue/scheduling_queue.go @@ -308,7 +308,7 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI if _, exists, _ := p.podBackoffQ.Get(pInfo); exists { return fmt.Errorf("pod %v is already present in the backoff queue", nsNameForPod(pod)) } - + // Refresh the timestamp since the pod is re-added. pInfo.Timestamp = p.clock.Now()