[sandbox] Fix panic when waiting for sandbox controller

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2022-11-28 13:29:21 -08:00
parent dbc6d33ac5
commit 9f4ba48839

View File

@ -296,7 +296,11 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
// but we don't care about sandbox TaskOOM right now, so it is fine.
go func() {
resp, err := controller.Wait(context.Background(), id)
if err != nil && err != context.Canceled && err != context.DeadlineExceeded {
if err != nil {
log.G(ctx).WithError(err).Error("failed to wait for sandbox controller, skipping exit event")
return
}
e := &eventtypes.TaskExit{
ContainerID: id,
ID: id,
@ -306,7 +310,6 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
ExitedAt: resp.ExitedAt,
}
c.eventMonitor.backOff.enBackOff(id, e)
}
}()
sandboxRuntimeCreateTimer.WithValues(labels["oci_runtime_type"]).UpdateSince(runtimeStart)