diff --git a/scheduler/util.go b/scheduler/util.go index b0a3ed7c7..ee18e3000 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -614,22 +614,25 @@ func inplaceUpdate(ctx Context, eval *structs.Evaluation, job *structs.Job, continue } - // Restore the network offers from the existing allocation. + // Restore the network and device offers from the existing allocation. // We do not allow network resources (reserved/dynamic ports) // to be updated. This is guarded in taskUpdated, so we can // safely restore those here. for task, resources := range option.TaskResources { var networks structs.Networks + var devices []*structs.AllocatedDeviceResource if update.Alloc.AllocatedResources != nil { if tr, ok := update.Alloc.AllocatedResources.Tasks[task]; ok { networks = tr.Networks + devices = tr.Devices } } else if tr, ok := update.Alloc.TaskResources[task]; ok { networks = tr.Networks } - // Add thhe networks back + // Add the networks and devices back resources.Networks = networks + resources.Devices = devices } // Create a shallow copy @@ -892,15 +895,17 @@ func genericAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateTy return false, true, nil } - // Restore the network offers from the existing allocation. + // Restore the network and device offers from the existing allocation. // We do not allow network resources (reserved/dynamic ports) // to be updated. This is guarded in taskUpdated, so we can // safely restore those here. for task, resources := range option.TaskResources { var networks structs.Networks + var devices []*structs.AllocatedDeviceResource if existing.AllocatedResources != nil { if tr, ok := existing.AllocatedResources.Tasks[task]; ok { networks = tr.Networks + devices = tr.Devices } } else if tr, ok := existing.TaskResources[task]; ok { networks = tr.Networks @@ -908,6 +913,7 @@ func genericAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateTy // Add the networks back resources.Networks = networks + resources.Devices = devices } // Create a shallow copy