Skip to content

Commit

Permalink
Allow users to override default storage opts with --storage-opt
Browse files Browse the repository at this point in the history
We define in the man page that this overrides the default storage
options, but the code was appending to the existing options.

This PR also makes a change to allow users to specify --storage-opt="".
This will turn off all storage options.

#9852

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Apr 5, 2021
1 parent 3fae801 commit 69ace20
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/markdown/podman.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ specify additional options via the `--storage-opt` flag.

#### **\-\-storage-opt**=*value*

Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all.
Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all. If you specify --storage-opt="", no storage options will be used.

#### **\-\-syslog**=*true|false*

Expand Down
3 changes: 1 addition & 2 deletions libpod/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func WithStorageConfig(config storage.StoreOptions) RuntimeOption {
rt.storageConfig.GraphDriverOptions = make([]string, len(config.GraphDriverOptions))
copy(rt.storageConfig.GraphDriverOptions, config.GraphDriverOptions)
} else {
// append new options after what is specified in the config files
rt.storageConfig.GraphDriverOptions = append(rt.storageConfig.GraphDriverOptions, config.GraphDriverOptions...)
rt.storageConfig.GraphDriverOptions = config.GraphDriverOptions
}
setField = true
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/domain/infra/runtime_libpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo
// This should always be checked after storage-driver is checked
if len(cfg.StorageOpts) > 0 {
storageSet = true
storageOpts.GraphDriverOptions = cfg.StorageOpts
if len(cfg.StorageOpts) == 1 && cfg.StorageOpts[0] == "" {
storageOpts.GraphDriverOptions = []string{}
} else {
storageOpts.GraphDriverOptions = cfg.StorageOpts
}
}
if opts.migrate {
options = append(options, libpod.WithMigrate())
Expand Down
9 changes: 9 additions & 0 deletions test/system/005-info.bats
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ store.imageStore.number | 1

}

@test "podman info --storage-opt='' " {
skip_if_remote "--storage-opt flag is not supported for remote"
skip_if_rootless "storage opts are required for rootless running"
run_podman --storage-opt='' info
# Note this will not work in rootless mode, unless you specify
# storage-driver=vfs, until we have kernels that support rootless overlay
# mounts.
is "$output" ".*graphOptions: {}" "output includes graphOptions: {}"
}
# vim: filetype=sh

0 comments on commit 69ace20

Please sign in to comment.