server: sync ctr state before checking it
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
79073df3c2
commit
1b2d4f3d60
4 changed files with 92 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/kubernetes-incubator/cri-o/oci"
|
||||
"golang.org/x/net/context"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
)
|
||||
|
@ -16,8 +17,14 @@ func (s *Server) StopContainer(ctx context.Context, req *pb.StopContainerRequest
|
|||
return nil, 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.UpdateStatus(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cStatus := s.runtime.ContainerStatus(c)
|
||||
if cStatus.Status != oci.ContainerStateStopped {
|
||||
if err := s.runtime.StopContainer(c); err != nil {
|
||||
return nil, fmt.Errorf("failed to stop container %s: %v", c.ID(), err)
|
||||
}
|
||||
}
|
||||
|
||||
resp := &pb.StopContainerResponse{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue