Skip to content

Commit 435aa93

Browse files
committed
Disable partial pulls (zstd:chunked) by default
Disable the storage.options.pull_options.enable_partial_images option by default, so that it will have to be explicitly enabled in order to be used. Update the apply-diff-from-staging-directory integration test to call the test helper binary directly, so that the configuration file the test writes won't have its settings overridden by command line options that the storage() test helper function adds. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
1 parent ec3af4e commit 435aa93

File tree

6 files changed

+70
-19
lines changed

6 files changed

+70
-19
lines changed

cmd/containers-storage/config.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/containers/storage"
7+
"github.com/containers/storage/pkg/mflag"
8+
"github.com/containers/storage/types"
9+
)
10+
11+
func config(flags *mflag.FlagSet, action string, m storage.Store, args []string) (int, error) {
12+
options, err := types.DefaultStoreOptions()
13+
if err != nil {
14+
return 1, fmt.Errorf("default: %+v", err)
15+
}
16+
if len(args) > 0 {
17+
if err = types.ReloadConfigurationFileIfNeeded(args[0], &options); err != nil {
18+
return 1, fmt.Errorf("reload: %+v", err)
19+
}
20+
}
21+
return outputJSON(options)
22+
}
23+
24+
func init() {
25+
commands = append(commands, command{
26+
names: []string{"config"},
27+
usage: "Print storage library configuration as JSON",
28+
minArgs: 0,
29+
maxArgs: 1,
30+
optionsHelp: "[configurationFile]",
31+
action: config,
32+
})
33+
}

docs/containers-storage-config.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## containers-storage-config 1 "November 2024"
2+
3+
## NAME
4+
containers-storage config - Output the configuration for the storage library
5+
6+
## SYNOPSIS
7+
**containers-storage** **config** [configurationFile]
8+
9+
## DESCRIPTION
10+
Reads and outputs the current configuration for the storage library, or the
11+
current configuration with the contents of a specified configuration file
12+
loaded in, in a JSON format.
13+
14+
## EXAMPLE
15+
**containers-storage config**
16+
17+
## SEE ALSO
18+
containers-storage-version(1)

docs/containers-storage.conf.5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ The `storage.options.pull_options` table supports the following keys:
102102

103103
**enable_partial_images="true"|"false"**
104104
Enable the "zstd:chunked" feature, which allows partial pulls, reusing
105-
content that already exists on the system. This is enabled by default,
106-
but can be explicitly disabled. For more on zstd:chunked, see
105+
content that already exists on the system. This is disabled by default,
106+
and must be explicitly enabled to be used. For more on zstd:chunked, see
107107
<https://github.com/containers/storage/blob/main/docs/containers-storage-zstd-chunked.md>.
108108
This is a "string bool": "false"|"true" (cannot be native TOML boolean)
109109

pkg/chunked/storage_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (c *chunkedDiffer) convertTarToZstdChunked(destDirectory string, payload *o
149149
func GetDiffer(ctx context.Context, store storage.Store, blobDigest digest.Digest, blobSize int64, annotations map[string]string, iss ImageSourceSeekable) (graphdriver.Differ, error) {
150150
pullOptions := store.PullOptions()
151151

152-
if !parseBooleanPullOption(pullOptions, "enable_partial_images", true) {
152+
if !parseBooleanPullOption(pullOptions, "enable_partial_images", false) {
153153
// If convertImages is set, the two options disagree whether fallback is permissible.
154154
// Right now, we enable it, but that’s not a promise; rather, such a configuration should ideally be rejected.
155155
return nil, newErrFallbackToOrdinaryLayerDownload(errors.New("partial images are disabled"))

storage.conf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
# /usr/containers/storage.conf
99
# /etc/containers/storage.conf
1010
# $HOME/.config/containers/storage.conf
11-
# $XDG_CONFIG_HOME/containers/storage.conf (If XDG_CONFIG_HOME is set)
11+
# $XDG_CONFIG_HOME/containers/storage.conf (if XDG_CONFIG_HOME is set)
1212
# See man 5 containers-storage.conf for more information
13-
# The "container storage" table contains all of the server options.
13+
# The "storage" table contains all of the server options.
1414
[storage]
1515

16-
# Default Storage Driver, Must be set for proper operation.
16+
# Default storage driver, must be set for proper operation.
1717
driver = "overlay"
1818

1919
# Temporary storage location
@@ -24,8 +24,8 @@ runroot = "/run/containers/storage"
2424
# driver_priority = ["overlay", "btrfs"]
2525

2626
# Primary Read/Write location of container storage
27-
# When changing the graphroot location on an SELINUX system, you must
28-
# ensure the labeling matches the default locations labels with the
27+
# When changing the graphroot location on an SELinux system, you must
28+
# ensure the labeling matches the default location's labels with the
2929
# following commands:
3030
# semanage fcontext -a -e /var/lib/containers/storage /NEWSTORAGEPATH
3131
# restorecon -R -v /NEWSTORAGEPATH
@@ -54,14 +54,14 @@ graphroot = "/var/lib/containers/storage"
5454
additionalimagestores = [
5555
]
5656

57-
# Options controlling how storage is populated when pulling images.
57+
# Options controlling how storage is populated when pulling images.
5858
[storage.options.pull_options]
5959
# Enable the "zstd:chunked" feature, which allows partial pulls, reusing
60-
# content that already exists on the system. This is enabled by default,
61-
# but can be explicitly disabled. For more on zstd:chunked, see
60+
# content that already exists on the system. This is disabled by default,
61+
# and must be explicitly enabled to be used. For more on zstd:chunked, see
6262
# https://github.com/containers/storage/blob/main/docs/containers-storage-zstd-chunked.md
6363
# This is a "string bool": "false" | "true" (cannot be native TOML boolean)
64-
# enable_partial_images = "true"
64+
# enable_partial_images = "false"
6565

6666
# Tells containers/storage to use hard links rather then create new files in
6767
# the image, if an identical file already existed in storage.

tests/apply-diff.bats

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,28 @@ driver="overlay"
7171
graphroot="$root"
7272
runroot="$runroot"
7373
74-
[storage.options]
75-
pull_options = {enable_partial_images = "true" }
74+
[storage.options.pull_options]
75+
enable_partial_images = "true"
7676
EOF
7777

7878
# Create a layer.
79-
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-layer
79+
CONTAINERS_STORAGE_CONF=$sconf run ${STORAGE_BINARY} create-layer
8080
[ "$status" -eq 0 ]
8181
[ "$output" != "" ]
8282
layer="$output"
8383

84-
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false applydiff-using-staging-dir $layer $SRC
84+
CONTAINERS_STORAGE_CONF=$sconf run ${STORAGE_BINARY} applydiff-using-staging-dir $layer $SRC
8585
[ "$status" -eq 0 ]
8686

8787
name=safe-image
88-
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-image --name $name $layer
88+
CONTAINERS_STORAGE_CONF=$sconf run ${STORAGE_BINARY} create-image --name $name $layer
8989
[ "$status" -eq 0 ]
9090

9191
ctrname=foo
92-
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false create-container --name $ctrname $name
92+
CONTAINERS_STORAGE_CONF=$sconf run ${STORAGE_BINARY} create-container --name $ctrname $name
9393
[ "$status" -eq 0 ]
9494

95-
CONTAINERS_STORAGE_CONF=$sconf run storage --debug=false mount $ctrname
95+
CONTAINERS_STORAGE_CONF=$sconf run ${STORAGE_BINARY} mount $ctrname
9696
[ "$status" -eq 0 ]
9797
mount="$output"
9898

0 commit comments

Comments
 (0)