Distinguish unschedulable with unresolvable in scheduler
Before, in RunPostFilterPlugins, we didn't distinguish between unschedulable and unresolvable because we only have one postFilterPlugin by default, now, we have at least two, we should make sure that once a postFilterPlugin returns unresolvable, we'll return directly Signed-off-by: Kante Yin <kerthcet@gmail.com>
This commit is contained in:
@@ -79,13 +79,14 @@ const (
|
||||
// Error is used for internal plugin errors, unexpected input, etc.
|
||||
Error
|
||||
// Unschedulable is used when a plugin finds a pod unschedulable. The scheduler might attempt to
|
||||
// preempt other pods to get this pod scheduled. Use UnschedulableAndUnresolvable to make the
|
||||
// scheduler skip preemption.
|
||||
// run other postFilter plugins like preemption to get this pod scheduled.
|
||||
// Use UnschedulableAndUnresolvable to make the scheduler skipping other postFilter plugins.
|
||||
// The accompanying status message should explain why the pod is unschedulable.
|
||||
Unschedulable
|
||||
// UnschedulableAndUnresolvable is used when a plugin finds a pod unschedulable and
|
||||
// preemption would not change anything. Plugins should return Unschedulable if it is possible
|
||||
// that the pod can get scheduled with preemption.
|
||||
// other postFilter plugins like preemption would not change anything.
|
||||
// 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.
|
||||
UnschedulableAndUnresolvable
|
||||
// Wait is used when a Permit plugin finds a pod scheduling should wait.
|
||||
@@ -97,15 +98,6 @@ const (
|
||||
// This list should be exactly the same as the codes iota defined above in the same order.
|
||||
var codes = []string{"Success", "Error", "Unschedulable", "UnschedulableAndUnresolvable", "Wait", "Skip"}
|
||||
|
||||
// statusPrecedence defines a map from status to its precedence, larger value means higher precedent.
|
||||
var statusPrecedence = map[Code]int{
|
||||
Error: 3,
|
||||
UnschedulableAndUnresolvable: 2,
|
||||
Unschedulable: 1,
|
||||
// Any other statuses we know today, `Skip` or `Wait`, will take precedence over `Success`.
|
||||
Success: -1,
|
||||
}
|
||||
|
||||
func (c Code) String() string {
|
||||
return codes[c]
|
||||
}
|
||||
@@ -255,7 +247,10 @@ func (s *Status) Equal(x *Status) bool {
|
||||
if !cmp.Equal(s.err, x.err, cmpopts.EquateErrors()) {
|
||||
return false
|
||||
}
|
||||
return cmp.Equal(s.reasons, x.reasons)
|
||||
if !cmp.Equal(s.reasons, x.reasons) {
|
||||
return false
|
||||
}
|
||||
return cmp.Equal(s.failedPlugin, x.failedPlugin)
|
||||
}
|
||||
|
||||
// NewStatus makes a Status out of the given arguments and returns its pointer.
|
||||
@@ -278,36 +273,6 @@ func AsStatus(err error) *Status {
|
||||
}
|
||||
}
|
||||
|
||||
// PluginToStatus maps plugin name to status it returned.
|
||||
type PluginToStatus map[string]*Status
|
||||
|
||||
// Merge merges the statuses in the map into one. The resulting status code have the following
|
||||
// precedence: Error, UnschedulableAndUnresolvable, Unschedulable.
|
||||
func (p PluginToStatus) Merge() *Status {
|
||||
if len(p) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
finalStatus := NewStatus(Success)
|
||||
for _, s := range p {
|
||||
if statusPrecedence[s.Code()] > statusPrecedence[finalStatus.code] {
|
||||
finalStatus.code = s.Code()
|
||||
// Same as code, we keep the most relevant failedPlugin in the returned Status.
|
||||
finalStatus.failedPlugin = s.FailedPlugin()
|
||||
}
|
||||
|
||||
reasons := s.Reasons()
|
||||
if finalStatus.err == nil {
|
||||
finalStatus.err = s.err
|
||||
reasons = s.reasons
|
||||
}
|
||||
for _, r := range reasons {
|
||||
finalStatus.AppendReason(r)
|
||||
}
|
||||
}
|
||||
return finalStatus
|
||||
}
|
||||
|
||||
// WaitingPod represents a pod currently waiting in the permit phase.
|
||||
type WaitingPod interface {
|
||||
// GetPod returns a reference to the waiting pod.
|
||||
|
Reference in New Issue
Block a user