From 54b1b8b1df11d10852bcee2c25ab110857ce8348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Rop=C3=A9?= Date: Thu, 12 Jan 2023 17:13:41 +0100 Subject: [PATCH 1/2] Fix generated event name on stop container action. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a STOP action, cri-o was generating a CONTAINER_DELETED_EVENT instead of CONTAINER_STOPPED_EVENT. Signed-off-by: Julien Ropé --- server/container_stop.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/container_stop.go b/server/container_stop.go index ed01d278ac6..2baa4031ac0 100644 --- a/server/container_stop.go +++ b/server/container_stop.go @@ -42,7 +42,7 @@ 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) + s.generateCRIEvent(ctx, c, types.ContainerEventType_CONTAINER_STOPPED_EVENT) log.Infof(ctx, "Stopped container %s: %s", c.ID(), c.Description()) return &types.StopContainerResponse{}, nil } From cf4c22d66d1403c5908fab16642b160c13cbea82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Rop=C3=A9?= Date: Tue, 17 Jan 2023 13:28:11 +0100 Subject: [PATCH 2/2] runtimeVM: ignore missing shim path for deleted containers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating the container's status when it's already removed causes an error. We can ignore this error safely when we find the container was terminated already. Signed-off-by: Julien Ropé --- internal/oci/runtime_vm.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/oci/runtime_vm.go b/internal/oci/runtime_vm.go index c78a03989af..d1f7b1efbdd 100644 --- a/internal/oci/runtime_vm.go +++ b/internal/oci/runtime_vm.go @@ -635,6 +635,13 @@ func (r *runtimeVM) updateContainerStatus(ctx context.Context, c *Container) err addressPath := filepath.Join(c.BundlePath(), "address") data, err := os.ReadFile(addressPath) if err != nil { + // If the container is actually removed, this error is expected and should be ignored. + // In this case, the container's status should be "Stopped". + if c.state.Status == ContainerStateStopped { + log.Debugf(ctx, "Skipping status update for: %+v", c.state) + return nil + } + log.Warnf(ctx, "Failed to read shim address: %v", err) return errors.New("runtime not correctly setup") }