Skip to content

Commit

Permalink
Revert "scheduler: pick vf by random (#1953)"
Browse files Browse the repository at this point in the history
This reverts commit beaafa3.

Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
wangjianyu.wjy committed Apr 7, 2024
1 parent f6acba6 commit 1cdf019
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
8 changes: 1 addition & 7 deletions pkg/scheduler/plugins/deviceshare/device_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package deviceshare

import (
"fmt"
"math/rand"
"sort"

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

var (
randIntnFn = rand.Intn
)

var deviceHandlers = map[schedulingv1alpha1.DeviceType]DeviceHandler{}
var deviceAllocators = map[schedulingv1alpha1.DeviceType]DeviceAllocator{}

Expand Down Expand Up @@ -489,11 +484,10 @@ func allocateVF(vfAllocation *VFAllocation, deviceInfos map[int]*schedulingv1alp
if len(remainingVFs) == 0 {
return nil
}
// 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
sort.Slice(remainingVFs, func(i, j int) bool {
return remainingVFs[i].BusID < remainingVFs[j].BusID
})
vf := &remainingVFs[randIntnFn(len(remainingVFs))]
vf := &remainingVFs[0]
return vf
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/scheduler/plugins/deviceshare/device_allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,6 @@ func TestAutopilotAllocator(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
randIntnFn = func(n int) int {
return 0
}
deviceCR := tt.deviceCR.DeepCopy()
deviceCR.ResourceVersion = "1"
koordFakeClient := koordfake.NewSimpleClientset()
Expand Down Expand Up @@ -1706,9 +1703,6 @@ func TestAutopilotAllocatorWithExclusivePolicyAndRequiredScope(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
randIntnFn = func(n int) int {
return 0
}
deviceCR := tt.deviceCR.DeepCopy()
deviceCR.ResourceVersion = "1"
koordFakeClient := koordfake.NewSimpleClientset()
Expand Down

0 comments on commit 1cdf019

Please sign in to comment.