|
|
|
@@ -132,7 +132,7 @@ func (ev *Evaluator) Preempt(ctx context.Context, pod *v1.Pod, m framework.NodeT
|
|
|
|
|
podNamespace, podName := pod.Namespace, pod.Name
|
|
|
|
|
pod, err := ev.PodLister.Pods(pod.Namespace).Get(pod.Name)
|
|
|
|
|
if err != nil {
|
|
|
|
|
klog.ErrorS(err, "getting the updated preemptor pod object", "pod", klog.KRef(podNamespace, podName))
|
|
|
|
|
klog.ErrorS(err, "Getting the updated preemptor pod object", "pod", klog.KRef(podNamespace, podName))
|
|
|
|
|
return nil, framework.AsStatus(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -196,7 +196,7 @@ func (ev *Evaluator) findCandidates(ctx context.Context, pod *v1.Pod, m framewor
|
|
|
|
|
klog.V(3).InfoS("Preemption will not help schedule pod on any node", "pod", klog.KObj(pod))
|
|
|
|
|
// In this case, we should clean-up any existing nominated node name of the pod.
|
|
|
|
|
if err := util.ClearNominatedNodeName(ev.Handler.ClientSet(), pod); err != nil {
|
|
|
|
|
klog.ErrorS(err, "cannot clear 'NominatedNodeName' field of pod", "pod", klog.KObj(pod))
|
|
|
|
|
klog.ErrorS(err, "Cannot clear 'NominatedNodeName' field of pod", "pod", klog.KObj(pod))
|
|
|
|
|
// We do not return as this error is not critical.
|
|
|
|
|
}
|
|
|
|
|
return nil, unschedulableNodeStatus, nil
|
|
|
|
@@ -213,7 +213,7 @@ func (ev *Evaluator) findCandidates(ctx context.Context, pod *v1.Pod, m framewor
|
|
|
|
|
for i := offset; i < offset+10 && i < int32(len(potentialNodes)); i++ {
|
|
|
|
|
sample = append(sample, potentialNodes[i].Node().Name)
|
|
|
|
|
}
|
|
|
|
|
klog.Infof("from a pool of %d nodes (offset: %d, sample %d nodes: %v), ~%d candidates will be chosen", len(potentialNodes), offset, len(sample), sample, numCandidates)
|
|
|
|
|
klog.InfoS("Selecting candidates from a pool of nodes", "potentialNodesCount", len(potentialNodes), "offset", offset, "sampleLength", len(sample), "sample", sample, "candidates", numCandidates)
|
|
|
|
|
}
|
|
|
|
|
candidates, nodeStatuses, err := ev.DryRunPreemption(ctx, pod, potentialNodes, pdbs, offset, numCandidates)
|
|
|
|
|
for node, nodeStatus := range unschedulableNodeStatus {
|
|
|
|
@@ -257,7 +257,7 @@ func (ev *Evaluator) callExtenders(pod *v1.Pod, candidates []Candidate) ([]Candi
|
|
|
|
|
if victims == nil || len(victims.Pods) == 0 {
|
|
|
|
|
if extender.IsIgnorable() {
|
|
|
|
|
delete(nodeNameToVictims, nodeName)
|
|
|
|
|
klog.InfoS("Ignoring node without victims", "node", nodeName)
|
|
|
|
|
klog.InfoS("Ignoring node without victims", "node", klog.KRef("", nodeName))
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
return nil, framework.AsStatus(fmt.Errorf("expected at least one victim pod on node %q", nodeName))
|
|
|
|
@@ -307,7 +307,7 @@ func (ev *Evaluator) SelectCandidate(candidates []Candidate) Candidate {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We shouldn't reach here.
|
|
|
|
|
klog.ErrorS(errors.New("no candidate selected"), "should not reach here", "candidates", candidates)
|
|
|
|
|
klog.ErrorS(errors.New("no candidate selected"), "Should not reach here", "candidates", candidates)
|
|
|
|
|
// To not break the whole flow, return the first candidate.
|
|
|
|
|
return candidates[0]
|
|
|
|
|
}
|
|
|
|
@@ -339,7 +339,7 @@ func (ev *Evaluator) prepareCandidate(c Candidate, pod *v1.Pod, pluginName strin
|
|
|
|
|
// lets scheduler find another place for them.
|
|
|
|
|
nominatedPods := getLowerPriorityNominatedPods(fh, pod, c.Name())
|
|
|
|
|
if err := util.ClearNominatedNodeName(cs, nominatedPods...); err != nil {
|
|
|
|
|
klog.ErrorS(err, "cannot clear 'NominatedNodeName' field")
|
|
|
|
|
klog.ErrorS(err, "Cannot clear 'NominatedNodeName' field")
|
|
|
|
|
// We do not return as this error is not critical.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -481,7 +481,7 @@ func pickOneNodeForPreemption(nodesToVictims map[string]*extenderv1.Victims) str
|
|
|
|
|
if latestStartTime == nil {
|
|
|
|
|
// If the earliest start time of all pods on the 1st node is nil, just return it,
|
|
|
|
|
// which is not expected to happen.
|
|
|
|
|
klog.ErrorS(errors.New("earliestStartTime is nil for node"), "should not reach here", "node", minNodes2[0])
|
|
|
|
|
klog.ErrorS(errors.New("earliestStartTime is nil for node"), "Should not reach here", "node", klog.KRef("", minNodes2[0]))
|
|
|
|
|
return minNodes2[0]
|
|
|
|
|
}
|
|
|
|
|
nodeToReturn := minNodes2[0]
|
|
|
|
@@ -490,7 +490,7 @@ func pickOneNodeForPreemption(nodesToVictims map[string]*extenderv1.Victims) str
|
|
|
|
|
// Get earliest start time of all pods on the current node.
|
|
|
|
|
earliestStartTimeOnNode := util.GetEarliestPodStartTime(nodesToVictims[node])
|
|
|
|
|
if earliestStartTimeOnNode == nil {
|
|
|
|
|
klog.ErrorS(errors.New("earliestStartTime is nil for node"), "should not reach here", "node", node)
|
|
|
|
|
klog.ErrorS(errors.New("earliestStartTime is nil for node"), "Should not reach here", "node", klog.KRef("", node))
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if earliestStartTimeOnNode.After(latestStartTime.Time) {
|
|
|
|
|