ensure shutdown delay can be removed
This commit is contained in:
parent
9874e7b21d
commit
0d550049e9
|
@ -111,19 +111,18 @@ func (h *groupServiceHook) Update(req *interfaces.RunnerUpdateRequest) error {
|
|||
networks = req.Alloc.AllocatedResources.Shared.Networks
|
||||
}
|
||||
|
||||
// Update group service hook fields
|
||||
tg := req.Alloc.Job.LookupTaskGroup(h.group)
|
||||
h.networks = networks
|
||||
h.services = tg.Services
|
||||
h.canary = canary
|
||||
h.taskEnvBuilder.UpdateTask(req.Alloc, nil)
|
||||
|
||||
// Update shutdown delay
|
||||
var shutdown time.Duration
|
||||
if tg.ShutdownDelay != nil {
|
||||
shutdown = *tg.ShutdownDelay
|
||||
}
|
||||
|
||||
// Update group service hook fields
|
||||
h.networks = networks
|
||||
h.services = tg.Services
|
||||
h.canary = canary
|
||||
h.delay = shutdown
|
||||
h.taskEnvBuilder.UpdateTask(req.Alloc, nil)
|
||||
|
||||
// Create new task services struct with those new values
|
||||
newWorkloadServices := h.getWorkloadServices()
|
||||
|
|
|
@ -77,12 +77,21 @@ func TestGroupServiceHook_ShutdownDelayUpdate(t *testing.T) {
|
|||
})
|
||||
require.NoError(t, h.Prerun())
|
||||
|
||||
// Incease shutdown Delay
|
||||
alloc.Job.TaskGroups[0].ShutdownDelay = helper.TimeToPtr(15 * time.Second)
|
||||
req := &interfaces.RunnerUpdateRequest{Alloc: alloc}
|
||||
require.NoError(t, h.Update(req))
|
||||
|
||||
// Assert that update updated the delay value
|
||||
require.Equal(t, h.delay, 15*time.Second)
|
||||
|
||||
// Remove shutdown delay
|
||||
alloc.Job.TaskGroups[0].ShutdownDelay = nil
|
||||
req = &interfaces.RunnerUpdateRequest{Alloc: alloc}
|
||||
require.NoError(t, h.Update(req))
|
||||
|
||||
// Assert that update updated the delay value
|
||||
require.Equal(t, h.delay, 0*time.Second)
|
||||
}
|
||||
|
||||
// TestGroupServiceHook_GroupServices asserts group service hooks with group
|
||||
|
|
Loading…
Reference in a new issue