c8d: use the container's configured snapshotter where possible
While we currently do not provide an option to specify the snapshotter to use for individual containers (we may want to add this option in future), currently it already is possible to configure the snapshotter in the daemon configuration, which could (likely) cause issues when changing and restarting the daemon. This patch updates some code-paths that have the container available to use the snapshotter that's configured for the container (instead of the default snapshotter configured). There are still code-paths to be looked into, and a tracking ticket as well as some TODO's were added for those. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2fa8f54d08
commit
465cbccdaf
7 changed files with 11 additions and 6 deletions
|
@ -40,7 +40,7 @@ func (i *ImageService) Changes(ctx context.Context, container *container.Contain
|
|||
return nil, err
|
||||
}
|
||||
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
snapshotter := i.client.SnapshotService(container.Driver)
|
||||
|
||||
diffIDs := image.RootFS.DiffIDs
|
||||
parent, err := snapshotter.View(ctx, rnd.String(), identity.ChainID(diffIDs).String())
|
||||
|
|
|
@ -61,7 +61,7 @@ func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig)
|
|||
|
||||
var (
|
||||
differ = i.client.DiffService()
|
||||
sn = i.client.SnapshotService(i.snapshotter)
|
||||
sn = i.client.SnapshotService(container.Driver)
|
||||
)
|
||||
|
||||
// Don't gc me and clean the dirty data after 1 hour!
|
||||
|
@ -87,7 +87,7 @@ func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig)
|
|||
}
|
||||
|
||||
layers := append(manifest.Layers, diffLayerDesc)
|
||||
commitManifestDesc, err := writeContentsForImage(ctx, i.snapshotter, cs, imageConfig, layers)
|
||||
commitManifestDesc, err := writeContentsForImage(ctx, container.Driver, cs, imageConfig, layers)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
)
|
||||
|
||||
func (i *ImageService) PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(root string) error) error {
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
snapshotter := i.client.SnapshotService(c.Driver)
|
||||
mounts, err := snapshotter.Mounts(ctx, c.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -50,6 +50,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// TODO(thaJeztah): do we need to take multiple snapshotters into account? See https://github.com/moby/moby/issues/45273
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
sizeCache := make(map[digest.Digest]int64)
|
||||
snapshotSizeFn := func(d digest.Digest) (int64, error) {
|
||||
|
@ -177,6 +178,8 @@ func (i *ImageService) singlePlatformImage(ctx context.Context, contentStore con
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO(thaJeztah): do we need to take multiple snapshotters into account? See https://github.com/moby/moby/issues/45273
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
sizeCache := make(map[digest.Digest]int64)
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string,
|
|||
defer finishProgress()
|
||||
|
||||
opts = append(opts, containerd.WithPullUnpack)
|
||||
// TODO(thaJeztah): we may have to pass the snapshotter to use if the pull is part of a "docker run" (container create -> pull image if missing). See https://github.com/moby/moby/issues/45273
|
||||
opts = append(opts, containerd.WithPullSnapshotter(i.snapshotter))
|
||||
|
||||
// AppendInfoHandlerWrapper will annotate the image with basic information like manifest and layer digests as labels;
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
// Mount mounts the container filesystem in a temporary location, use defer imageService.Unmount
|
||||
// to unmount the filesystem when calling this
|
||||
func (i *ImageService) Mount(ctx context.Context, container *container.Container) error {
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
snapshotter := i.client.SnapshotService(container.Driver)
|
||||
mounts, err := snapshotter.Mounts(ctx, container.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -128,6 +128,7 @@ func (i *ImageService) ReleaseLayer(rwlayer layer.RWLayer) error {
|
|||
// called from disk_usage.go
|
||||
func (i *ImageService) LayerDiskUsage(ctx context.Context) (int64, error) {
|
||||
var allLayersSize int64
|
||||
// TODO(thaJeztah): do we need to take multiple snapshotters into account? See https://github.com/moby/moby/issues/45273
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
snapshotter.Walk(ctx, func(ctx context.Context, info snapshots.Info) error {
|
||||
usage, err := snapshotter.Usage(ctx, info.Name)
|
||||
|
@ -179,7 +180,7 @@ func (i *ImageService) GetContainerLayerSize(ctx context.Context, containerID st
|
|||
return 0, 0, err
|
||||
}
|
||||
|
||||
snapshotter := i.client.SnapshotService(i.snapshotter)
|
||||
snapshotter := i.client.SnapshotService(ctr.Driver)
|
||||
usage, err := snapshotter.Usage(ctx, containerID)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
|
|
Loading…
Add table
Reference in a new issue