Skip to content
Permalink
Browse files

Merge pull request #79641 from yqwang-ms/yqwang/fix-ds-crash

Fix default scheduler crash if scheduler extender filter returns a not found node
  • Loading branch information...
k8s-ci-robot committed Aug 14, 2019
2 parents 0166742 + 5927ec4 commit 2ad2795136be1edd0d1920e7b3e8c25e1e66f6a4
Showing with 14 additions and 8 deletions.
  1. +13 −7 pkg/scheduler/core/extender.go
  2. +1 −1 pkg/scheduler/scheduler.go
@@ -253,8 +253,8 @@ func convertToNodeNameToVictims(
}

// Filter based on extender implemented predicate functions. The filtered list is
// expected to be a subset of the supplied list. failedNodesMap optionally contains
// the list of failed nodes and failure reasons.
// expected to be a subset of the supplied list; otherwise the function returns an error.
// failedNodesMap optionally contains the list of failed nodes and failure reasons.
func (h *HTTPExtender) Filter(
pod *v1.Pod,
nodes []*v1.Node, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo,
@@ -298,14 +298,20 @@ func (h *HTTPExtender) Filter(
}

if h.nodeCacheCapable && result.NodeNames != nil {
nodeResult = make([]*v1.Node, 0, len(*result.NodeNames))
for i := range *result.NodeNames {
nodeResult = append(nodeResult, nodeNameToInfo[(*result.NodeNames)[i]].Node())
nodeResult = make([]*v1.Node, len(*result.NodeNames))
for i, nodeName := range *result.NodeNames {
if node, ok := nodeNameToInfo[nodeName]; ok {
nodeResult[i] = node.Node()
} else {
return nil, nil, fmt.Errorf(
"extender %q claims a filtered node %q which is not found in nodeNameToInfo map",
h.extenderURL, nodeName)
}
}
} else if result.Nodes != nil {
nodeResult = make([]*v1.Node, 0, len(result.Nodes.Items))
nodeResult = make([]*v1.Node, len(result.Nodes.Items))
for i := range result.Nodes.Items {
nodeResult = append(nodeResult, &result.Nodes.Items[i])
nodeResult[i] = &result.Nodes.Items[i]
}
}

@@ -305,7 +305,7 @@ func (sched *Scheduler) preempt(fwk framework.Framework, preemptor *v1.Pod, sche

node, victims, nominatedPodsToClear, err := sched.config.Algorithm.Preempt(preemptor, scheduleErr)
if err != nil {
klog.Errorf("Error preempting victims to make room for %v/%v.", preemptor.Namespace, preemptor.Name)
klog.Errorf("Error preempting victims to make room for %v/%v: %v", preemptor.Namespace, preemptor.Name, err)
return "", err
}
var nodeName = ""

0 comments on commit 2ad2795

Please sign in to comment.
You can’t perform that action at this time.