Skip to content

Commit

Permalink
support preemption when the number of pods of a node reaches the uppe…
Browse files Browse the repository at this point in the history
…r limit

Signed-off-by: lili <[email protected]>
  • Loading branch information
Lily922 committed Nov 10, 2023
1 parent ea04e65 commit 17f266b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions pkg/scheduler/api/pod_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func GetPodResourceRequest(pod *v1.Pod) *Resource {
for _, container := range pod.Spec.InitContainers {
result.SetMaxResource(NewResource(container.Resources.Requests))
}
result.AddScalar(v1.ResourcePods, 1)

return result
}
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/api/resource_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func NewResource(rl v1.ResourceList) *Resource {
r.Memory += float64(rQuant.Value())
case v1.ResourcePods:
r.MaxTaskNum += int(rQuant.Value())
r.AddScalar(rName, float64(rQuant.Value()))
case v1.ResourceEphemeralStorage:
r.AddScalar(rName, float64(rQuant.MilliValue()))
default:
Expand Down
20 changes: 12 additions & 8 deletions pkg/scheduler/plugins/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,22 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
}

if node.Allocatable.MaxTaskNum <= len(nodeInfo.Pods) {
klog.V(4).Infof("NodePodNumber predicates Task <%s/%s> on Node <%s> failed",
task.Namespace, task.Name, node.Name)
klog.V(4).Infof("NodePodNumber predicates Task <%s/%s> on Node <%s> failed, %d, %d",
task.Namespace, task.Name, node.Name, node.Allocatable.MaxTaskNum, len(nodeInfo.Pods))
podsNumStatus := &api.Status{
// TODO(wangyang0616): When the number of pods of a node reaches the upper limit, preemption is not supported for now.
// Record details in #3079 (volcano.sh/volcano)
// In the preempt stage, the pipeline of the pod number is not considered,
// the preemption of the pod number is released directly, which will cause the pods in the node to be cyclically evicted.
Code: api.UnschedulableAndUnresolvable,
Code: api.Unschedulable,
Reason: api.NodePodNumberExceeded,
}
predicateStatus = append(predicateStatus, podsNumStatus)
return predicateStatus, fmt.Errorf("%s", api.NodePodNumberExceeded)
}
return predicateStatus, nil
})

ssn.AddPredicateFn(pp.Name(), func(task *api.TaskInfo, node *api.NodeInfo) ([]*api.Status, error) {
predicateStatus := make([]*api.Status, 0)
nodeInfo, found := nodeMap[node.Name]
if !found {
return predicateStatus, fmt.Errorf("failed to predicates, node info for %s not found", node.Name)
}

predicateByStablefilter := func(pod *v1.Pod, nodeInfo *k8sframework.NodeInfo) ([]*api.Status, bool, error) {
Expand Down

0 comments on commit 17f266b

Please sign in to comment.