Move loop check to before sleep

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2021-07-13 11:54:33 -07:00
parent 2e8a572dfd
commit 18321f539c
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -81,7 +81,7 @@ version = 2
task.Kill(ctx, syscall.SIGKILL)
begin := time.Now()
deadline := begin.Add(interval).Add(epsilon)
for time.Now().Before(deadline) {
for {
status, err := task.Status(ctx)
now := time.Now()
if err != nil {
@ -97,6 +97,9 @@ version = 2
return
}
}
if time.Now().After(deadline) {
break
}
time.Sleep(epsilon)
}
t.Fatalf("%v: the task was not restarted in %s + %s",