Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multisnapshotter: set snapshotter in container config #2739

Merged
merged 1 commit into from
Mar 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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