Skip to content

Commit c579dd5

Browse files
ZiMengShengwangjianyu.wjy
andauthored
Revert "scheduler: pick vf by random (#1953)" (#1986)
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com> Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
1 parent d1a1e1a commit c579dd5

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

pkg/scheduler/plugins/deviceshare/device_allocator.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package deviceshare
1818

1919
import (
2020
"fmt"
21-
"math/rand"
2221
"sort"
2322

2423
corev1 "k8s.io/api/core/v1"
@@ -34,10 +33,6 @@ import (
3433
"github.com/koordinator-sh/koordinator/pkg/util/bitmask"
3534
)
3635

37-
var (
38-
randIntnFn = rand.Intn
39-
)
40-
4136
var deviceHandlers = map[schedulingv1alpha1.DeviceType]DeviceHandler{}
4237
var deviceAllocators = map[schedulingv1alpha1.DeviceType]DeviceAllocator{}
4338

@@ -489,11 +484,10 @@ func allocateVF(vfAllocation *VFAllocation, deviceInfos map[int]*schedulingv1alp
489484
if len(remainingVFs) == 0 {
490485
return nil
491486
}
492-
// Here we sort the remaining vf just for test deterministic. In fact, we pick the vf by random to alleviating some unexpected vf duplicate allocation problem due to uncoordinated scheduling and node-side vf allocation components
493487
sort.Slice(remainingVFs, func(i, j int) bool {
494488
return remainingVFs[i].BusID < remainingVFs[j].BusID
495489
})
496-
vf := &remainingVFs[randIntnFn(len(remainingVFs))]
490+
vf := &remainingVFs[0]
497491
return vf
498492
}
499493

pkg/scheduler/plugins/deviceshare/device_allocator_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -866,9 +866,6 @@ func TestAutopilotAllocator(t *testing.T) {
866866

867867
for _, tt := range tests {
868868
t.Run(tt.name, func(t *testing.T) {
869-
randIntnFn = func(n int) int {
870-
return 0
871-
}
872869
deviceCR := tt.deviceCR.DeepCopy()
873870
deviceCR.ResourceVersion = "1"
874871
koordFakeClient := koordfake.NewSimpleClientset()
@@ -1706,9 +1703,6 @@ func TestAutopilotAllocatorWithExclusivePolicyAndRequiredScope(t *testing.T) {
17061703

17071704
for _, tt := range tests {
17081705
t.Run(tt.name, func(t *testing.T) {
1709-
randIntnFn = func(n int) int {
1710-
return 0
1711-
}
17121706
deviceCR := tt.deviceCR.DeepCopy()
17131707
deviceCR.ResourceVersion = "1"
17141708
koordFakeClient := koordfake.NewSimpleClientset()

0 commit comments

Comments
 (0)