From e2f3f2af830bc77135df3bfea42cef3cef0abcec Mon Sep 17 00:00:00 2001 From: Ace-Tang Date: Sat, 9 Mar 2019 20:19:14 +0800 Subject: [PATCH] multisnapshotter: set snapshotter in container config since we support multi snapshotter, set current snapshotter in container config, then plugin can know current used snapshotter. Signed-off-by: Ace-Tang --- daemon/mgr/container.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/daemon/mgr/container.go b/daemon/mgr/container.go index 39bae93ae..1454f337b 100644 --- a/daemon/mgr/container.go +++ b/daemon/mgr/container.go @@ -316,6 +316,9 @@ 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 { @@ -323,9 +326,15 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty } } + // 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{}