Cleanup sandbox interfaces
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -29,7 +29,11 @@ option go_package = "github.com/containerd/containerd/api/runtime/sandbox/v1;san
|
||||
// A typical example of sandbox is microVM or pause container - an entity that groups containers and/or
|
||||
// holds resources relevant for this group.
|
||||
service Sandbox {
|
||||
// StartSandbox will create/start a new sandbox instance
|
||||
// CreateSandbox will be called right after sandbox shim instance launched.
|
||||
// It is a good place to initialize sandbox environment.
|
||||
rpc CreateSandbox(CreateSandboxRequest) returns (CreateSandboxResponse);
|
||||
|
||||
// StartSandbox will start previsouly created sandbox.
|
||||
rpc StartSandbox(StartSandboxRequest) returns (StartSandboxResponse);
|
||||
|
||||
// StopSandbox will stop existing sandbox instance
|
||||
@@ -38,16 +42,6 @@ service Sandbox {
|
||||
// WaitSandbox blocks until sanbox exits.
|
||||
rpc WaitSandbox(WaitSandboxRequest) returns (WaitSandboxResponse);
|
||||
|
||||
// Update can be used to amend the state of currently running sandbox instance (depending on
|
||||
// implementation this can be used to resize/reacquire needed resources like RAM/CPU).
|
||||
rpc UpdateSandbox(UpdateSandboxRequest) returns (UpdateSandboxResponse);
|
||||
|
||||
// PauseSandbox will suspend currently running sandbox instance.
|
||||
rpc PauseSandbox(PauseSandboxRequest) returns (PauseSandboxResponse);
|
||||
|
||||
// ResumeSandbox will resuyme previously suspended sandbox instance.
|
||||
rpc ResumeSandbox(ResumeSandboxRequest) returns (ResumeSandboxResponse);
|
||||
|
||||
// SandboxStatus will return current status of the running sandbox instance
|
||||
rpc SandboxStatus(SandboxStatusRequest) returns (SandboxStatusResponse);
|
||||
|
||||
@@ -55,15 +49,22 @@ service Sandbox {
|
||||
rpc PingSandbox(PingRequest) returns (PingResponse);
|
||||
}
|
||||
|
||||
message StartSandboxRequest {
|
||||
message CreateSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
string bundle_path = 2;
|
||||
repeated containerd.types.Mount rootfs = 3;
|
||||
google.protobuf.Any options = 4;
|
||||
}
|
||||
|
||||
message CreateSandboxResponse {}
|
||||
|
||||
message StartSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message StartSandboxResponse {
|
||||
uint32 pid = 1;
|
||||
google.protobuf.Timestamp created_at = 2;
|
||||
}
|
||||
|
||||
message StopSandboxRequest {
|
||||
@@ -94,18 +95,6 @@ message SandboxStatusRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message PauseSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message PauseSandboxResponse {}
|
||||
|
||||
message ResumeSandboxRequest {
|
||||
string sandbox_id = 1;
|
||||
}
|
||||
|
||||
message ResumeSandboxResponse {}
|
||||
|
||||
message SandboxStatusResponse {
|
||||
string id = 1;
|
||||
uint32 pid = 2;
|
||||
|
||||
@@ -8,12 +8,10 @@ import (
|
||||
)
|
||||
|
||||
type SandboxService interface {
|
||||
CreateSandbox(context.Context, *CreateSandboxRequest) (*CreateSandboxResponse, error)
|
||||
StartSandbox(context.Context, *StartSandboxRequest) (*StartSandboxResponse, error)
|
||||
StopSandbox(context.Context, *StopSandboxRequest) (*StopSandboxResponse, error)
|
||||
WaitSandbox(context.Context, *WaitSandboxRequest) (*WaitSandboxResponse, error)
|
||||
UpdateSandbox(context.Context, *UpdateSandboxRequest) (*UpdateSandboxResponse, error)
|
||||
PauseSandbox(context.Context, *PauseSandboxRequest) (*PauseSandboxResponse, error)
|
||||
ResumeSandbox(context.Context, *ResumeSandboxRequest) (*ResumeSandboxResponse, error)
|
||||
SandboxStatus(context.Context, *SandboxStatusRequest) (*SandboxStatusResponse, error)
|
||||
PingSandbox(context.Context, *PingRequest) (*PingResponse, error)
|
||||
}
|
||||
@@ -21,6 +19,13 @@ type SandboxService interface {
|
||||
func RegisterSandboxService(srv *ttrpc.Server, svc SandboxService) {
|
||||
srv.RegisterService("containerd.runtime.sandbox.v1.Sandbox", &ttrpc.ServiceDesc{
|
||||
Methods: map[string]ttrpc.Method{
|
||||
"CreateSandbox": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req CreateSandboxRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.CreateSandbox(ctx, &req)
|
||||
},
|
||||
"StartSandbox": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req StartSandboxRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
@@ -42,27 +47,6 @@ func RegisterSandboxService(srv *ttrpc.Server, svc SandboxService) {
|
||||
}
|
||||
return svc.WaitSandbox(ctx, &req)
|
||||
},
|
||||
"UpdateSandbox": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req UpdateSandboxRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.UpdateSandbox(ctx, &req)
|
||||
},
|
||||
"PauseSandbox": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req PauseSandboxRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.PauseSandbox(ctx, &req)
|
||||
},
|
||||
"ResumeSandbox": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req ResumeSandboxRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return svc.ResumeSandbox(ctx, &req)
|
||||
},
|
||||
"SandboxStatus": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) {
|
||||
var req SandboxStatusRequest
|
||||
if err := unmarshal(&req); err != nil {
|
||||
@@ -91,6 +75,14 @@ func NewSandboxClient(client *ttrpc.Client) SandboxService {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *sandboxClient) CreateSandbox(ctx context.Context, req *CreateSandboxRequest) (*CreateSandboxResponse, error) {
|
||||
var resp CreateSandboxResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "CreateSandbox", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *sandboxClient) StartSandbox(ctx context.Context, req *StartSandboxRequest) (*StartSandboxResponse, error) {
|
||||
var resp StartSandboxResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "StartSandbox", req, &resp); err != nil {
|
||||
@@ -115,30 +107,6 @@ func (c *sandboxClient) WaitSandbox(ctx context.Context, req *WaitSandboxRequest
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *sandboxClient) UpdateSandbox(ctx context.Context, req *UpdateSandboxRequest) (*UpdateSandboxResponse, error) {
|
||||
var resp UpdateSandboxResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "UpdateSandbox", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *sandboxClient) PauseSandbox(ctx context.Context, req *PauseSandboxRequest) (*PauseSandboxResponse, error) {
|
||||
var resp PauseSandboxResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "PauseSandbox", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *sandboxClient) ResumeSandbox(ctx context.Context, req *ResumeSandboxRequest) (*ResumeSandboxResponse, error) {
|
||||
var resp ResumeSandboxResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "ResumeSandbox", req, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (c *sandboxClient) SandboxStatus(ctx context.Context, req *SandboxStatusRequest) (*SandboxStatusResponse, error) {
|
||||
var resp SandboxStatusResponse
|
||||
if err := c.client.Call(ctx, "containerd.runtime.sandbox.v1.Sandbox", "SandboxStatus", req, &resp); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user