Commit Graph

133 Commits

Author SHA1 Message Date
Giuseppe Scrivano bfd9c8046e
chunked: chunk deduplication
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:15 +01:00
Giuseppe Scrivano f18141fa76
chunked: move cache to separate file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano dce078f3ae
chunked: move discard call to outer scope
it solves a problem where the discard could be performed before the
compression handler was closed (through a deferred call).

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano 24b99d165f
chunked: support copy from uncompressed stream
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano 22ba9b01ef
chunked: add infra to dedup from partial file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano 8e67467c2f
chunked: allow streaming to the same file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano 20282b354b
chunked: rename types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00
Giuseppe Scrivano 8fabddd147
chunked: drop argument mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00
Giuseppe Scrivano 2e6acd4035
chunked: move check to helper function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00
Daniel J Walsh 13f2d571d1
Merge pull request #1077 from giuseppe/ignore-security-selinux
archive: ignore the security.selinux xattr
2021-11-29 10:59:56 -05:00
Giuseppe Scrivano ce5ea8e816
chunked: ignore security.selinux
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-26 11:00:59 +01:00
Giuseppe Scrivano 94c46e4cc6
chunked: add fallback for openat2
add a fallback mechanism when openat2 is not supported by the
underlying kernel.

If a call to openat2 fails with ENOSYS, then fallback to a user space
lookup.  Generally the user space lookup is not safe, since symlinks
lookups are vulnerable to TOCTOU attacks, but in this case where the
rootfs is being created, there are no other processes modifying it
thus such lookups can be considered safe.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-26 09:29:55 +01:00
Giuseppe Scrivano 4be78487cb
chunked: refactor common code in a function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-25 14:49:35 +01:00
Giuseppe Scrivano f26ed33fbf
chunked: wrap the correct underlying error
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-25 14:49:08 +01:00
Giuseppe Scrivano a72972c5ee
chunked: fix setting attributes for symlinks
when dealing with symlink, open the parent directory and use the
symlink basename to set its attributes.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-23 21:13:23 +01:00
Giuseppe Scrivano 501611fd51
chunked: create missing parent directories
when creating a new file, handle the case where any of the parent
directories are missing and create them automatically if needed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-23 21:13:22 +01:00
Giuseppe Scrivano 8d6af4b7f0
chunked: improve error messages
add more context to the error messages generated while unpacking the
image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-23 21:13:22 +01:00
Giuseppe Scrivano da2733a4e4
pkg/chunked, pkg/idtools: adjust error message
since we now support reading additional IDs with libsubid, clarify
that the /etc/subuid and /etc/subgid files are honored only when
shadow-utils is configured to use them.

[NO TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-08 13:12:45 +01:00
Giuseppe Scrivano fff3e7117b
chunked: fix another occurrence of linkat
Using unix.AT_EMPTY_PATH requires CAP_DAC_READ_SEARCH.  Use an
equivalent variant that uses /proc/self/fd that can be used with
rootless.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-03 10:32:55 +01:00
Giuseppe Scrivano a5a3c6020b
chunked: implement OSTree deduplication
if the option ostree_repos is set:

    [storage.options]
    pull_options = {enable_partial_images = "true", ostree_repos = "/foo:/bar"}

then attempt to deduplicate from the specified list of OSTree repositories.

In order to be usable, an OSTree repository must be configured to track
the checksum for its files payload (payload link), that is disabled by
default:

ostree config --repo=/path/to/repo set core.payload-link-threshold N

Where N is the minimum size for files to be tracked by their payload
and must be a nonzero value.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-24 10:56:46 +02:00
Giuseppe Scrivano 980f24ec58
chunked: fix linkat for rootless
Using unix.AT_EMPTY_PATH requires CAP_DAC_READ_SEARCH.  Use an
equivalent variant that uses /proc/self/fd that can be used with
rootless.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-06 10:37:16 +02:00
Giuseppe Scrivano 4ef5ee00ab
chunked: restrict dedup with hard links
before deduplicating with hard links make sure the two files share the
same UID, GID, file mode and extended attributes.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-06 10:37:15 +02:00
Giuseppe Scrivano d00974a9aa
chunked: cache all the files with the same digest
this is a preparation change for the next commit.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-03 13:03:03 +02:00
Giuseppe Scrivano 31d1330f74
chunked: do not store the digest if it is empty
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-03 12:26:19 +02:00
Giuseppe Scrivano 2855d17137
chunked: estargz support
in addition to zstd:chunked, add support for the estargz format.

estargz is maintained at github.com/containerd/stargz-snapshotter

Images using estargz can be used on old clients and registries that
have no support for the zstd compression algorithm.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-25 16:16:20 +02:00
Giuseppe Scrivano 8694b29402
chunked: remove unused args
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-18 09:25:50 +02:00
Giuseppe Scrivano 76e458bfbe
chunked: fix fd leak on error
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-18 08:17:40 +02:00
Giuseppe Scrivano 0f9ccfe64a
chunked: remove unused argument missingDirsMode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-18 08:17:39 +02:00
Giuseppe Scrivano c85d07f33b
chunked: add new pull option use_hard_links
if the option use_hard_links is set:

[storage.options]
pull_options = {use_hard_links = "true"}

then attempt to deduplicate files using hard links first.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-18 08:17:39 +02:00
Giuseppe Scrivano a68c6e1cbf
chunked: allow to disable partial images feature
enable partial pulls only when it is explicitely configured in the
storage.conf file:

[storage.options]

pull_options = {enable_partial_images = "true"}

This is to prevent the experimental feature to leak into CRI-O.

The default value will change in future once the feature is stable.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-17 09:32:36 +02:00
Miloslav Trmač 92b63ead41 Split pkg/chunked.ZstdCompressor into a separate subpackage
containers/image/pkg/compression depends on that function, so it's
highly undesirable for it to drag in all of containers/storage.

So, move it into a separate subpackage, along with its exclusive
dependency tree.

Code that is called both from the new pkg/chunked/compressor
and the original pkg/chunked has been moved into pkg/chunked/internal ,
so that we don't expose any new public API. That move was made
purely mechanically without any concern for conceptual consistency,
to minimize the size of the dependency (and not to spend time on
that until the concept is proven to be useful).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2021-07-23 21:43:52 +02:00
Giuseppe Scrivano bfa0c220a5
chunked: fix the path used for layers dedup
`source` is the path to the layer that already contains the file that
is looked up.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-07-01 00:02:06 +02:00
Giuseppe Scrivano 5494513f2e
chunked: fix build on other platforms
fix package build on !linux platforms

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-05-25 14:42:28 +02:00