Ensure that alloc updates preserve device offers
When an alloc is updated in-place, ensure that the allocated device are preserved and carried over to new alloc.
This commit is contained in:
parent
2ff2745374
commit
9f005201e2
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue