Merge pull request #241 from sameo/topic/sandbox_remove
Make RemovePodSandbox idempotent
This commit is contained in:
commit
0fcb25cc97
2 changed files with 13 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
|
@ -26,6 +27,10 @@ const (
|
|||
podDefaultNamespace = "default"
|
||||
)
|
||||
|
||||
var (
|
||||
errSandboxIDEmpty = errors.New("PodSandboxId should not be empty")
|
||||
)
|
||||
|
||||
func (s *sandbox) addContainer(c *oci.Container) {
|
||||
s.containers.Add(c.Name(), c)
|
||||
}
|
||||
|
@ -60,7 +65,7 @@ type podSandboxRequest interface {
|
|||
func (s *Server) getPodSandboxFromRequest(req podSandboxRequest) (*sandbox, error) {
|
||||
sbID := req.GetPodSandboxId()
|
||||
if sbID == "" {
|
||||
return nil, fmt.Errorf("PodSandboxId should not be empty")
|
||||
return nil, errSandboxIDEmpty
|
||||
}
|
||||
|
||||
sandboxID, err := s.podIDIndex.Get(sbID)
|
||||
|
|
|
@ -18,7 +18,13 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
|||
logrus.Debugf("RemovePodSandboxRequest %+v", req)
|
||||
sb, err := s.getPodSandboxFromRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err == errSandboxIDEmpty {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := &pb.RemovePodSandboxResponse{}
|
||||
logrus.Warnf("could not get sandbox %s, it's probably been removed already: %v", req.GetPodSandboxId(), err)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
podInfraContainer := sb.infraContainer
|
||||
|
|
Loading…
Reference in a new issue