[Sandbox] Add Wait and PID

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2022-02-09 12:52:37 -08:00
parent 0d165e6544
commit b7a36950f6
12 changed files with 1996 additions and 220 deletions

View File

@@ -22,7 +22,6 @@ import (
api "github.com/containerd/containerd/api/services/sandbox/v1"
"github.com/containerd/containerd/errdefs"
sb "github.com/containerd/containerd/sandbox"
"github.com/gogo/protobuf/types"
)
// sandboxRemoteController is a low level GRPC client for containerd's sandbox controller service
@@ -37,14 +36,13 @@ func NewSandboxRemoteController(client api.ControllerClient) sb.Controller {
return &sandboxRemoteController{client: client}
}
func (s *sandboxRemoteController) Start(ctx context.Context, sandboxID string) error {
if _, err := s.client.Start(ctx, &api.ControllerStartRequest{
SandboxID: sandboxID,
}); err != nil {
return errdefs.FromGRPC(err)
func (s *sandboxRemoteController) Start(ctx context.Context, sandboxID string) (uint32, error) {
resp, err := s.client.Start(ctx, &api.ControllerStartRequest{SandboxID: sandboxID})
if err != nil {
return 0, errdefs.FromGRPC(err)
}
return nil
return resp.Pid, nil
}
func (s *sandboxRemoteController) Shutdown(ctx context.Context, sandboxID string) error {
@@ -56,6 +54,15 @@ func (s *sandboxRemoteController) Shutdown(ctx context.Context, sandboxID string
return nil
}
func (s *sandboxRemoteController) Wait(ctx context.Context, sandboxID string) (*api.ControllerWaitResponse, error) {
resp, err := s.client.Wait(ctx, &api.ControllerWaitRequest{SandboxID: sandboxID})
if err != nil {
return nil, errdefs.FromGRPC(err)
}
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 {
@@ -82,11 +89,11 @@ func (s *sandboxRemoteController) Ping(ctx context.Context, sandboxID string) er
return nil
}
func (s *sandboxRemoteController) Status(ctx context.Context, sandboxID string) (*types.Any, error) {
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 {
return nil, errdefs.FromGRPC(err)
}
return resp.Status, nil
return resp, nil
}