diff --git a/scheduler/preemption.go b/scheduler/preemption.go index ec7973748..18d47eaca 100644 --- a/scheduler/preemption.go +++ b/scheduler/preemption.go @@ -454,7 +454,7 @@ func newAllocDeviceGroup() *deviceGroupAllocs { } // PreemptForDevice tries to find allocations to preempt to meet devices needed -// This is called once per task when assigning devices to the task +// This is called once per device request when assigning devices to the task func (p *Preemptor) PreemptForDevice(ask *structs.RequestedDevice, devAlloc *deviceAllocator) []*structs.Allocation { // Group allocations by device, tracking the number of @@ -473,6 +473,7 @@ func (p *Preemptor) PreemptForDevice(ask *structs.RequestedDevice, devAlloc *dev deviceIdTuple := *device.ID() devInst := devAlloc.Devices[deviceIdTuple] + // devInst can be nil if the device is no longer healthy if devInst == nil { continue } @@ -490,8 +491,6 @@ func (p *Preemptor) PreemptForDevice(ask *structs.RequestedDevice, devAlloc *dev deviceToAllocs[deviceIdTuple] = allocDeviceGrp } allocDeviceGrp.allocs = append(allocDeviceGrp.allocs, alloc) - devCount := allocDeviceGrp.deviceInstances[alloc.ID] - devCount += len(device.DeviceIDs) allocDeviceGrp.deviceInstances[alloc.ID] += len(device.DeviceIDs) } } diff --git a/scheduler/rank.go b/scheduler/rank.go index d892d317f..0b531e689 100644 --- a/scheduler/rank.go +++ b/scheduler/rank.go @@ -251,7 +251,7 @@ OUTER: netPreemptions := preemptor.PreemptForNetwork(ask, netIdx) if netPreemptions == nil { - iter.ctx.Logger().Named("binpack").Error(fmt.Sprintf("unable to meet network resource %v after preemption", ask)) + iter.ctx.Logger().Named("binpack").Error("preemption not possible ", "network_resource", ask) netIdx.Release() continue OUTER } @@ -268,7 +268,7 @@ OUTER: offer, err = netIdx.AssignNetwork(ask) if offer == nil { - iter.ctx.Logger().Named("binpack").Error(fmt.Sprintf("unexpected error, unable to create offer after preempting:%v", err)) + iter.ctx.Logger().Named("binpack").Error("unexpected error, unable to create network offer after considering preemption", "error", err) netIdx.Release() continue OUTER } @@ -296,7 +296,7 @@ OUTER: devicePreemptions := preemptor.PreemptForDevice(req, devAllocator) if devicePreemptions == nil { - iter.ctx.Logger().Named("binpack").Error(fmt.Sprintf("unable to meet device resource need after attempting preemption:%v", req)) + iter.ctx.Logger().Named("binpack").Error("preemption not possible", "requested_device", req) netIdx.Release() continue OUTER } @@ -312,7 +312,7 @@ OUTER: // Try offer again offer, sumAffinities, err = devAllocator.AssignDevice(req) if offer == nil { - iter.ctx.Logger().Named("binpack").Error(fmt.Sprintf("unexpected error, unable to create device offer after preempting:%v", err)) + iter.ctx.Logger().Named("binpack").Error("unexpected error, unable to create device offer after considering preemption", "error", err) continue OUTER } }