server: do not guard runtime.StopContainer
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
3c0db0bece
commit
87d7296ea8
4 changed files with 8 additions and 25 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
@ -22,11 +21,8 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq
|
||||||
return nil, fmt.Errorf("failed to update container state: %v", err)
|
return nil, fmt.Errorf("failed to update container state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cState := s.runtime.ContainerStatus(c)
|
if err := s.runtime.StopContainer(c); err != nil {
|
||||||
if cState.Status == oci.ContainerStateCreated || cState.Status == oci.ContainerStateRunning {
|
return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err)
|
||||||
if err := s.runtime.StopContainer(c); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.runtime.DeleteContainer(c); err != nil {
|
if err := s.runtime.DeleteContainer(c); err != nil {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
@ -20,11 +19,8 @@ func (s *Server) StopContainer(ctx context.Context, req *pb.StopContainerRequest
|
||||||
if err := s.runtime.UpdateStatus(c); err != nil {
|
if err := s.runtime.UpdateStatus(c); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cStatus := s.runtime.ContainerStatus(c)
|
if err := s.runtime.StopContainer(c); err != nil {
|
||||||
if cStatus.Status != oci.ContainerStateStopped {
|
return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err)
|
||||||
if err := s.runtime.StopContainer(c); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &pb.StopContainerResponse{}
|
resp := &pb.StopContainerResponse{}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
@ -36,12 +35,8 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
return nil, fmt.Errorf("failed to update container state: %v", err)
|
return nil, fmt.Errorf("failed to update container state: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cState := s.runtime.ContainerStatus(c)
|
if err := s.runtime.StopContainer(c); err != nil {
|
||||||
if cState.Status == oci.ContainerStateCreated || cState.Status == oci.ContainerStateRunning {
|
return fmt.Errorf("failed to stop container %s: %v", c.Name(), err)
|
||||||
if err := s.runtime.StopContainer(c); err != nil {
|
|
||||||
// Assume container is already stopped
|
|
||||||
logrus.Warnf("failed to stop container %s: %v", c.Name(), err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.runtime.DeleteContainer(c); err != nil {
|
if err := s.runtime.DeleteContainer(c); err != nil {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
@ -46,11 +45,8 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque
|
||||||
if err := s.runtime.UpdateStatus(c); err != nil {
|
if err := s.runtime.UpdateStatus(c); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cStatus := s.runtime.ContainerStatus(c)
|
if err := s.runtime.StopContainer(c); err != nil {
|
||||||
if cStatus.Status != oci.ContainerStateStopped {
|
return nil, fmt.Errorf("failed to stop container %s in pod sandbox %s: %v", c.Name(), sb.id, err)
|
||||||
if err := s.runtime.StopContainer(c); err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to stop container %s in pod sandbox %s: %v", c.Name(), sb.id, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue