server: sync ctr state before checking it

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-12-06 12:39:38 +01:00
parent 79073df3c2
commit 1b2d4f3d60
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
4 changed files with 92 additions and 2 deletions

View file

@ -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{}