Simplify task.Wait() a bit
@@ -147,22 +147,25 @@ func (t *task) Wait(ctx context.Context) (uint32, error) {
return UnknownExitStatus, err
}
<-t.pidSync
-evloop:
+
+ var e eventsapi.RuntimeEvent
+
for {
evt, err := eventstream.Recv()
if err != nil {
return UnknownExitStatus, err
}
- switch {
- case events.Is(evt.Event, &eventsapi.RuntimeEvent{}):
- var e eventsapi.RuntimeEvent
+ if !events.Is(evt.Event, &eventsapi.RuntimeEvent{}) {
+ continue
+ }
+
if err := events.UnmarshalEvent(evt.Event, &e); err != nil {
return UnknownExitStatus, err
}
if e.Type != tasktypes.Event_EXIT {
- continue evloop
+ continue
}
if e.ID == t.containerID && e.Pid == t.pid {
@@ -170,7 +173,6 @@ evloop:
}
}
}
-}
// Delete deletes the task and its runtime state
// it returns the exit status of the task and any errors that were encountered
