mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-12 21:27:02 +00:00
Merge pull request #1151 from sboeuf/fix_v2_shutdown
runtime-v2: Make sure Shutdown() only shuts the server down
This commit is contained in:
commit
45f72219f8
@ -386,6 +386,22 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAP
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take care of the use case where it is a sandbox.
|
||||||
|
// Right after the container representing the sandbox has
|
||||||
|
// been deleted, let's make sure we stop and delete the
|
||||||
|
// sandbox.
|
||||||
|
if c.cType.IsSandbox() {
|
||||||
|
if err = s.sandbox.Stop(); err != nil {
|
||||||
|
logrus.WithField("sandbox", s.sandbox.ID()).Error("failed to stop sandbox")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = s.sandbox.Delete(); err != nil {
|
||||||
|
logrus.WithField("sandbox", s.sandbox.ID()).Error("failed to delete sandbox")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &taskAPI.DeleteResponse{
|
return &taskAPI.DeleteResponse{
|
||||||
ExitStatus: c.exit,
|
ExitStatus: c.exit,
|
||||||
ExitedAt: c.time,
|
ExitedAt: c.time,
|
||||||
@ -654,26 +670,17 @@ 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) {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
|
||||||
|
|
||||||
if len(s.containers) != 0 {
|
if len(s.containers) != 0 {
|
||||||
|
s.Unlock()
|
||||||
return empty, nil
|
return empty, nil
|
||||||
}
|
}
|
||||||
|
s.Unlock()
|
||||||
|
|
||||||
defer os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
err := s.sandbox.Stop()
|
// This will never be called, but this is only there to make sure the
|
||||||
if err != nil {
|
// program can compile.
|
||||||
logrus.WithField("sandbox", s.sandbox.ID()).Error("failed to stop sandbox")
|
return empty, nil
|
||||||
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