Add implementation for Stop Pod Sandbox
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
b01d9dcc10
commit
c0048118a0
1 changed files with 17 additions and 2 deletions
|
@ -158,8 +158,23 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
|
||||||
|
|
||||||
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
// StopPodSandbox stops the sandbox. If there are any running containers in the
|
||||||
// sandbox, they should be force terminated.
|
// sandbox, they should be force terminated.
|
||||||
func (s *Server) StopPodSandbox(context.Context, *pb.StopPodSandboxRequest) (*pb.StopPodSandboxResponse, error) {
|
func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxRequest) (*pb.StopPodSandboxResponse, error) {
|
||||||
return nil, nil
|
sbName := req.PodSandboxId
|
||||||
|
if *sbName == "" {
|
||||||
|
return nil, fmt.Errorf("PodSandboxConfig.Name should not be empty")
|
||||||
|
}
|
||||||
|
sb := s.state.sandboxes[*sbName]
|
||||||
|
if sb == nil {
|
||||||
|
return nil, fmt.Errorf("specified sandbox not found: %s", *sbName)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range sb.containers {
|
||||||
|
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 &pb.StopPodSandboxResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeletePodSandbox deletes the sandbox. If there are any running containers in the
|
// DeletePodSandbox deletes the sandbox. If there are any running containers in the
|
||||||
|
|
Loading…
Reference in a new issue