[sandbox] Cleanup interfaces
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
parent
de49745723
commit
85a49e4ee7
@ -3306,45 +3306,6 @@ file {
|
||||
json_name: "exitedAt"
|
||||
}
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerPauseRequest"
|
||||
field {
|
||||
name: "sandbox_id"
|
||||
number: 1
|
||||
label: LABEL_OPTIONAL
|
||||
type: TYPE_STRING
|
||||
json_name: "sandboxId"
|
||||
}
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerPauseResponse"
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerResumeRequest"
|
||||
field {
|
||||
name: "sandbox_id"
|
||||
number: 1
|
||||
label: LABEL_OPTIONAL
|
||||
type: TYPE_STRING
|
||||
json_name: "sandboxId"
|
||||
}
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerResumeResponse"
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerPingRequest"
|
||||
field {
|
||||
name: "sandbox_id"
|
||||
number: 1
|
||||
label: LABEL_OPTIONAL
|
||||
type: TYPE_STRING
|
||||
json_name: "sandboxId"
|
||||
}
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerPingResponse"
|
||||
}
|
||||
message_type {
|
||||
name: "ControllerStatusRequest"
|
||||
field {
|
||||
@ -3451,21 +3412,6 @@ file {
|
||||
input_type: ".containerd.services.sandbox.v1.ControllerWaitRequest"
|
||||
output_type: ".containerd.services.sandbox.v1.ControllerWaitResponse"
|
||||
}
|
||||
method {
|
||||
name: "Pause"
|
||||
input_type: ".containerd.services.sandbox.v1.ControllerPauseRequest"
|
||||
output_type: ".containerd.services.sandbox.v1.ControllerPauseResponse"
|
||||
}
|
||||
method {
|
||||
name: "Resume"
|
||||
input_type: ".containerd.services.sandbox.v1.ControllerResumeRequest"
|
||||
output_type: ".containerd.services.sandbox.v1.ControllerResumeResponse"
|
||||
}
|
||||
method {
|
||||
name: "Ping"
|
||||
input_type: ".containerd.services.sandbox.v1.ControllerPingRequest"
|
||||
output_type: ".containerd.services.sandbox.v1.ControllerPingResponse"
|
||||
}
|
||||
method {
|
||||
name: "Status"
|
||||
input_type: ".containerd.services.sandbox.v1.ControllerStatusRequest"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -89,9 +89,6 @@ service Controller {
|
||||
rpc Start(ControllerStartRequest) returns (ControllerStartResponse);
|
||||
rpc Shutdown(ControllerShutdownRequest) returns (ControllerShutdownResponse);
|
||||
rpc Wait(ControllerWaitRequest) returns (ControllerWaitResponse);
|
||||
rpc Pause(ControllerPauseRequest) returns (ControllerPauseResponse);
|
||||
rpc Resume(ControllerResumeRequest) returns (ControllerResumeResponse);
|
||||
rpc Ping(ControllerPingRequest) returns (ControllerPingResponse);
|
||||
rpc Status(ControllerStatusRequest) returns (ControllerStatusResponse);
|
||||
}
|
||||
|
||||
@ -122,24 +119,6 @@ message ControllerWaitResponse {
|
||||
google.protobuf.Timestamp exited_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message ControllerPauseRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message ControllerPauseResponse {}
|
||||
|
||||
message ControllerResumeRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message ControllerResumeResponse {}
|
||||
|
||||
message ControllerPingRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message ControllerPingResponse {}
|
||||
|
||||
message ControllerStatusRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ var Command = cli.Command{
|
||||
runCommand,
|
||||
listCommand,
|
||||
removeCommand,
|
||||
pingCommand,
|
||||
},
|
||||
}
|
||||
|
||||
@ -177,30 +176,3 @@ var removeCommand = cli.Command{
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var pingCommand = cli.Command{
|
||||
Name: "ping",
|
||||
ArgsUsage: "<id> [<id>, ...]",
|
||||
Usage: "ping sandbox",
|
||||
Action: func(context *cli.Context) error {
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
for _, id := range context.Args() {
|
||||
sandbox, err := client.LoadSandbox(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to load sandbox %s: %w", id, err)
|
||||
}
|
||||
|
||||
err = sandbox.Ping(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to ping %s: %w", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
18
sandbox.go
18
sandbox.go
@ -47,12 +47,6 @@ type Sandbox interface {
|
||||
Wait(ctx context.Context) (<-chan ExitStatus, error)
|
||||
// Delete removes sandbox from the metadata store.
|
||||
Delete(ctx context.Context) error
|
||||
// Pause will freeze running sandbox instance
|
||||
Pause(ctx context.Context) error
|
||||
// Resume will unfreeze previously paused sandbox instance
|
||||
Resume(ctx context.Context) error
|
||||
// Ping will check whether existing sandbox instance alive
|
||||
Ping(ctx context.Context) error
|
||||
}
|
||||
|
||||
type sandboxClient struct {
|
||||
@ -127,18 +121,6 @@ func (s *sandboxClient) Delete(ctx context.Context) error {
|
||||
return s.client.SandboxStore().Delete(ctx, s.ID())
|
||||
}
|
||||
|
||||
func (s *sandboxClient) Pause(ctx context.Context) error {
|
||||
return s.client.SandboxController().Pause(ctx, s.ID())
|
||||
}
|
||||
|
||||
func (s *sandboxClient) Resume(ctx context.Context) error {
|
||||
return s.client.SandboxController().Resume(ctx, s.ID())
|
||||
}
|
||||
|
||||
func (s *sandboxClient) Ping(ctx context.Context) error {
|
||||
return s.client.SandboxController().Ping(ctx, s.ID())
|
||||
}
|
||||
|
||||
// NewSandbox creates new sandbox client
|
||||
func (c *Client) NewSandbox(ctx context.Context, sandboxID string, opts ...NewSandboxOpts) (Sandbox, error) {
|
||||
if sandboxID == "" {
|
||||
|
@ -49,14 +49,6 @@ type Controller interface {
|
||||
Shutdown(ctx context.Context, sandboxID string) error
|
||||
// Wait blocks until sandbox process exits.
|
||||
Wait(ctx context.Context, sandboxID string) (*sandbox.ControllerWaitResponse, error)
|
||||
// Pause will freeze running sandbox instance.
|
||||
// Shim implementations may return ErrNotImplemented if this is out of scope of a given sandbox.
|
||||
Pause(ctx context.Context, sandboxID string) error
|
||||
// Resume will unfreeze previously paused sandbox instance
|
||||
Resume(ctx context.Context, sandboxID string) error
|
||||
// Ping is a lightweight API call to check whether sandbox instance is still alive (e.g. quick livability check).
|
||||
// This should not involve any complex logic and containerd will not debug log it as it might be called quite often.
|
||||
Ping(ctx context.Context, sandboxID string) error
|
||||
// Status will query sandbox process status. It is heavier than Ping call and must be used whenever you need to
|
||||
// gather metadata about current sandbox state (status, uptime, resource use, etc).
|
||||
Status(ctx context.Context, sandboxID string) (*sandbox.ControllerStatusResponse, error)
|
||||
|
@ -63,32 +63,6 @@ func (s *sandboxRemoteController) Wait(ctx context.Context, sandboxID string) (*
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *sandboxRemoteController) Pause(ctx context.Context, sandboxID string) error {
|
||||
_, err := s.client.Pause(ctx, &api.ControllerPauseRequest{SandboxID: sandboxID})
|
||||
if err != nil {
|
||||
return errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sandboxRemoteController) Resume(ctx context.Context, sandboxID string) error {
|
||||
_, err := s.client.Resume(ctx, &api.ControllerResumeRequest{SandboxID: sandboxID})
|
||||
if err != nil {
|
||||
return errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sandboxRemoteController) Ping(ctx context.Context, sandboxID string) error {
|
||||
if _, err := s.client.Ping(ctx, &api.ControllerPingRequest{SandboxID: sandboxID}); err != nil {
|
||||
return errdefs.FromGRPC(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *sandboxRemoteController) Status(ctx context.Context, sandboxID string) (*api.ControllerStatusResponse, error) {
|
||||
resp, err := s.client.Status(ctx, &api.ControllerStatusRequest{SandboxID: sandboxID})
|
||||
if err != nil {
|
||||
|
@ -32,7 +32,6 @@ import (
|
||||
proto "github.com/containerd/containerd/runtime/v2/task"
|
||||
"github.com/containerd/containerd/sandbox"
|
||||
"github.com/containerd/containerd/services"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@ -165,51 +164,6 @@ func (c *controllerLocal) Wait(ctx context.Context, in *api.ControllerWaitReques
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *controllerLocal) Pause(ctx context.Context, in *api.ControllerPauseRequest, opts ...grpc.CallOption) (*api.ControllerPauseResponse, error) {
|
||||
svc, err := c.getSandbox(ctx, in.SandboxID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := svc.PauseSandbox(ctx, &proto.PauseSandboxRequest{
|
||||
SandboxID: in.SandboxID,
|
||||
}); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to resume sandbox %s", in.SandboxID)
|
||||
}
|
||||
|
||||
return &api.ControllerPauseResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *controllerLocal) Resume(ctx context.Context, in *api.ControllerResumeRequest, opts ...grpc.CallOption) (*api.ControllerResumeResponse, error) {
|
||||
svc, err := c.getSandbox(ctx, in.SandboxID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := svc.ResumeSandbox(ctx, &proto.ResumeSandboxRequest{
|
||||
SandboxID: in.SandboxID,
|
||||
}); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to resume sandbox %s", in.SandboxID)
|
||||
}
|
||||
|
||||
return &api.ControllerResumeResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *controllerLocal) Ping(ctx context.Context, in *api.ControllerPingRequest, opts ...grpc.CallOption) (*api.ControllerPingResponse, error) {
|
||||
svc, err := c.getSandbox(ctx, in.SandboxID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := svc.PingSandbox(ctx, &proto.PingRequest{
|
||||
SandboxID: in.SandboxID,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &api.ControllerPingResponse{}, nil
|
||||
}
|
||||
|
||||
func (c *controllerLocal) Status(ctx context.Context, in *api.ControllerStatusRequest, opts ...grpc.CallOption) (*api.ControllerStatusResponse, error) {
|
||||
svc, err := c.getSandbox(ctx, in.SandboxID)
|
||||
if err != nil {
|
||||
|
@ -83,20 +83,6 @@ func (s *controllerService) Wait(ctx context.Context, req *api.ControllerWaitReq
|
||||
return s.local.Wait(ctx, req)
|
||||
}
|
||||
|
||||
func (s *controllerService) Pause(ctx context.Context, req *api.ControllerPauseRequest) (*api.ControllerPauseResponse, error) {
|
||||
log.G(ctx).WithField("req", req).Debug("pause sandbox")
|
||||
return s.local.Pause(ctx, req)
|
||||
}
|
||||
|
||||
func (s *controllerService) Resume(ctx context.Context, req *api.ControllerResumeRequest) (*api.ControllerResumeResponse, error) {
|
||||
log.G(ctx).WithField("req", req).Debug("resume sandbox")
|
||||
return s.local.Resume(ctx, req)
|
||||
}
|
||||
|
||||
func (s *controllerService) Ping(ctx context.Context, req *api.ControllerPingRequest) (*api.ControllerPingResponse, error) {
|
||||
return s.local.Ping(ctx, req)
|
||||
}
|
||||
|
||||
func (s *controllerService) Status(ctx context.Context, req *api.ControllerStatusRequest) (*api.ControllerStatusResponse, error) {
|
||||
log.G(ctx).WithField("req", req).Debug("sandbox status")
|
||||
return s.local.Status(ctx, req)
|
||||
|
Loading…
Reference in New Issue
Block a user