Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
containerd-shim-kata-v2: add the service Shutdown support
Browse files Browse the repository at this point in the history
Add the Shutdown api support to shutdown the shim.

Signed-off-by: fupan <[email protected]>
  • Loading branch information
lifupan committed Nov 28, 2018
1 parent 87f591a commit 642231b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion containerd-shim-v2/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,27 @@ func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (*task
}

func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*ptypes.Empty, error) {
return nil, errdefs.ErrNotImplemented
s.Lock()
defer s.Unlock()

if len(s.containers) != 0 {
return empty, nil
}

defer os.Exit(0)

err := s.sandbox.Stop()
if err != nil {
logrus.WithField("sandbox", s.sandbox.ID()).Error("failed to stop sandbox")
return empty, err
}

err = s.sandbox.Delete()
if err != nil {
logrus.WithField("sandbox", s.sandbox.ID()).Error("failed to delete sandbox")
}

return empty, err
}

func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.StatsResponse, error) {
Expand Down

0 comments on commit 642231b

Please sign in to comment.