Merge pull request #26501 from resouer/scheduler

Automatic merge from submit-queue

Add kubelet awareness to taint tolerant match caculator.

Add kubelet awareness to taint tolerant match caculator.

Ref: #25320

This is required by `TaintEffectNoScheduleNoAdmit` & `TaintEffectNoScheduleNoAdmitNoExecute `, so that node will know if it should expect the taint&tolerant
This commit is contained in:
Kubernetes Submit Queue
2016-10-07 12:05:35 -07:00
committed by GitHub
14 changed files with 295 additions and 37 deletions

View File

@@ -1083,23 +1083,37 @@ func PodToleratesNodeTaints(pod *api.Pod, meta interface{}, nodeInfo *schedulerc
return false, nil, err
}
if tolerationsToleratesTaints(tolerations, taints) {
if tolerated, someUntoleratedTaintIsNoAdmit := tolerationsToleratesTaints(tolerations, taints); tolerated {
return true, nil, nil
} else {
return false, []algorithm.PredicateFailureReason{newErrTaintsTolerationsNotMatch(someUntoleratedTaintIsNoAdmit)}, nil
}
return false, []algorithm.PredicateFailureReason{ErrTaintsTolerationsNotMatch}, nil
}
func tolerationsToleratesTaints(tolerations []api.Toleration, taints []api.Taint) bool {
// tolerationsToleratesTaints checks if given tolerations can live with given taints.
// It returns:
// 1. whether tolerated or not;
// 2. whether kubelet should be aware if it's unfit.
func tolerationsToleratesTaints(tolerations []api.Toleration, taints []api.Taint) (bool, bool) {
// If the taint list is nil/empty, it is tolerated by all tolerations by default.
if len(taints) == 0 {
return true
return true, false
}
// The taint list isn't nil/empty, a nil/empty toleration list can't tolerate them.
if len(tolerations) == 0 {
return false
// if there's taint has TaintEffectNoScheduleNoAdmit, kubelet should also be aware of this.
for _, taint := range taints {
if taint.Effect == api.TaintEffectNoScheduleNoAdmit {
return false, true
}
}
return false, false
}
someUntoleratedTaintIsNoAdmit := false
fits := true
for i := range taints {
taint := &taints[i]
// skip taints that have effect PreferNoSchedule, since it is for priorities
@@ -1107,12 +1121,16 @@ func tolerationsToleratesTaints(tolerations []api.Toleration, taints []api.Taint
continue
}
if !api.TaintToleratedByTolerations(taint, tolerations) {
return false
if tolerated := api.TaintToleratedByTolerations(taint, tolerations); !tolerated {
fits = false
if taint.Effect == api.TaintEffectNoScheduleNoAdmit {
someUntoleratedTaintIsNoAdmit = true
return fits, someUntoleratedTaintIsNoAdmit
}
}
}
return true
return fits, someUntoleratedTaintIsNoAdmit
}
// Determine if a pod is scheduled with best-effort QoS