Merge pull request #7792 from mxpv/sb-shutdown

This commit is contained in:
Fu Wei
2022-12-15 13:37:35 +08:00
committed by GitHub
16 changed files with 448 additions and 259 deletions

View File

@@ -154,12 +154,22 @@ func (c *controllerLocal) Stop(ctx context.Context, in *api.ControllerStopReques
return &api.ControllerStopResponse{}, nil
}
func (c *controllerLocal) Delete(ctx context.Context, in *api.ControllerDeleteRequest, opts ...grpc.CallOption) (*api.ControllerDeleteResponse, error) {
func (c *controllerLocal) Shutdown(ctx context.Context, in *api.ControllerShutdownRequest, opts ...grpc.CallOption) (*api.ControllerShutdownResponse, error) {
svc, err := c.getSandbox(ctx, in.SandboxID)
if err != nil {
return nil, err
}
_, err = svc.ShutdownSandbox(ctx, &runtimeAPI.ShutdownSandboxRequest{SandboxID: in.SandboxID})
if err != nil {
return nil, errdefs.ToGRPC(fmt.Errorf("failed to shutdown sandbox: %w", err))
}
if err := c.shims.Delete(ctx, in.SandboxID); err != nil {
return nil, errdefs.ToGRPC(fmt.Errorf("failed to delete sandbox shim: %w", err))
}
return &api.ControllerDeleteResponse{}, nil
return &api.ControllerShutdownResponse{}, nil
}
func (c *controllerLocal) Wait(ctx context.Context, in *api.ControllerWaitRequest, opts ...grpc.CallOption) (*api.ControllerWaitResponse, error) {

View File

@@ -94,7 +94,7 @@ func (s *controllerService) Status(ctx context.Context, req *api.ControllerStatu
return s.local.Status(ctx, req)
}
func (s *controllerService) Delete(ctx context.Context, req *api.ControllerDeleteRequest) (*api.ControllerDeleteResponse, error) {
log.G(ctx).WithField("req", req).Debug("delete sandbox")
return s.local.Delete(ctx, req)
func (s *controllerService) Shutdown(ctx context.Context, req *api.ControllerShutdownRequest) (*api.ControllerShutdownResponse, error) {
log.G(ctx).WithField("req", req).Debug("shutdown sandbox")
return s.local.Shutdown(ctx, req)
}