Commit Graph

71 Commits

Author SHA1 Message Date
Kir Kolyshkin c3ff7f58df Use any instead of interface{}
It's available since Go 1.18 (see https://pkg.go.dev/builtin#any).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 15:37:25 -07:00
Kir Kolyshkin 7c9328eb0c Remove obsoleted linter from nolint annotations
While at it, made sure there's no space between // and nolint
(as it is required for comments aimed for tools not humans).

This fixes the following golangci-lint warning:

> WARN [runner/nolint_filter] Found unknown linters in //nolint directives: golint

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 14:29:57 -07:00
Miloslav Trmač 116abed46c Introduce pkg/chunked/internal/path.RegularFilePathForValidatedDigest
... to centralize the composefs backing file layout design.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-01-07 16:50:19 +01:00
Giuseppe Scrivano a9754def35
driver: add skeleton for Dedup()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-09 16:41:59 +01:00
Miloslav Trmač 7eb4a104ef Explicitly differentiate between empty and missing tar-split
Empty tar-split shouldn't ever happen, but being precise
here doesn't hurt.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-10-14 20:10:07 +02:00
Miloslav Trmač 71fc790550 Don't set UncompressedSize on chunked pull
The current value obtained by summing the sizes of regular file contents
does not match the size of the uncompressed layer tarball.

We don't have a convenient source to compute the correct size
for estargz without pulling the full layer and defeating the point;
so we must allow for the size being unknown.

For recent zstd:chunked images, we have the full tar-split,
so we can compute the correct size; that will happen in
the following commits.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-10-14 20:10:07 +02:00
Giuseppe Scrivano a315bbfa0c
drivers: drop unused args from ApplyDiffWithDiffer
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-09-19 09:33:27 +02:00
Jan Rodák 2a6a35821b
Fix linter: printf: non-constant format string in call (govet)
drivers/driver.go:499:18: printf: non-constant format string in call to github.com/sirupsen/logrus.Errorf (govet)
drivers/overlay/overlay.go:1495:44: printf: non-constant format string in call to (*github.com/sirupsen/logrus.Logger).Logf (govet)

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-08-16 12:22:22 +02:00
Giuseppe Scrivano 28cba3014b
chunked: store compressed digest if validated
if the compressed digest was validated, as it happens when
'pull_options = {convert_images = "true"}' is set, then store it as
well so that reusing the blob by its compressed digest works.

Previously, when an image converted to zstd:chunked was pulled a
second time, it would not be recognized by its compressed digest,
resulting in the need to re-pull the image again.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-07-10 09:41:41 +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
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