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:
@@ -59,20 +59,13 @@ func init() {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sbPlugin, err := ic.GetByID(plugins.SandboxStorePlugin, "local")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
shims = shimPlugin.(*v2.ShimManager)
|
||||
publisher = exchangePlugin.(*exchange.Exchange)
|
||||
store = sbPlugin.(sandbox.Store)
|
||||
)
|
||||
|
||||
return &controllerLocal{
|
||||
shims: shims,
|
||||
store: store,
|
||||
publisher: publisher,
|
||||
}, nil
|
||||
},
|
||||
@@ -81,7 +74,6 @@ func init() {
|
||||
|
||||
type controllerLocal struct {
|
||||
shims *v2.ShimManager
|
||||
store sandbox.Store
|
||||
publisher events.Publisher
|
||||
}
|
||||
|
||||
@@ -106,8 +98,9 @@ func (c *controllerLocal) cleanupShim(ctx context.Context, sandboxID string, svc
|
||||
}
|
||||
}
|
||||
|
||||
func (c *controllerLocal) Create(ctx context.Context, sandboxID string, opts ...sandbox.CreateOpt) error {
|
||||
func (c *controllerLocal) Create(ctx context.Context, info sandbox.Sandbox, opts ...sandbox.CreateOpt) error {
|
||||
var coptions sandbox.CreateOptions
|
||||
sandboxID := info.ID
|
||||
for _, opt := range opts {
|
||||
opt(&coptions)
|
||||
}
|
||||
@@ -116,11 +109,6 @@ func (c *controllerLocal) Create(ctx context.Context, sandboxID string, opts ...
|
||||
return fmt.Errorf("sandbox %s already running: %w", sandboxID, errdefs.ErrAlreadyExists)
|
||||
}
|
||||
|
||||
info, err := c.store.Get(ctx, sandboxID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to query sandbox metadata from store: %w", err)
|
||||
}
|
||||
|
||||
shim, err := c.shims.Start(ctx, sandboxID, runtime.CreateOpts{
|
||||
Spec: info.Spec,
|
||||
RuntimeOptions: info.Runtime.Options,
|
||||
|
Reference in New Issue
Block a user