From 19926bc905f2bde742b39249f7951c7d29e7f6ab Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 19 Sep 2016 12:34:10 -0700 Subject: [PATCH] Check if container in a pod is already stopped before stopping it Signed-off-by: Mrunal Patel --- server/sandbox.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/sandbox.go b/server/sandbox.go index 2baf3242..a0418e06 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -226,8 +226,11 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v", c.Name(), *sbName, err) } } - if err := s.runtime.StopContainer(c); err != nil { - return nil, fmt.Errorf("failed to stop container %s in sandbox %s: %v", c.Name(), *sbName, err) + cStatus := s.runtime.ContainerStatus(c) + if cStatus.Status != "stopped" { + if err := s.runtime.StopContainer(c); err != nil { + return nil, fmt.Errorf("failed to stop container %s in sandbox %s: %v", c.Name(), *sbName, err) + } } }