Skip to content

Commit

Permalink
Merge pull request kubernetes-retired#455 from jeefy/453-check-node-spec
Browse files Browse the repository at this point in the history
Check node spec for unschedulable as well
  • Loading branch information
k8s-ci-robot authored Oct 20, 2018
2 parents 5c9ec69 + f652d86 commit e43b0af
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/scheduler/plugins/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/scheduler/algorithm"
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/pkg/scheduler/cache"

Expand Down Expand Up @@ -99,6 +100,14 @@ func (c *cachedNodeInfo) GetNodeInfo(name string) (*v1.Node, error) {
return node.Node, nil
}

// Check to see if node spec is set to Schedulable or not
func CheckNodeUnschedulable(pod *v1.Pod, nodeInfo *cache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
if nodeInfo.Node().Spec.Unschedulable {
return false, []algorithm.PredicateFailureReason{predicates.ErrNodeUnschedulable}, nil
}
return true, nil, nil
}

func (pp *nodeAffinityPlugin) OnSessionOpen(ssn *framework.Session) {
pl := &podLister{
session: ssn,
Expand Down Expand Up @@ -144,6 +153,20 @@ func (pp *nodeAffinityPlugin) OnSessionOpen(ssn *framework.Session) {
node.Name, task.Namespace, task.Name)
}

// Check to see if node.Spec.Unschedulable is set
fit, _, err = CheckNodeUnschedulable(task.Pod, nodeInfo)
if err != nil {
return err
}

glog.V(3).Infof("Check Unschedulable Task <%s/%s> on Node <%s>: fit %t, err %v",
task.Namespace, task.Name, node.Name, fit, err)

if !fit {
return fmt.Errorf("task <%s/%s> node <%s> set to unschedulable",
task.Namespace, task.Name, node.Name)
}

// Toleration/Taint Predicate
fit, _, err = predicates.PodToleratesNodeTaints(task.Pod, nil, nodeInfo)
if err != nil {
Expand Down

0 comments on commit e43b0af

Please sign in to comment.