From 2066b68791d550f424f30971849056c9b9743f9a Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 23 Sep 2016 14:34:31 -0700 Subject: [PATCH] Fixup stop sandbox logic Signed-off-by: Mrunal Patel --- server/sandbox.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/sandbox.go b/server/sandbox.go index e43b0b83..c1f0dba5 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -231,16 +231,16 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR // StopPodSandbox stops the sandbox. If there are any running containers in the // sandbox, they should be force terminated. func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxRequest) (*pb.StopPodSandboxResponse, error) { - sbName := req.PodSandboxId - if *sbName == "" { + sbID := req.PodSandboxId + if *sbID == "" { return nil, fmt.Errorf("PodSandboxId should not be empty") } - sb := s.getSandbox(*sbName) + sb := s.getSandbox(*sbID) if sb == nil { - return nil, fmt.Errorf("specified sandbox not found: %s", *sbName) + return nil, fmt.Errorf("specified sandbox not found: %s", *sbID) } - podInfraContainer := *sbName + "-infra" + podInfraContainer := sb.name + "-infra" for _, c := range sb.containers.List() { if podInfraContainer == c.Name() { podNamespace := "" @@ -248,14 +248,14 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque if err != nil { return nil, err } - if err := s.netPlugin.TearDownPod(netnsPath, podNamespace, *sbName, podInfraContainer); err != nil { - return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v", c.Name(), *sbName, err) + if err := s.netPlugin.TearDownPod(netnsPath, podNamespace, *sbID, podInfraContainer); err != nil { + return nil, fmt.Errorf("failed to destroy network for container %s in sandbox %s: %v", c.Name(), *sbID, 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) + return nil, fmt.Errorf("failed to stop container %s in sandbox %s: %v", c.Name(), *sbID, err) } } }