diff --git a/server/container_stop.go b/server/container_stop.go index ed01d278ac6..b4926597ab6 100644 --- a/server/container_stop.go +++ b/server/container_stop.go @@ -42,7 +42,6 @@ func (s *Server) StopContainer(ctx context.Context, req *types.StopContainerRequ log.Warnf(ctx, "NRI stop failed for container %q: %v", c.ID(), err) } - s.generateCRIEvent(ctx, c, types.ContainerEventType_CONTAINER_DELETED_EVENT) log.Infof(ctx, "Stopped container %s: %s", c.ID(), c.Description()) return &types.StopContainerResponse{}, nil } diff --git a/server/sandbox_stop_linux.go b/server/sandbox_stop_linux.go index e50fe3804c2..33f94f74a6e 100644 --- a/server/sandbox_stop_linux.go +++ b/server/sandbox_stop_linux.go @@ -94,7 +94,12 @@ func (s *Server) stopPodSandbox(ctx context.Context, sb *sandbox.Sandbox) error log.Infof(ctx, "Stopped pod sandbox: %s", sb.ID()) sb.SetStopped(ctx, true) - s.generateCRIEvent(ctx, sb.InfraContainer(), types.ContainerEventType_CONTAINER_STOPPED_EVENT) + + if podInfraContainer.Spoofed() { + // event generation would be needed in case of a spoofed infra container where there is no + // exit process that hits the handleExit() code. + s.generateCRIEvent(ctx, sb.InfraContainer(), types.ContainerEventType_CONTAINER_STOPPED_EVENT) + } return nil }