Commit Graph

62 Commits

Author SHA1 Message Date
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
Colin Walters 6ec1306ac3 graphdriver: Clarify name of fsverity const, tweak docs
- Add comments that make clear these are internal values
- Rename "Enabled" to "IfAvailable" to clarify what it does
- Also note that `DifferFsVerityRequired` is not actually set by anything
  in this codebase.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-05 10:53:56 -04:00
Kohei Tokunaga 1bdba37848
Enable to pass TOCDigest to Additional Layer Store
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2024-05-15 10:11:40 +09:00
Giuseppe Scrivano 383e8e39c7
drivers: use fileutils.{Le,E}xists()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-08 16:07:27 +02:00
Giuseppe Scrivano c6de01cf31
driver: simplify ApplyDiffFromStagingDirectory
enforce that the stagingDirectory must have the same value as the
diffOutput.Target variable.  It allows to simplify the internal API.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-15 21:56:59 +01:00
Giuseppe Scrivano 81fc7c1214
chunked: calculate the file fs-verity when it is written
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-19 12:50:35 +01:00
Giuseppe Scrivano b7c31d234c
chunked: store the root dir more if present
propagate the mode for the current root directory if it is specified
in the tarball.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-12 20:52:39 +01:00
Giuseppe Scrivano 15ac716f16
layers: add option to initialize layer Flags
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-04 16:58:13 +01:00
Giuseppe Scrivano f424bfcf9f
store: new struct to pass ApplyDiffWithDiffer opts
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-04 16:58:13 +01:00
Giuseppe Scrivano 02f7e8f4ab
drivers: add Artifacts to DriverWithDifferOutput
so the differ can export arbitrary data that is not written as a big
file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-16 13:09:45 +02:00
Giuseppe Scrivano a50bb95770
chunked: support writing files in a flat dir format
so that they can be stored by their digest

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-04 17:45:41 +02:00
Giuseppe Scrivano 8bb5a087ab
driver: extend ApplyDiff with differOpts
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-04 17:45:41 +02:00
Giuseppe Scrivano b007d1744d
driver: keep TOC digest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02:00
Giuseppe Scrivano 7bbf6ed448
chunked: generate tar-split as part of zstd:chunked
change the file format to store the tar-split as part of the
zstd:chunked image.  This will allow clients to rebuild the entire
tarball without having to download it fully.

also store the uncompressed digest for the tarball, so that it can be
stored into the storage database.

Needs: https://github.com/containers/image/pull/1976

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02: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
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
Nalin Dahyabhai cabf1b9fd0 Initial implementation of consistency checks
Add initial Check() and Repair() methods to Stores.

Check() checks for inconsistencies between the layers which the
lower-level storage driver claims to know about and the ones which we
know we're managing.  It checks that layers referenced by layers,
images, and containers are known to us and that images referenced by
containers are known to us.  It checks that data which we store
alongside layers, images, and containers is still present, and to the
extent which we store other information about that data (frequenly just
the size of the data), verifies that it matches recorded expectations.
Lastly, it checks that layers which are part of images (and which we
therefore know what they should have in them) have the expected content,
and nothing else.

Repair() removes any containers, images, and layers which have any
errors associated with them.  This is destructive, so its use should be
considered and deliberate.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-04-13 10:38:24 -04:00
Daniel J Walsh a3204cf7e8
Move to golang 1.18 and later
Github.com is reporting security issues on older versions of
golang.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-04-03 15:26:54 -04: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 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 ddf18d41da Add Store.GarbageCollect() method
This looks in the container store for existing data dirs with ids not in
the container files and removes them. It also adds an (optional) driver
method to list available layers, then uses this and compares it to the
layers json file and removes layers that are not references.

Losing track of containers and layers can potentially happen in the
case of some kind of unclean shutdown, but mainly it happens at reboot
when using transient storage mode. Such users are recommended to run
a garbage collect at boot.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-11-14 16:36:30 +01:00
Miloslav Trmač 5e410ef763 Misc individual warning fixes
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:53 +02:00
Miloslav Trmač f42467020f Misc. warning cleanups
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:53:06 +02:00
Miloslav Trmač 5e8eb4c69a Check and report errors in driver.Put()
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:46:53 +02:00
Miloslav Trmač f1e256e70d Introduce, and use, graphdriver.MustRegister
... instead of silently failing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:46:52 +02:00
Nalin Dahyabhai 449ffb0f8d Use defined constants for flag names
Use constants for the names of flags that we set in Flags maps that we
store in layer/image/container records, to make it easier to avoid
possible breakages due to typos in the future.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-09-14 10:54:54 -04:00
Daniel J Walsh 3f8c0dc0de
Wrap errors properly with fmt.Errorf
Also returned errors should not begine with a capatalized errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-07-12 13:26:10 -04:00
Sascha Grunert 3455d12729
Switch to golang native error wrapping
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>
2022-07-07 13:22:46 +02:00
ktock 2bb8cde363 Enable to export layers from Additional Layer Store
Currently, layers aquired from additional layer store cannot be exported
(e.g. `podman save`, `podman push`).

This is because the current additional layer store exposes only *extracted view*
of layers. Tar is not reproducible so the runtime cannot reproduce the tar
archive that has the same diff ID as the original.

