Follow up to https://github.com/containers/storage/pull/1357
Podman tests suggest that do not need to use XDG_CONFIG_HOME if
storage.conf does not exists. In that case we fall back to
/etc/containers/storage.conf and /usr/share/containers/storage.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
HPC Customers noticed that storage was attempting to read files in /usr
and /etc, even though they set XDG_CONFIG_HOME, they expect to only read
config files in this directory.
Fixes: https://github.com/containers/podman/issues/15680
(Actually partial fixes), need to look at other config files.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This allows consumers of this library to rely on the in-memory default
rather than requiring a storage.conf.
Refers to https://github.com/containers/storage/pull/1279 and
1f647d954f
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
We now use the golang error wrapping format specifier `%w` instead of the
deprecated github.com/pkg/errors package.
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
when the configuration file was explicitly specified, all the graph
drivers options are copied, not only the ones allowed for rootless.
Closes: https://github.com/containers/storage/issues/1278
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
otherwise changes applied later to the object are propagated to the
copy in prevReloadConfig.storeOptions.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
if the CONTAINERS_STORAGE_CONF environment variable is set and the
specified file doesn't exist, then return an error.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Using init in libs is bad. init() has to be run every time the
application which imports this package starts. This slows down startup
time even if the application will never use this code path.
Instead use a sync.Once to only the config when it is required.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
CONTAINERS_STORAGE_CONF env var should overwrite the default path even
for the first config load at init time.
Fixescontainers/podman#14267
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Also add interfaces to allow callers to see the pull options.
While experimenting with pushing and pulling with zstd, I found
that storage pulloptions were not being used in rootless mode.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
when the container specifies some mappings to be applied, verify that
they are not overlapping and give a clearer error message.
Closes: https://github.com/containers/storage/issues/1127
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
If passing either just a runroot or both a runroot and a graphroot
GetStore() was returning when finding a match for JUST the graph root,
overriding the runroot and using a different location than specified
Also create two new helper functions which add the ability to retrieve and overwrite
the toml config in the user's storage.conf file
Signed-off-by: cdoern <cdoern@redhat.com>
While reloading from config files `graph` and `run` root could be set to
empty. We should fall back to default if they are empty.
See: https://github.com/containers/podman/issues/12467
Signed-off-by: Aditya Rajan <arajan@redhat.com>
Currently DefaultConfigFile does not report back the storage.conf file
that is actually used if /etc/containers/storage.conf exists it should
be reported back to the user. This issue was seen with Podman.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Man page says we support storage.conf in this directory, so if
system does not have /etc/containers/storage.conf we should use it.
Fixes: https://github.com/containers/storage/issues/1015
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Now expandEnvPath always fallbacks to filepath.Clean() when
filepath.EvalSymlinks() fails.
commit b4477c7a8b introduced the
regression.
This is useful in a user namespace when the permissions for the
storage path are not yet tweaked to allow access for all users.
Reported by: https://github.com/containers/buildah/pull/3450
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Currently if a user puts a typo into a storage.conf
or puts the keys in the wrong section, then tools using
container/storage ignore them. This patch will print them
as warnings, so that the user has some idea what is going on.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Other parts of the code are using this directory, so we end up
with us creating an empty directory.
I don't see a reason why we would just use this directory only if
the init program is systemd?
Fixes: https://github.com/containers/podman/issues/10782
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
The current code was hanging for me, this makes sure the path is
expanded properly when it is read.
Fixes: https://github.com/containers/podman/issues/10181
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Currently in Podman if we reset the CONTAINERS_STORAGE_CONF path, we get
the graph driver options from the original config file as well as the
options from the override path. This PR resets the storageconf to the
initial state when called multiple times.
Also if user sets STORAGE_OPTS="" then we should use it to override all
other storage options.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
The storage driver set in `/etc/containers/storage.conf` was ignored for rootless configurations.
Rootless configurations would use overlay or vfs by default.
If the STORAGE_DRIVER environment was variable set, this value would be used instead.
This commit changes this behavior to inherit the driver set in `/etc/containers/storage.conf`.
To inherit the driver in rootless configurations, the driver must be valid in a rootless context.
The valid rootless drivers are btrfs, overlay, and vfs at this time.
To remain consistent with previous behavior, the STORAGE_DRIVER environment variable supersedes any driver set in `/etc/containers/storage.conf` and does not need to be a valid rootless driver.
buildah's documentation for the `--storage-driver` command will need to be updated to reflect these changes.
Currently when we build podman bindings we are pulling in the entire
storage libraries, even though we only need a few structures and
functions.
Testing with the following program
```
package main
import (
"fmt"
"github.com/containers/storage/types"
)
func main() {
fmt.Println(types.GetRootlessRuntimeDir(0))
}
```
Removing types above gives me compile size of the the program
du -s t.old t.new
9640 t.before
3232 t.after
Currently these functions are being vendored into
containers/common/pkg/config, which leads to large size in podman-remote
and podman bindings.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>