Skip to content

Commit 6dea737

Browse files
authored
Fix topology plugin typos (kai-scheduler#369)
1 parent 94ffd3b commit 6dea737

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

pkg/scheduler/plugins/topology/topology_plugin_job_filtering.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (t *topologyPlugin) prePredicateFn(_ *pod_info.PodInfo, job *podgroup_info.
3030
return nil
3131
}
3232

33-
defer t.treeAllocateableCleanup(topologyTree)
33+
defer t.treeAllocatableCleanup(topologyTree)
3434
maxAllocatablePods, err := t.calcTreeAllocatable(job, topologyTree)
3535
if err != nil {
3636
return err
@@ -42,7 +42,7 @@ func (t *topologyPlugin) prePredicateFn(_ *pod_info.PodInfo, job *podgroup_info.
4242
return nil
4343
}
4444

45-
_, err = t.getBestjobAllocateableDomains(job, topologyTree)
45+
_, err = t.getBestJobAllocatableDomains(job, topologyTree)
4646
if err != nil {
4747
return err
4848
}
@@ -105,42 +105,42 @@ func (t *topologyPlugin) calcSubTreeAllocatable(jobAllocationData *jobAllocation
105105
}
106106

107107
for _, child := range rootDomain.Children {
108-
childAllocateable, err := t.calcSubTreeAllocatable(jobAllocationData, child)
108+
childAllocatable, err := t.calcSubTreeAllocatable(jobAllocationData, child)
109109
if err != nil {
110110
return 0, err
111111
}
112-
rootDomain.AllocatablePods += childAllocateable
112+
rootDomain.AllocatablePods += childAllocatable
113113
}
114114
return rootDomain.AllocatablePods, nil
115115
}
116116

117117
func calcNodeAccommodation(jobAllocationMetaData *jobAllocationMetaData, node *node_info.NodeInfo) int {
118-
allocateablePodsCount := 0
118+
allocatablePodsCount := 0
119119
for _, resourceRepresentorPod := range jobAllocationMetaData.allocationTestPods {
120120
if node.IsTaskAllocatable(resourceRepresentorPod) {
121-
allocateablePodsCount++
121+
allocatablePodsCount++
122122
} else {
123123
break
124124
}
125125
}
126126
// Add more to jobResourcesAllocationsRepresentors until node cannot accommodate any more pods
127-
if allocateablePodsCount == len(jobAllocationMetaData.allocationTestPods) {
128-
for i := allocateablePodsCount; i < len(jobAllocationMetaData.tasksToAllocate); i++ {
127+
if allocatablePodsCount == len(jobAllocationMetaData.allocationTestPods) {
128+
for i := allocatablePodsCount; i < len(jobAllocationMetaData.tasksToAllocate); i++ {
129129
latestTestPod := jobAllocationMetaData.allocationTestPods[len(jobAllocationMetaData.allocationTestPods)-1]
130130

131131
iAllocationsTestPod := &pod_info.PodInfo{
132-
Name: fmt.Sprintf("%d-pods-resources", allocateablePodsCount+1),
132+
Name: fmt.Sprintf("%d-pods-resources", allocatablePodsCount+1),
133133
ResReq: calcNextAllocationTestPodResources(latestTestPod.ResReq, jobAllocationMetaData.maxPodResources),
134134
}
135135
jobAllocationMetaData.allocationTestPods = append(jobAllocationMetaData.allocationTestPods, iAllocationsTestPod)
136136
if node.IsTaskAllocatable(iAllocationsTestPod) {
137-
allocateablePodsCount++
137+
allocatablePodsCount++
138138
} else {
139139
break
140140
}
141141
}
142142
}
143-
return allocateablePodsCount
143+
return allocatablePodsCount
144144
}
145145

146146
func calcNextAllocationTestPodResources(previousTestResources, maxPodResources *resource_info.ResourceRequirements) *resource_info.ResourceRequirements {
@@ -160,7 +160,7 @@ func calcNextAllocationTestPodResources(previousTestResources, maxPodResources *
160160
return nPlus1Resources
161161
}
162162

163-
func (t *topologyPlugin) getBestjobAllocateableDomains(job *podgroup_info.PodGroupInfo, topologyTree *TopologyInfo) ([]*TopologyDomainInfo, error) {
163+
func (t *topologyPlugin) getBestJobAllocatableDomains(job *podgroup_info.PodGroupInfo, topologyTree *TopologyInfo) ([]*TopologyDomainInfo, error) {
164164
relevantLevels, err := t.calculateRelevantDomainLevels(job, topologyTree.Name, topologyTree)
165165
if err != nil {
166166
return nil, err
@@ -188,7 +188,7 @@ func (t *topologyPlugin) getBestjobAllocateableDomains(job *podgroup_info.PodGro
188188

189189
if job.PodGroup.Spec.TopologyConstraint.PreferredTopologyLevel != "" &&
190190
maxDepthDomains[0].Level != job.PodGroup.Spec.TopologyConstraint.PreferredTopologyLevel {
191-
// If Preferred is defined and we couldn't find a domain on the prefered level,
191+
// If Preferred is defined and we couldn't find a domain on the preferred level,
192192
// return a children subset and not a single domain
193193
return t.improveChoiceForPreference(maxDepthDomains, job)
194194
}
@@ -227,12 +227,12 @@ func (*topologyPlugin) calculateRelevantDomainLevels(
227227
}
228228
}
229229
if requiredPlacement != "" && !foundRequiredLevel {
230-
return nil, fmt.Errorf("the topology %s doesn't have a level matching the required(%s) spesified for the job %s",
230+
return nil, fmt.Errorf("the topology %s doesn't have a level matching the required(%s) specified for the job %s",
231231
jobTopologyName, requiredPlacement, job.Name,
232232
)
233233
}
234234
if preferredPlacement != "" && !foundPreferredLevel {
235-
return nil, fmt.Errorf("the topology %s doesn't have a level matching the preffered(%s) spesified for the job %s",
235+
return nil, fmt.Errorf("the topology %s doesn't have a level matching the preferred(%s) specified for the job %s",
236236
jobTopologyName, preferredPlacement, job.Name,
237237
)
238238
}
@@ -245,33 +245,33 @@ func (t *topologyPlugin) improveChoiceForPreference(maxDepthDomains []*TopologyD
245245
// and return the one with the least number of domains required for the allocation
246246
bestChildrenSubset := []*TopologyDomainInfo{}
247247
for _, domain := range maxDepthDomains {
248-
childDomainSubset := getJobAllocateableChildrenSubset(domain, taskToAllocateCount)
248+
childDomainSubset := getJobAllocatableChildrenSubset(domain, taskToAllocateCount)
249249
if len(bestChildrenSubset) == 0 || len(childDomainSubset) < len(bestChildrenSubset) {
250250
bestChildrenSubset = childDomainSubset
251251
}
252252
}
253253
return bestChildrenSubset, nil
254254
}
255255

256-
func getJobAllocateableChildrenSubset(domain *TopologyDomainInfo, taskToAllocateCount int) []*TopologyDomainInfo {
256+
func getJobAllocatableChildrenSubset(domain *TopologyDomainInfo, taskToAllocateCount int) []*TopologyDomainInfo {
257257
children := slices.Clone(domain.Children)
258258
sort.SliceStable(children, func(i, j int) bool {
259259
return children[i].AllocatablePods > children[j].AllocatablePods
260260
})
261261

262-
allocateablePodsSum := 0
262+
allocatablePodsSum := 0
263263
childDomainSubset := []*TopologyDomainInfo{}
264264
for _, childDomain := range children {
265-
allocateablePodsSum += childDomain.AllocatablePods
265+
allocatablePodsSum += childDomain.AllocatablePods
266266
childDomainSubset = append(childDomainSubset, childDomain)
267-
if allocateablePodsSum >= taskToAllocateCount {
267+
if allocatablePodsSum >= taskToAllocateCount {
268268
break
269269
}
270270
}
271271
return childDomainSubset
272272
}
273273

274-
func (*topologyPlugin) treeAllocateableCleanup(topologyTree *TopologyInfo) {
274+
func (*topologyPlugin) treeAllocatableCleanup(topologyTree *TopologyInfo) {
275275
for _, levelDomains := range topologyTree.DomainsByLevel {
276276
for _, domain := range levelDomains {
277277
domain.AllocatablePods = 0

pkg/scheduler/plugins/topology/topology_plugin_job_filtering_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestTopologyPlugin_calculateRelevantDomainLevels(t *testing.T) {
194194
},
195195
},
196196
expectedLevels: nil,
197-
expectedError: "the topology test-topology doesn't have a level matching the required(nonexistent) spesified for the job test-job",
197+
expectedError: "the topology test-topology doesn't have a level matching the required(nonexistent) specified for the job test-job",
198198
},
199199
{
200200
name: "preferred placement not found in topology",
@@ -224,7 +224,7 @@ func TestTopologyPlugin_calculateRelevantDomainLevels(t *testing.T) {
224224
},
225225
},
226226
expectedLevels: nil,
227-
expectedError: "the topology test-topology doesn't have a level matching the preffered(nonexistent) spesified for the job test-job",
227+
expectedError: "the topology test-topology doesn't have a level matching the preferred(nonexistent) specified for the job test-job",
228228
},
229229
{
230230
name: "required placement at first level",
@@ -879,7 +879,7 @@ func TestTopologyPlugin_calcTreeAllocatable(t *testing.T) {
879879
}
880880
}
881881

882-
func TestTopologyPlugin_getBestjobAllocateableDomains(t *testing.T) {
882+
func TestTopologyPlugin_getBestJobAllocatableDomains(t *testing.T) {
883883
tests := []struct {
884884
name string
885885
job *podgroup_info.PodGroupInfo
@@ -1057,7 +1057,7 @@ func TestTopologyPlugin_getBestjobAllocateableDomains(t *testing.T) {
10571057
return l.(*pod_info.PodInfo).Name < r.(*pod_info.PodInfo).Name
10581058
},
10591059
expectedDomains: nil,
1060-
expectedError: "the topology test-topology doesn't have a level matching the required(zone) spesified for the job test-job",
1060+
expectedError: "the topology test-topology doesn't have a level matching the required(zone) specified for the job test-job",
10611061
},
10621062
{
10631063
name: "complex topology with multiple levels",
@@ -1370,7 +1370,7 @@ func TestTopologyPlugin_getBestjobAllocateableDomains(t *testing.T) {
13701370
taskOrderFunc: tt.taskOrderFunc,
13711371
}
13721372

1373-
result, err := plugin.getBestjobAllocateableDomains(tt.job, tt.topologyTree)
1373+
result, err := plugin.getBestJobAllocatableDomains(tt.job, tt.topologyTree)
13741374

13751375
// Check error
13761376
if tt.expectedError != "" {

0 commit comments

Comments
 (0)