Skip to content

Commit 241ea6c

Browse files
authored
Bug fix: Add the child domains properly to the parent when calculating the topology tree in the scheduler (#396)
1 parent 695e72d commit 241ea6c

File tree

6 files changed

+82
-67
lines changed

6 files changed

+82
-67
lines changed

pkg/scheduler/actions/common/allocate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ func AllocateJob(ssn *framework.Session, stmt *framework.Statement, nodes []*nod
2626
}
2727
return false
2828
}
29+
30+
defer ssn.CleanAllocationAttemptCache(job)
2931
cp := stmt.Checkpoint()
3032
for index, task := range tasksToAllocate {
3133
success := allocateTask(ssn, stmt, nodes, task, isPipelineOnly)
@@ -73,8 +75,6 @@ func allocateTask(ssn *framework.Session, stmt *framework.Statement, nodes []*no
7375
task.Namespace, task.Name, node.Name)
7476
}
7577

76-
ssn.CleanAllocationAttemptCache(job)
77-
7878
if success {
7979
log.InfraLogger.V(6).Infof("Allocation succeeded for task: <%v/%v>", task.Namespace, task.Name)
8080
} else {

pkg/scheduler/plugins/topology/topology_plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ func (*topologyPlugin) addNodeDataToTopology(topologyTree *TopologyInfo, singleT
9797

9898
// Connect the child domain to the current domain. The current node gives us the link
9999
if nodeContainingChildDomain != nil {
100-
nodeContainingChildDomain.Parent = domainInfo
100+
connectDomainToParent(nodeContainingChildDomain, domainInfo)
101101
}
102102
nodeContainingChildDomain = domainInfo
103103
}
104-
nodeContainingChildDomain.Parent = topologyTree.Root
104+
connectDomainToParent(nodeContainingChildDomain, topologyTree.Root)
105105
topologyTree.Root.AddNode(nodeInfo)
106106
}
107107

pkg/scheduler/plugins/topology/topology_plugin_job_filtering.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package topology
66
import (
77
"errors"
88
"fmt"
9-
"slices"
109
"sort"
1110
"strings"
1211

@@ -242,7 +241,8 @@ func (*topologyPlugin) calculateRelevantDomainLevels(
242241
foundPreferredLevel := false
243242
relevantLevels := []string{}
244243
abovePreferredLevel := preferredPlacement == ""
245-
for _, level := range topologyTree.TopologyResource.Spec.Levels {
244+
for i := len(topologyTree.TopologyResource.Spec.Levels) - 1; i >= 0; i-- {
245+
level := topologyTree.TopologyResource.Spec.Levels[i]
246246
if preferredPlacement != "" && preferredPlacement == level.NodeLabel {
247247
foundPreferredLevel = true
248248
abovePreferredLevel = true
@@ -286,7 +286,10 @@ func (t *topologyPlugin) improveChoiceForPreference(maxDepthDomains []*TopologyD
286286
}
287287

288288
func getJobAllocatableChildrenSubset(domain *TopologyDomainInfo, taskToAllocateCount int) []*TopologyDomainInfo {
289-
children := slices.Clone(domain.Children)
289+
children := make([]*TopologyDomainInfo, 0, len(domain.Children))
290+
for _, child := range domain.Children {
291+
children = append(children, child)
292+
}
290293
sort.SliceStable(children, func(i, j int) bool {
291294
return children[i].AllocatablePods > children[j].AllocatablePods
292295
})

0 commit comments

Comments
 (0)