Commit Graph

58 Commits

Author SHA1 Message Date
Kir Kolyshkin fd5483f4a8 all: use strings.Cut{Prefix,Suffix} where appropriate
Functions strings.CutPrefix and strings.CutSuffix are available
since Go 1.20 and can be used instead of strings.Has* counterparts
when the latter is followed by removing the prefix or suffix.

This simplifies the code a bit, allowing for less mistakes.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-09-19 17:03:19 -07:00
Miloslav Trmač 412ff916c2 Remove various unused parameters
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-10 23:54:30 +02:00
Giuseppe Scrivano 2d959dd4bf
store: drop remap-[ug]ids
drop the possibility to configure a remapping for all the layers in
the storage.

The feature dates back to the initial fork from Docker, that supported
a single user namespace where all the images were pulled. It was never
used by the container tools since we have a finer control of the user
namespaces.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-24 13:15:04 +02:00
Giuseppe Scrivano de0900aab7
types: use fileutils.{Le,E}xist()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-08 16:07:27 +02:00
Giuseppe Scrivano b0885dfba9
store: drop rootless from arguments
drop the rootless argument from DefaultStoreOptions and
UpdateStoreOptions since this can be retrieved internally through the
unshare package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-16 21:13:28 +01:00
Giuseppe Scrivano c72a594c83
types: use functionalities from pkg/homedir
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-16 08:36:21 +01:00
Daniel J Walsh 42d1d96371
Run codespell on code
Cleanup description of imagestore.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-15 06:16:12 -04:00
Kevin Hannon 91da0c2be7 add documentation on imagestore and add a warning if set
Signed-off-by: Kevin Hannon <kehannon@redhat.com>
2023-08-28 10:35:41 -04:00
Aditya R 2bcafa5897
options,rootless: honor imagestore from config file
Honor `imagestore` option from config file for rootless setups.

Fixes issues in: https://github.com/containers/podman/pull/18224

Signed-off-by: Aditya R <arajan@redhat.com>
2023-06-16 12:56:04 +05:30
Aditya R e31225e1f9
types/options: check prior drivers using readdir
Fetch prior drivers if any using `ReadDir` and looking for traces of
`%s-images` dirs if present already on the system where `%s` is the
prior driver.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-06-12 17:48:51 +05:30
Daniel J Walsh 55ee2d1929
Merge pull request #1618 from flouthoc/default-vfs-old-users
options: keep using prior drivers if found
2023-05-26 07:44:21 -04:00
Toshiki Sonoda 01fccaa58f options: enable Remap-User/Group setting
Remap-User/Group setting is always override by
Remap-UIDs/GIDs setting and ignored.

This commit enables Remap-User/Group setting.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-05-26 15:42:26 +09:00
Aditya R 9ef15e4d49
options: keep using prior drivers if found
There is no need for `vfs` to be the default storage driver since kernel
>= 5.13 supports `overlay` natively however there is use-case for users
who don't had any configs and they started using `vfs` in a default
manner following check is a hack to keep `buildah` and `podman` working
for such users.

See: https://github.com/containers/storage/pull/1571 for prior
discussions.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-05-26 05:39:55 +05:30
Daniel J Walsh 4428f8b775
Merge pull request #1549 from flouthoc/pull-store
store: add support to split filesystem using `imagestore`
2023-04-17 16:55:03 -04:00
Giuseppe Scrivano e3b18ab721
types: try harder to use overlay with rootless
if there are no configuration files present, attempt to use overlay
for rootless if fuse-overlayfs is installed or if the kernel is >= 5.13.

Closes: https://github.com/containers/storage/issues/1570

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-04-17 09:47:50 +02:00
Aditya R 30775d4b2b
store: add support to split ImageStore
Allow storage users to split the filesystem of containers vs image
store, `imagestore` if configured will pull images in image storage
instead of the `graphRoot` while keeping the other parts still in the
originally configured `graphRoot`.

overlay: set workdir and upperdir according to splitstore
If splitstore is set `workdir` and `upperdir` must go into the
splitstore i.e `graphRoot`.

Signed-off-by: Aditya R <arajan@redhat.com>
2023-04-14 17:34:27 +05:30
Giuseppe Scrivano 9ebdbd9d9d
options: reject empty runroot or graphroot
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>
2023-02-16 15:52:40 +01:00
Daniel J Walsh 0ee26255cd
Run codespell on codebase
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-09 12:27:59 -05:00
Dan Čermák df0cb3234e
Only override the graphdriver to vfs if the priority is unset
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>
2023-01-16 09:03:42 +01:00
Dan Čermák b2b2fefb3e
Only warn about 'driver' not being set if the priority list is unset
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>
2023-01-06 08:43:46 +01:00
Dan Čermák 881ac4864a
Make the priority for picking the storage driver configurable
This fixes https://github.com/containers/storage/issues/1457

