Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: support pod preemption from numa awareless reservation #2204

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/scheduler/plugins/nodenumaresource/preempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/kubernetes/pkg/scheduler/framework"

"github.com/koordinator-sh/koordinator/pkg/scheduler/frameworkext"
"github.com/koordinator-sh/koordinator/pkg/util/cpuset"
)

Expand Down Expand Up @@ -141,7 +142,7 @@ func (p *Plugin) AddPod(_ context.Context, cycleState *framework.CycleState, pre
state.schedulingStateData.lock.Unlock()

rInfo := p.getPodNominatedReservationInfo(pod, nodeName)
if rInfo == nil { // preempt node unallocated resources
if p.isReservationUnallocatedNUMAResources(rInfo) { // preempt node unallocated resources
if nodeState.nodeAlloc == nil {
nodeState.nodeAlloc = newPreemptibleAlloc()
}
Expand Down Expand Up @@ -197,7 +198,7 @@ func (p *Plugin) RemovePod(_ context.Context, cycleState *framework.CycleState,
state.schedulingStateData.lock.Unlock()

rInfo := p.getPodNominatedReservationInfo(pod, nodeName)
if rInfo == nil { // preempt node unallocated resources
if p.isReservationUnallocatedNUMAResources(rInfo) { // preempt node unallocated resources
if nodeState.nodeAlloc == nil {
nodeState.nodeAlloc = newPreemptibleAlloc()
}
Expand All @@ -219,6 +220,17 @@ func (p *Plugin) RemovePod(_ context.Context, cycleState *framework.CycleState,
return nil
}

func (p *Plugin) isReservationUnallocatedNUMAResources(rInfo *frameworkext.ReservationInfo) bool {
saintube marked this conversation as resolved.
Show resolved Hide resolved
if rInfo == nil {
return true
}
podAllocatedCPUs, podAllocatedNUMAResources := p.getPodAllocated(rInfo.Pod, rInfo.GetNodeName())
if podAllocatedCPUs.IsEmpty() && len(podAllocatedNUMAResources) == 0 {
return true
}
return false
}

func (p *Plugin) getPodAllocated(pod *corev1.Pod, nodeName string) (cpus cpuset.CPUSet, numaResources map[int]corev1.ResourceList) {
podAllocatedCPUs, ok := p.resourceManager.GetAllocatedCPUSet(nodeName, pod.UID)
if ok && !podAllocatedCPUs.IsEmpty() {
Expand Down