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: remove invalid hint in which some numaNode lack resource #2018

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 24 additions & 4 deletions pkg/scheduler/plugins/nodenumaresource/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,22 @@ func (c *resourceManager) getAvailableNUMANodeResources(nodeName string, topolog
}

func generateResourceHints(numaNodeResources []NUMANodeResource, podRequests corev1.ResourceList, totalAvailable map[int]corev1.ResourceList, numaScorer *resourceAllocationScorer) map[string][]topologymanager.NUMATopologyHint {
var resourceNamesByNUMA []corev1.ResourceName
for _, numaNodeResource := range numaNodeResources {
resourceNamesByNUMA = append(resourceNamesByNUMA, quotav1.ResourceNames(numaNodeResource.Resources)...)
}
numaNodesLackResource := map[corev1.ResourceName][]int{}
for _, resourceName := range resourceNamesByNUMA {
for nodeID, numaAvailable := range totalAvailable {
if available, ok := numaAvailable[resourceName]; !ok || available.IsZero() {
numaNodesLackResource[resourceName] = append(numaNodesLackResource[resourceName], nodeID)
}
}
}
generator := hintsGenerator{
minAffinitySize: make(map[corev1.ResourceName]int),
hints: map[string][]topologymanager.NUMATopologyHint{},
numaNodesLackResource: numaNodesLackResource,
minAffinitySize: make(map[corev1.ResourceName]int),
hints: map[string][]topologymanager.NUMATopologyHint{},
}
var memoryResourceNames []corev1.ResourceName
for resourceName := range podRequests {
Expand Down Expand Up @@ -492,8 +505,9 @@ func generateResourceHints(numaNodeResources []NUMANodeResource, podRequests cor
}

type hintsGenerator struct {
minAffinitySize map[corev1.ResourceName]int
hints map[string][]topologymanager.NUMATopologyHint
numaNodesLackResource map[corev1.ResourceName][]int
minAffinitySize map[corev1.ResourceName]int
hints map[string][]topologymanager.NUMATopologyHint
}

func (g *hintsGenerator) generateHints(mask bitmask.BitMask, score int64, totalAllocatable, totalFree corev1.ResourceList, podRequests corev1.ResourceList, resourceNames ...corev1.ResourceName) {
Expand All @@ -504,6 +518,12 @@ func (g *hintsGenerator) generateHints(mask bitmask.BitMask, score int64, totalA
}
}

for _, resourceName := range resourceNames {
if mask.AnySet(g.numaNodesLackResource[resourceName]) {
return
}
}

nodeCount := mask.Count()
for _, resourceName := range resourceNames {
affinitySize := g.minAffinitySize[resourceName]
Expand Down
14 changes: 0 additions & 14 deletions pkg/scheduler/plugins/nodenumaresource/resource_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,6 @@ func TestResourceManagerGetTopologyHint(t *testing.T) {
}(),
Preferred: true,
},
{
NUMANodeAffinity: func() bitmask.BitMask {
mask, _ := bitmask.NewBitMask(0, 1)
return mask
}(),
Preferred: false,
},
},
},
wantErr: false,
Expand Down Expand Up @@ -806,13 +799,6 @@ func TestResourceManagerGetTopologyHint(t *testing.T) {
}(),
Preferred: true,
},
{
NUMANodeAffinity: func() bitmask.BitMask {
mask, _ := bitmask.NewBitMask(0, 1)
return mask
}(),
Preferred: false,
},
},
},
wantErr: false,
Expand Down
Loading