Co-authored-by: Valentin Rothberg <vrothberg@redhat.com>
Signed-off-by: Dan Čermák <dcermak@suse.com>
2023-01-05 12:38:33 +01:00
Alexander Larsson 522b67c944 Add new storage.conf option "transient_store"
This just adds the support for setting and handling this key, it
doesn't really do anything yet.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-11-14 16:36:30 +01:00
Daniel J Walsh 68a0b369a2
Expose System wide config file
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>
2022-10-26 12:10:09 -04:00
Daniel J Walsh 9e06c38dfe
Only read storage.conf once
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>
2022-10-20 08:39:06 -04:00
Miloslav Trmač f42467020f Misc. warning cleanups
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:53:06 +02:00
Daniel J Walsh f75d738e63
Use system defaults if storage.conf does not exist in XDG_CONFIG_HOME
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>
2022-09-27 14:21:54 -04:00
Daniel J Walsh 9415b88c35
If XDG_CONFIG_HOME env is set we should use it and ignore defaults
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>
2022-09-23 15:40:13 -04:00
Sascha Grunert a10dcf45f5
Do not error if no storage.conf exists
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>
2022-07-14 10:37:00 +02:00
Giuseppe Scrivano cbb1446d16
options: copy all options on explicit config file
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>
2022-07-02 16:04:54 +02:00
Giuseppe Scrivano 63f6bba7bb
options: store a copy for prevReloadConfig
otherwise changes applied later to the object are propagated to the
copy in prevReloadConfig.storeOptions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-07-02 16:04:54 +02:00
Giuseppe Scrivano 880f7a7b34
options: treat missing $CONTAINERS_STORAGE_CONF as error
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>
2022-07-02 16:04:54 +02:00
Giuseppe Scrivano 1f647d954f
types: propagate configuration load errors
if any error happens when loading the default configuration file,
report it to the caller.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-07-02 16:04:54 +02:00
Giuseppe Scrivano 8e9ae4fd4b
options: fix function name
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-07-01 22:50:31 +02:00
Paul Holzinger 43bc333374
types: do not load storage.conf at init time
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>
2022-06-01 16:26:49 +02:00
Paul Holzinger 07530efd08
storage.conf: respect CONTAINERS_STORAGE_CONF env
CONTAINERS_STORAGE_CONF env var should overwrite the default path even
for the first config load at init time.

Fixes containers/podman#14267

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-06-01 16:23:55 +02:00
Valentin Rothberg b6be89d47f types: logrus: remove trailing dots
Not needed by the log convention in the rest of the code.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-17 13:56:38 +02:00
Valentin Rothberg e1ebdadf52 types: fix typo in warning
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-17 13:56:38 +02:00
Daniel J Walsh b05b3b44e2
PullOptions should work for rootless users also
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>
2022-05-16 16:05:15 -04:00
Doug Rabson ae67ca335b Change default location for storage.conf to...
... /usr/local/etc/containers on FreeBSD

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-05-03 16:39:32 +01:00
Dan Čermák 39de90b9d7
Move the mount_program autodetection into the graphdriver Init()
This prevents issues inside podman where the mount_program is detected and
subsequently erased, e.g. via the usage of the --root option.
This fixes https://github.com/containers/podman/issues/13459
This fixes https://github.com/containers/podman/issues/13458

Signed-off-by: Dan Čermák <dcermak@suse.com>
2022-03-18 12:07:49 +01:00
cdoern f260c4ec1e fix Save()
switched os.Open to os.Create because os.Open() creates a file in read only mode

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-02-10 22:34:00 -05:00
Daniel J Walsh 86dd22e482
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-21 07:42:51 -05:00
cdoern 454ba682f6 GetStore modifications, Create StorageConfig and Save
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>
2022-01-10 21:40:29 -05:00
Daniel J Walsh cadf8d9017
Merge branch 'main' into default 2021-12-13 15:21:36 -05:00
Aditya Rajan 0bc7e4dd52
options: use global const for run and graph root
Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-12-02 21:28:56 +05:30
Aditya Rajan cf1b8c2ab3
options: fall back to default graph and run root for empty case
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>
2021-12-02 17:07:06 +05:30
Daniel J Walsh 0baf764c4a
Reset defaultConfigFile if defaultOverrideConfigFile exits.
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>
2021-11-30 06:34:40 -05:00
Daniel J Walsh d963622899
User are reporting potential issues with using overlay2
We should just switch to overlay right away rather then
handling the driver code lower in the stack.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-15 08:48:58 -05:00
Daniel J Walsh 5c5bf639ed
Support /usr/share/containers/storage.conf
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>
2021-10-14 09:09:21 -04:00
Daniel J Walsh 5bd2e7b703
Report bad entries in storage.conf to the user
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>
2021-06-30 10:23:21 -04:00