From 52ff7f8dc0c66880874318589a5cfc3b56843907 Mon Sep 17 00:00:00 2001 From: Kensei Nakada Date: Sat, 18 Nov 2023 19:04:47 +0900 Subject: [PATCH] fix(framework): elaborate the document on PostFilter --- pkg/scheduler/framework/interface.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pkg/scheduler/framework/interface.go b/pkg/scheduler/framework/interface.go index 409b6b95a42..49230be7117 100644 --- a/pkg/scheduler/framework/interface.go +++ b/pkg/scheduler/framework/interface.go @@ -95,12 +95,13 @@ const ( Unschedulable // UnschedulableAndUnresolvable is used when a plugin finds a pod unschedulable and // other postFilter plugins like preemption would not change anything. + // See the comment on PostFilter interface for more details about how PostFilter should handle this status. // Plugins should return Unschedulable if it is possible that the pod can get scheduled // after running other postFilter plugins. // The accompanying status message should explain why the pod is unschedulable. // // We regard the backoff as a penalty of wasting the scheduling cycle. - // When the scheduling queue requeues Pods, which was rejected with Unschedulable in the last scheduling, + // When the scheduling queue requeues Pods, which was rejected with UnschedulableAndUnresolvable in the last scheduling, // the Pod goes through backoff. UnschedulableAndUnresolvable // Wait is used when a Permit plugin finds a pod scheduling should wait. @@ -423,7 +424,17 @@ type FilterPlugin interface { // after a pod cannot be scheduled. type PostFilterPlugin interface { Plugin - // PostFilter is called by the scheduling framework. + // PostFilter is called by the scheduling framework + // when the scheduling cycle failed at PreFilter or Filter by Unschedulable or UnschedulableAndUnresolvable. + // NodeToStatusMap has statuses that each Node got in the Filter phase. + // If this scheduling cycle failed at PreFilter, all Nodes have the status from the rejector PreFilter plugin in NodeToStatusMap. + // Note that the scheduling framework runs PostFilter plugins even when PreFilter returned UnschedulableAndUnresolvable. + // In that case, NodeToStatusMap contains all Nodes with UnschedulableAndUnresolvable. + // + // Also, ignoring Nodes with UnschedulableAndUnresolvable is the responsibility of each PostFilter plugin, + // meaning NodeToStatusMap obviously could have Nodes with UnschedulableAndUnresolvable + // and the scheduling framework does call PostFilter even when all Nodes in NodeToStatusMap are UnschedulableAndUnresolvable. + // // A PostFilter plugin should return one of the following statuses: // - Unschedulable: the plugin gets executed successfully but the pod cannot be made schedulable. // - Success: the plugin gets executed successfully and the pod can be made schedulable.