Skip to content

Commit

Permalink
scheduler: move creating dev allocator into once func
Browse files Browse the repository at this point in the history
  • Loading branch information
nickethier committed Nov 13, 2020
1 parent 4192bd2 commit 7342826
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scheduler/rank.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ OUTER:
var initNetIdxOnce sync.Once

// Create a device allocator
devAllocator := newDeviceAllocator(iter.ctx, option.Node)
var devAllocator *deviceAllocator
initDevAllocator := func() {
devAllocator = newDeviceAllocator(iter.ctx, option.Node)
devAllocator.AddAllocs(proposed)
}
var initDevAllocatorOnce sync.Once

// Track the affinities of the devices
Expand Down Expand Up @@ -363,7 +367,7 @@ OUTER:

// Check if we need to assign devices
for _, req := range task.Resources.Devices {
initDevAllocatorOnce.Do(func() { devAllocator.AddAllocs(proposed) })
initDevAllocatorOnce.Do(initDevAllocator)
offer, sumAffinities, err := devAllocator.AssignDevice(req)
if offer == nil {
// If eviction is not enabled, mark this node as exhausted and continue
Expand Down

0 comments on commit 7342826

Please sign in to comment.