From 23ff5f8c5723724e110eb4b086aead6167e3dc8c Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 15 Feb 2024 15:35:19 +0100 Subject: [PATCH 1/2] storage: enable partial images by default by default enable pulling a partial image, it is still possible to disable the feature through the configuration file. Signed-off-by: Giuseppe Scrivano --- docs/containers-storage.conf.5.md | 2 +- pkg/chunked/storage_linux.go | 2 +- storage.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/containers-storage.conf.5.md b/docs/containers-storage.conf.5.md index e5f1019956..3950b8671a 100644 --- a/docs/containers-storage.conf.5.md +++ b/docs/containers-storage.conf.5.md @@ -84,7 +84,7 @@ The `storage.options` table supports the following options: **additionalimagestores**=[] Paths to additional container image stores. Usually these are read/only and stored on remote network shares. -**pull_options** = {enable_partial_images = "false", use_hard_links = "false", ostree_repos=""} +**pull_options** = {enable_partial_images = "true", use_hard_links = "false", ostree_repos=""} Allows specification of how storage is populated when pulling images. This option can speed the pulling process of images compressed with format zstd:chunked. Containers/storage looks diff --git a/pkg/chunked/storage_linux.go b/pkg/chunked/storage_linux.go index a42ea53f9d..7faccef1c1 100644 --- a/pkg/chunked/storage_linux.go +++ b/pkg/chunked/storage_linux.go @@ -1701,7 +1701,7 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff UncompressedDigest: uncompressedDigest, } - if !parseBooleanPullOption(c.storeOpts, "enable_partial_images", false) { + if !parseBooleanPullOption(c.storeOpts, "enable_partial_images", true) { return output, errors.New("enable_partial_images not configured") } diff --git a/storage.conf b/storage.conf index d91fa98fa9..0bb324c506 100644 --- a/storage.conf +++ b/storage.conf @@ -70,7 +70,7 @@ additionalimagestores = [ # Tells containers/storage where an ostree repository exists that might have # previously pulled content which can be used when attempting to avoid # pulling content from the container registry -pull_options = {enable_partial_images = "false", use_hard_links = "false", ostree_repos=""} +pull_options = {enable_partial_images = "true", use_hard_links = "false", ostree_repos=""} # Remap-UIDs/GIDs is the mapping from UIDs/GIDs as they should appear inside of # a container, to the UIDs/GIDs as they should appear outside of the container, From 8c1cf34a37e2311a6d52b5a6183cd0d45f16f8b2 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 15 Feb 2024 15:55:03 +0100 Subject: [PATCH 2/2] storage: move check for enable_partial_images to GetDiffer move the check for `enable_partial_images` to GetDiffer so that it doesn't attempt any operation if the feature is disabled. Signed-off-by: Giuseppe Scrivano --- pkg/chunked/storage_linux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/chunked/storage_linux.go b/pkg/chunked/storage_linux.go index 7faccef1c1..7b81d790d7 100644 --- a/pkg/chunked/storage_linux.go +++ b/pkg/chunked/storage_linux.go @@ -241,6 +241,10 @@ func GetDiffer(ctx context.Context, store storage.Store, blobDigest digest.Diges return nil, err } + if !parseBooleanPullOption(&storeOpts, "enable_partial_images", true) { + return nil, errors.New("enable_partial_images not configured") + } + _, hasZstdChunkedTOC := annotations[internal.ManifestChecksumKey] _, hasEstargzTOC := annotations[estargz.TOCJSONDigestAnnotation] @@ -1701,10 +1705,6 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions, diff UncompressedDigest: uncompressedDigest, } - if !parseBooleanPullOption(c.storeOpts, "enable_partial_images", true) { - return output, errors.New("enable_partial_images not configured") - } - // When the hard links deduplication is used, file attributes are ignored because setting them // modifies the source file as well. useHardLinks := parseBooleanPullOption(c.storeOpts, "use_hard_links", false)