From 69a6d6fc28ee4d675bb038096a8dbf4366ae3676 Mon Sep 17 00:00:00 2001 From: Sai Ramesh Vanka Date: Thu, 27 Apr 2023 12:51:56 +0530 Subject: [PATCH] Fix events generated by Evented PLEG Fixes https://github.com/cri-o/cri-o/issues/6625 Signed-off-by: Sai Ramesh Vanka --- server/container_stop.go | 1 - server/sandbox_stop_linux.go | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 }