This commit solves this issue by introducing a new API "`blob`" to the
additional layer store. This file exposes the raw contents of that layer. When
*(c/storage).layerStore.Diff is called, it acquires the diff contents from this
`blob` file which the same digest as the original layer.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-05-15 10:38:39 +09:00
Daniel J Walsh 4f69205462
Merge pull request #775 from giuseppe/zstd-chunked
Enable zstd:chunked support in containers/image
2021-05-14 16:11:58 -04:00
Giuseppe Scrivano d5db906d7c
store: allow shifting only with contiguous mappings
enable fuse-overlayfs shifting only when the specified mapping is
contiguous.

Closes: https://github.com/containers/podman/issues/10272

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-05-13 16:14:26 +02:00
Giuseppe Scrivano c2a5fd1bb7
drivers: add interface to directly write diff
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-05-07 11:29:25 +02:00
ktock 64f018103e Support additional layer store
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-04-07 17:53:36 +09:00
Giuseppe Scrivano afacacf474
store: support volatile containers
add a new class of containers that are not guaranteed to survive a
crash.  The advantage of such containers is that storage can be
optimized to skip some synchronizations with the underlying storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 10:13:27 +01:00
Peter Hunt 01776faaa6 drivers: add ReadWriteDiskUsage endpoint
all endpoints currently walk the directory to find the size

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-01-28 11:57:53 -05:00
Giuseppe Scrivano be5932a4d8
storage: add option force_mask=
force_mask sets a permission mask used for the new files and
directories.

It is useful for using a NFS share for the rootless storage.  It
requires this change in fuse-overlayfs:

https://github.com/containers/fuse-overlayfs/pull/246

[storage]
  driver = "overlay"
  graphroot = "/mnt/nfs/home/storage"
  [storage.options]
    size = ""
    mountopt = "xattr_permissions=2"
   [storage.options.overlay]
     force_mask = "0755"
     ignore_chown_errors = "true"

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-11 10:30:43 +01:00
Sascha Grunert 24d793fc94
Revert API break due to lint fixes
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-29 11:46:52 +01:00
Sascha Grunert fd72b45a3f
Enable golint linter and fix lints
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-28 15:59:15 +01:00
Daniel J Walsh fa580f0747
Add support for ignoreChownErrors to vfs
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-29 14:30:17 -04:00
Daniel J Walsh 976fe22092
Add storage options to IgnoreChownErrors
Modified patch of Kevin Pelzel.

Also changed ApplyDiff to take new ApplyDiffOpts Struct.

Signed-off-by: Kevin Pelzel <kevinpelzel22@gmail.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-26 06:05:27 -04:00
Nalin Dahyabhai fe3d4bcf9b drivers.Options: pass RunRoot in, too
Pass the library-level RunRoot in as part of the Config struct that we
pass to lower-level driver initialization functions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -04:00
Nalin Dahyabhai 026db3c2bd drivers: make Init() take a graphdriver.Config
Instead of passing the driver-specific directory and assorted fields
from a Config struct to lower-level drivers when we initialize them,
pass them the directory and the Config struct.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-06-20 11:38:33 -04:00
Daniel J Walsh ef42340c2e
Revert "Add MountTempFromSource and RemoveTemp interfaces"
This reverts commit e9695564db.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-05-02 11:54:55 -04:00
Daniel J Walsh 91cf837e44
Merge branch 'master' of github.com:containers/storage 2019-05-02 10:36:36 -04:00
Giuseppe Scrivano 77065edb97
layers: propagate down the idmapping settings
when creating a layer, propagate down the idmapping.

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-01 18:31:19 +02:00
Daniel J Walsh e9695564db
Add MountTempFromSource and RemoveTemp interfaces
These interfaces can be used to setup a graphdriver mountpoint
of the source directory for use within a container.
The RemoveTemp interface umounts the mountpoint and then removes
all of the modified data in the graphdriver for this source directory.

The primary use case of these interfaces is for container engines that
want to mount a directory from the host system into the container. The
source dirctory then can be modified without actually changing the
directory on the host.

Containers will use these interfaces for sharing packaing cache directories
like /var/cache/dnf, to help speed up container builds.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-04-29 14:46:40 -04:00
Nalin Dahyabhai c073b43547 Add a CreateFromTemplate() method to drivers, and use it for mapped layers
Add a CreateFromTemplate() method to graph drivers, and use it instead
of a driver-oblivious diff/put method when we want to create a copy of
an image's top layer that has the same parent and which differs from the
original only in its ID maps.

This lets drivers that can quickly make an independent layer based on
another layer do something smarter than we were doing with the
driver-oblivious method.  For some drivers, a native method is
dramatically faster.

Note that the driver needs to be able to do this while still exposing
just one notional layer (i.e., one link in the chain of layers for a
given container) to the higher levels of the APIs, so if the new layer
is actually a child of the template layer, that needs to remain a detail
that's private to the driver.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-01-17 14:28:40 -05:00
Daniel J Walsh ab6be50561
Allow the passing in and retrieval of mount options
We want to allow tools like podman/buildah to override default storage
container mount options on a container by container basis.

For example if the default mount options for containers/storage include
nodev or nosuid, we want to allow podman to turn these off if the user
specifies --privileged.

We also might want to turn off certain user namespace flags that will cause
buildah and podman build to work slower when creating container images.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-11-19 19:14:21 -05:00
Daniel J Walsh b6ccc0acfa
Add MountOpts to stop adding fields to Get Interface
This patch adds a MountOpts field to the drivers so we can simplify
the interface to Get and allow additional options to be passed in the future.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-05 09:23:46 -04:00