From 6eab35c6b552a9bc5879c0aaa64b49135e16fad8 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Fri, 23 Sep 2016 14:41:20 -0700 Subject: [PATCH] Fixup remove 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 c1f0dba5..6e7fe08a 100644 --- a/server/sandbox.go +++ b/server/sandbox.go @@ -266,21 +266,21 @@ func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxReque // RemovePodSandbox deletes the sandbox. If there are any running containers in the // sandbox, they should be force deleted. func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxRequest) (*pb.RemovePodSandboxResponse, 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" // Delete all the containers in the sandbox for _, c := range sb.containers.List() { if err := s.runtime.DeleteContainer(c); err != nil { - return nil, fmt.Errorf("failed to delete container %s in sandbox %s: %v", c.Name(), *sbName, err) + return nil, fmt.Errorf("failed to delete container %s in sandbox %s: %v", c.Name(), *sbID, err) } if podInfraContainer == c.Name() { continue @@ -292,9 +292,9 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR } // Remove the files related to the sandbox - podSandboxDir := filepath.Join(s.sandboxDir, *sbName) + podSandboxDir := filepath.Join(s.sandboxDir, *sbID) if err := os.RemoveAll(podSandboxDir); err != nil { - return nil, fmt.Errorf("failed to remove sandbox %s directory: %v", *sbName, err) + return nil, fmt.Errorf("failed to remove sandbox %s directory: %v", *sbID, err) } return &pb.RemovePodSandboxResponse{}, nil