Skip to content

Commit

Permalink
multisnapshotter: set snapshotter in container config
Browse files Browse the repository at this point in the history
since we support multi snapshotter, set current snapshotter in container
config, then plugin can know current used snapshotter.

Signed-off-by: Ace-Tang <aceapril@126.com>
  • Loading branch information
Ace-Tang authored and fuweid committed Mar 10, 2019
1 parent f474bca commit 7e2e266
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,25 @@ func (mgr *ContainerManager) Restore(ctx context.Context) error {

// Create checks passed in parameters and create a Container object whose status is set at Created.
func (mgr *ContainerManager) Create(ctx context.Context, name string, config *types.ContainerCreateConfig) (resp *types.ContainerCreateResp, err error) {
currentSnapshotter := ctrd.CurrentSnapshotterName(ctx)
config.Snapshotter = currentSnapshotter

if mgr.containerPlugin != nil {
logrus.Infof("invoke container pre-create hook in plugin")
if ex := mgr.containerPlugin.PreCreate(config); ex != nil {
return nil, errors.Wrapf(ex, "pre-create plugin point execute failed")
}
}

// Attention, since we support multi snapshotter, if snapshotter not changed,
// means plugin not change it, so remove value in case to effect origin logic
if config.Snapshotter == currentSnapshotter {
config.Snapshotter = ""
}

// NOTE: choose snapshotter, snapshotter can only be set
// through containerPlugin in Create function
ctx = ctrd.WithSnapshotter(ctx, config.ContainerConfig.Snapshotter)
ctx = ctrd.WithSnapshotter(ctx, config.Snapshotter)

// cleanup allocated resources when failed
cleanups := []func() error{}
Expand Down

0 comments on commit 7e2e266

Please sign in to comment.