sandbox: add all sandbox information to Create method

When call sandbox controller to create sandbox, we change the param from
sandbox id to total sandbox object to git all information to controller,
so that sandbox controller do not rely on the sandbox store anymore,
this is more decouple for the sandbox controller plugin inside
containerd, and it is neccesary for remote sandbox controller plugins as
it is not able to get sandbox from the sandbox store anymore.

Signed-off-by: Abel Feng <fshb1988@gmail.com>
This commit is contained in:
Abel Feng
2023-06-05 21:01:55 +08:00
committed by f00589305
parent 0707f68690
commit d2d434b7d6
9 changed files with 138 additions and 129 deletions

View File

@@ -94,7 +94,7 @@ func WithTimeout(timeout time.Duration) StopOpt {
// Shim lifetimes are now managed manually via sandbox API by the containerd's client.
type Controller interface {
// Create is used to initialize sandbox environment. (mounts, any)
Create(ctx context.Context, sandboxID string, opts ...CreateOpt) error
Create(ctx context.Context, sandboxInfo Sandbox, opts ...CreateOpt) error
// Start will start previously created sandbox.
Start(ctx context.Context, sandboxID string) (ControllerInstance, error)
// Platform returns target sandbox OS that will be used by Controller.

View File

@@ -40,13 +40,13 @@ func NewSandboxController(client api.ControllerClient) sandbox.Controller {
return &remoteSandboxController{client: client}
}
func (s *remoteSandboxController) Create(ctx context.Context, sandboxID string, opts ...sandbox.CreateOpt) error {
func (s *remoteSandboxController) Create(ctx context.Context, sandboxInfo sandbox.Sandbox, opts ...sandbox.CreateOpt) error {
var options sandbox.CreateOptions
for _, opt := range opts {
opt(&options)
}
_, err := s.client.Create(ctx, &api.ControllerCreateRequest{
SandboxID: sandboxID,
SandboxID: sandboxInfo.ID,
Rootfs: mount.ToProto(options.Rootfs),
Options: &anypb.Any{
TypeUrl: options.Options.GetTypeUrl(),