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") } 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 }