make sure that the runroot and graphroot are not empty otherwise we will
end up using an empty directory as path prefix and create files in the
current directory.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
when running in rootful mode, if it is present, prefer the override path
/etc/containers/storage.conf instead of using the default storage.conf
provided by the package under the /usr/share/containers/ directory.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This is an amend to https://github.com/containers/storage/pull/1460
That PR was not addressing the case when the system wide config had the
driver_priority option configured and the user had no config file of their
own. Then `getRootlessStorageOpts` would be called and it would override the
graph driver to "vfs".
With this commit we only override the graph driver if driver priority is
empty. Otherwise we propagate the driver priority into the storage options, so
that the driver autodetection works as expected.
Signed-off-by: Dan Čermák <dcermak@suse.com>
Currently we would display an error when the user does not specify a `driver` in
their config file. This has been present for historical reasons mostly to
prevent users from accidentally getting the vfs
driver (https://github.com/containers/storage/pull/1460#issuecomment-1370866271). Now
that most systems support the overlay driver natively, we can reduce this to a
warning and only warn about it if the driver_priority list is unset. If it is
provided, then clearly the user or the distribution wanted for c/storage to pick
a driver itself and the warning would be only confusing to users.
Signed-off-by: Dan Čermák <dcermak@suse.com>
Want to allow Podman to print helpful error message when
users runs out of UIDs to use with podman run --userns=auto.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Currently Podman warns when attempting to reset storage, if the
system wide storage.conf file
/usr/share/containers/storage.conf exists.
Since distros ship this, we need to allow Podman to check if the
default is the System default and therefore do not warn.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Currently running a simple container runs and stats configuration
storage.conf files multiple times on a simple container run.
This PR cuts the opens and stats in half by caching the first read.
This speeds up start by about 10-20 microseconds.
If container engines want to react to storage files changing, added a
new function UpdateStoreOptions to allow engines to reload options.
Fixes: https://github.com/containers/storage/issues/1403
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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>