Skip to content

Commit 388fe85

Browse files
committed
CR comments 1
1 parent a2576fd commit 388fe85

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

pkg/scheduler/plugins/topology/topology_plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type topologyPlugin struct {
2121
enabled bool
2222
taskOrderFunc common_info.LessFn
2323
sessionStateGetter k8s_internal.SessionStateProvider
24-
nodesInfoMap map[string]*node_info.NodeInfo
24+
nodesInfos map[string]*node_info.NodeInfo
2525
TopologyTrees map[string]*TopologyInfo
2626
}
2727

@@ -40,7 +40,7 @@ func (t *topologyPlugin) OnSessionOpen(ssn *framework.Session) {
4040
topologies := ssn.Topologies
4141
t.taskOrderFunc = ssn.TaskOrderFn
4242
t.sessionStateGetter = ssn
43-
t.nodesInfoMap = ssn.Nodes
43+
t.nodesInfos = ssn.Nodes
4444
t.initializeTopologyTree(topologies, ssn)
4545

4646
ssn.AddEventHandler(&framework.EventHandler{

pkg/scheduler/plugins/topology/topology_plugin_job_filtering.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,26 @@ func (t *topologyPlugin) calcTreeAlocationData(job *podgroup_info.PodGroupInfo,
107107
currentlyUpdatedDomains := map[TopologyDomainID]*TopologyDomainInfo{}
108108
for len(latestUpdatedDomains) > 0 {
109109
for _, domain := range latestUpdatedDomains {
110-
if domain.Parent != nil {
111-
// Known issue: shold be replaced with the real distance logic
112-
// TODO: subsetsum on allocateablePods, from them find min distance
113-
if domain.Parent.AllocatablePods < taskToAllocateCount {
114-
// If the parent domain has less allocateable pods than the tasks to allocate,
115-
// we need to update the parent domain with the current domain's allocateable pods
116-
if domain.AllocatablePods < taskToAllocateCount {
117-
domain.Parent.Distance += domain.Distance
118-
domain.Parent.AllocatablePods += domain.AllocatablePods
119-
} else {
120-
domain.Parent.Distance = domain.Distance
121-
domain.Parent.AllocatablePods = domain.AllocatablePods
122-
}
123-
} else if domain.Parent.Distance > domain.Distance {
110+
if domain.Parent == nil {
111+
continue
112+
}
113+
// Known issue: should be replaced with the real distance logic
114+
// TODO: subsetsum on allocateablePods, from them find min distance
115+
if domain.Parent.AllocatablePods < taskToAllocateCount {
116+
// If the parent domain has less allocateable pods than the tasks to allocate,
117+
// we need to update the parent domain with the current domain's allocateable pods
118+
if domain.AllocatablePods < taskToAllocateCount {
119+
domain.Parent.Distance += domain.Distance
120+
domain.Parent.AllocatablePods += domain.AllocatablePods
121+
} else {
124122
domain.Parent.Distance = domain.Distance
125123
domain.Parent.AllocatablePods = domain.AllocatablePods
126124
}
127-
currentlyUpdatedDomains[domain.Parent.ID] = domain.Parent
125+
} else if domain.Parent.Distance > domain.Distance {
126+
domain.Parent.Distance = domain.Distance
127+
domain.Parent.AllocatablePods = domain.AllocatablePods
128128
}
129+
currentlyUpdatedDomains[domain.Parent.ID] = domain.Parent
129130
}
130131
latestUpdatedDomains = currentlyUpdatedDomains
131132
currentlyUpdatedDomains = map[TopologyDomainID]*TopologyDomainInfo{}
@@ -180,7 +181,7 @@ func (t *topologyPlugin) calcAllocationsForLeafDomains(job *podgroup_info.PodGro
180181
{Name: "1-pods-resources", ResReq: maxPodResources},
181182
}
182183
leafDomains := map[TopologyDomainID]*TopologyDomainInfo{}
183-
for _, node := range t.nodesInfoMap {
184+
for _, node := range t.nodesInfos {
184185
allocateablePodsCount := calcNodeAccomedation(maxPodResources, allocationTestPods, node, len(tasksToAllocate))
185186

186187
leafDomainId := calcLeafDomainId(topologyTree.TopologyResource, node.Node.Labels)

pkg/scheduler/plugins/topology/topology_plugin_job_filtering_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func TestTopologyPlugin_calcAllocationsForLeafDomains(t *testing.T) {
328328
}
329329
plugin := &topologyPlugin{
330330
sessionStateGetter: session,
331-
nodesInfoMap: nodesInfoMap,
331+
nodesInfos: nodesInfoMap,
332332
}
333333

334334
err, domains := plugin.calcAllocationsForLeafDomains(job, topologyTree)
@@ -1160,7 +1160,7 @@ func TestTopologyPlugin_calcTreeAlocationData(t *testing.T) {
11601160
}
11611161
plugin := &topologyPlugin{
11621162
sessionStateGetter: session,
1163-
nodesInfoMap: nodesInfoMap,
1163+
nodesInfos: nodesInfoMap,
11641164
}
11651165

11661166
// Call the function under test

0 commit comments

Comments
 (0)