Skip to content

Commit

Permalink
fix custom snapshotter for sandbox/container run
Browse files Browse the repository at this point in the history
Related with containerd#6899
The patch fixs the handle of sandbox run and container create.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
  • Loading branch information
imeoer committed Aug 14, 2023
1 parent 1fbd703 commit 0959cdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/cri/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
return nil, err
}

snapshotter, err := c.snapshotterFromPodSandboxConfig(ctx, image.ID, sandboxConfig)
if err != nil {
return nil, err
}

// Set snapshotter before any other options.
opts := []containerd.NewContainerOpts{
containerd.WithSnapshotter(c.runtimeSnapshotter(ctx, ociRuntime)),
containerd.WithSnapshotter(snapshotter),
// Prepare container rootfs. This is always writeable even if
// the container wants a readonly rootfs since we want to give
// the runtime (runc) a chance to modify (e.g. to create mount
Expand Down
7 changes: 6 additions & 1 deletion pkg/cri/server/sandbox_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
}
sOpts = append(sOpts, extraSOpts...)

snapshotter, err := c.snapshotterFromPodSandboxConfig(ctx, image.ID, config)
if err != nil {
return nil, err
}

opts := []containerd.NewContainerOpts{
containerd.WithSnapshotter(c.runtimeSnapshotter(ctx, ociRuntime)),
containerd.WithSnapshotter(snapshotter),
customopts.WithNewSnapshot(id, containerdImage, sOpts...),
containerd.WithSpec(spec, specOpts...),
containerd.WithContainerLabels(sandboxLabels),
Expand Down

0 comments on commit 0959cdb

Please sign in to comment.