mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 11:36:56 +00:00
containerd-shim-kata-v2: add the service Shutdown support
Add the Shutdown api support to shutdown the shim. Signed-off-by: fupan <lifupan@gmail.com>
This commit is contained in:
parent
87f591a697
commit
642231ba25
@ -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) {
|
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) {
|
func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.StatsResponse, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user