emit TaskRestartSignal event on vault restart

When Vault token expires and task is restarted, emit `TaskRestartSignal`
similar to v0.8.7
This commit is contained in:
Mahmood Ali 2019-02-22 14:45:17 -05:00
parent 8cb4bbcc08
commit 32551fb0e5
2 changed files with 11 additions and 5 deletions

View File

@ -1420,21 +1420,27 @@ func TestTaskRunner_VaultManager_Restart(t *testing.T) {
return false, fmt.Errorf("no events yet")
}
// TODO: check for RestartSignal too - 0.8 sent that event, but not 0.9
foundRestarting := false
foundRestartSignal, foundRestarting := false, false
for _, e := range state.Events {
if e.Type == structs.TaskRestarting {
switch e.Type {
case structs.TaskRestartSignal:
foundRestartSignal = true
case structs.TaskRestarting:
foundRestarting = true
}
}
if !foundRestartSignal {
return false, fmt.Errorf("no restart signal event yet: %#v", state.Events)
}
if !foundRestarting {
return false, fmt.Errorf("no restarting event yet: %#v", state.Events)
}
lastEvent := state.Events[len(state.Events)-1]
if lastEvent.Type != structs.TaskStarted {
return false, fmt.Errorf("expected last event to be task restarting but was %#v", lastEvent)
return false, fmt.Errorf("expected last event to be task starting but was %#v", lastEvent)
}
return true, nil
}, func(err error) {

View File

@ -254,7 +254,7 @@ OUTER:
case structs.VaultChangeModeRestart:
const noFailure = false
h.lifecycle.Restart(h.ctx,
structs.NewTaskEvent(structs.TaskRestarting).
structs.NewTaskEvent(structs.TaskRestartSignal).
SetDisplayMessage("Vault: new Vault token acquired"), false)
case structs.VaultChangeModeNoop:
fallthrough