diff --git a/server/container_remove.go b/server/container_remove.go index 1d1d67a2..161b3525 100644 --- a/server/container_remove.go +++ b/server/container_remove.go @@ -23,7 +23,7 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq } cState := s.runtime.ContainerStatus(c) - if cState.Status == oci.ContainerStateCreated || cState.Status == oci.ContainerStateRunning { + if cState.Status == oci.ContainerStateRunning { if err := s.runtime.StopContainer(c, -1); err != nil { return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err) } diff --git a/server/container_stop.go b/server/container_stop.go index 1ddee82f..506b9f47 100644 --- a/server/container_stop.go +++ b/server/container_stop.go @@ -21,7 +21,7 @@ func (s *Server) StopContainer(ctx context.Context, req *pb.StopContainerRequest return nil, err } cStatus := s.runtime.ContainerStatus(c) - if cStatus.Status != oci.ContainerStateStopped { + if cStatus.Status == oci.ContainerStateRunning { if err := s.runtime.StopContainer(c, req.Timeout); err != nil { return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err) } diff --git a/server/sandbox_remove.go b/server/sandbox_remove.go index cd4955f8..bba98e5f 100644 --- a/server/sandbox_remove.go +++ b/server/sandbox_remove.go @@ -41,7 +41,7 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR } cState := s.runtime.ContainerStatus(c) - if cState.Status == oci.ContainerStateCreated || cState.Status == oci.ContainerStateRunning { + if cState.Status == oci.ContainerStateRunning { if err := s.runtime.StopContainer(c, -1); err != nil { // Assume container is already stopped logrus.Warnf("failed to stop container %s: %v", c.Name(), err) diff --git a/server/sandbox_stop.go b/server/sandbox_stop.go index 55aa3d84..5484a1df 100644 --- a/server/sandbox_stop.go +++ b/server/sandbox_stop.go @@ -62,7 +62,7 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque return nil, err } cStatus := s.runtime.ContainerStatus(c) - if cStatus.Status != oci.ContainerStateStopped { + if cStatus.Status == oci.ContainerStateRunning { if err := s.runtime.StopContainer(c, -1); err != nil { return nil, fmt.Errorf("failed to stop container %s in pod sandbox %s: %v", c.Name(), sb.id, err) }