Commit Graph

157 Commits

Author SHA1 Message Date
Colin Walters cfde71b024 chunked: Add helpers for /proc/self/fd accesses
It's not hard to grep for /proc/self/fd, but this way is a bit
cleaner and avoids typos, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 09:30:55 -04:00
Giuseppe Scrivano 7c61cfaee7
chunked: refactor args to openFileUnderRoot()
follow the same pattern used by other functions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 22:33:43 +02:00
Giuseppe Scrivano 2278cb1e0e
chunked: provide constructor for seekableFile
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 21:37:13 +02:00
Giuseppe Scrivano 37800897ab
chunked: split file operations to a new file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 13:11:46 +02:00
Colin Walters 661531fb0d chunked: Set O_CLOEXEC
I was just reading the code and I have a mental checklist item
for "invoking open without O_CLOEXEC" that triggered here.
(See also e.g.
https://github.com/containers/composefs/pull/185#discussion_r1322925050
)

It has security-relevant properties for us, xref
CVE-2024-21626 for example.

This isn't the only missing variant of this in this codebase,
just using this targeted PR to test the waters for more PRs.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-05 09:20:07 -04:00
Giuseppe Scrivano 617a808a63
chunked: change auto merge threshold to 1024
Increase the threshold for auto-merging parts from 128 to 1024. This change
aims to reduce the number of parts in an HTTP multi-range request, thus
increasing the likelihood that the server will accept the request.

The previous threshold of 128 often resulted in a large number of small
ranges, which could lead to HTTP multi-range requests being rejected by
servers due to the excessive number of parts.

It partially addresses the reported issue.

Reported-by: https://github.com/containers/storage/issues/1928

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-03 15:00:35 +02:00
Miloslav Trmač dfb4b1ff87 Unmarshal the TOC already in readZstdChunkedManifest
Other TOC formats don't fill the data in.

For now, this only increases memory usage, but we will
need the data soon.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-05-14 10:53:03 +02:00
Miloslav Trmač 9fbd0e0395 Don't look for the binary digest when pulling layers
This code path is usually never triggered because
the annotations are present; and it was broken until recently.

Remove it to simplify the code and analysis.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-22 23:56:40 +02:00
openshift-merge-bot[bot] 2431799327
Merge pull request #1893 from giuseppe/convert-zstd-chunked-store-original-tarsize
chunked: store original tar size for converted layers
2024-04-20 10:33:32 +00:00
Giuseppe Scrivano 639f1a62f9
chunked: store original tar size for converted layers
if the layer was converted from an existing one, store the original
layer size.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-19 21:30:37 +02:00
Miloslav Trmač 1f47b38c09 Only obtain the zstd:chunked TOC digest once
Make it structually clear that the code is all using the same value,
making it less likely for the verifier and other uses to get out of sync.

Also avoids some redundant parsing and error paths.
The conversion path looks longer, but that's just moving the parsing
from the called function (which is redundant for other callers).

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-13 16:57:07 +02:00
Miloslav Trmač 3beea1e21e Only obtain the estargz TOC digest once
Make it structually clear that the code is all using the same value,
making it less likely for the verifier and other uses to get out of sync.

Also avoids some redundant parsing and error paths.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-04-13 16:26:32 +02:00
Giuseppe Scrivano 1126d65aa7
chunked: skip file metadata for composefs files
if the file is created using the object-store flat directory format,
there is no need to set its inodes attributes, as anyway they are
ignored when creating the composefs binary blob.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-20 15:47:38 +01:00
Giuseppe Scrivano 0f12ecea79
chunked: skip file metadata for hard links
if a file was deduplicated with a hard link, do not override its
metadata.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-20 15:47:38 +01:00
Giuseppe Scrivano f52cbe08c1
chunked: add way to skip setting file metadata
when it is set, only the file payload is written, but the inode
attributes are ignored.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-20 15:47:38 +01:00
Giuseppe Scrivano f6356d6ccd
chunked: refactor private fields to internal struct
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-20 15:47:37 +01:00
Giuseppe Scrivano 43b836e7e6
chunked: improve function to merge chunks
improve the function that combines neighbor chunks.  Instead of using
the number of parts, which also includes local files, use only the
number of chunks that must be retrieved from the network.

In addition, introduce a threshold limit to merge chunks so that we
further reduce the number of requested ranges.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-03-01 17:09:47 +01:00
Giuseppe Scrivano 69aeb17257
chunked: preserve the original value for symlinks
the symlinks must preserve their original value without any
alteration.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-27 21:36:19 +01:00
Giuseppe Scrivano 8c1cf34a37
storage: move check for enable_partial_images to GetDiffer
move the check for `enable_partial_images` to GetDiffer so that it
doesn't attempt any operation if the feature is disabled.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-15 21:59:01 +01:00
Giuseppe Scrivano 23ff5f8c57
storage: enable partial images by default
by default enable pulling a partial image, it is still possible to
disable the feature through the configuration file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-15 21:58:57 +01:00
Giuseppe Scrivano 9343f9f792
chunked: report TOCDigest for converted layers
even if we validated the full layer, report the TOC Digest as well so
the upper layer can use both.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-09 11:13:43 +01:00
Giuseppe Scrivano dc3f818a84
chunked: store UncompressedDigest if validated
store the UncompressedDigest when the original tarball was converted
to zstd:chunked, since its diffID was computed and validated.

In this way the layer can be reused as any other layer that was fully
retrieved and validated.

Before this change, a layer that was converted to zstd:chunked was
always retrieved since it has not a TOC Digest.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-30 21:24:54 +01:00
Daniel J Walsh b9c7cc2267
Merge pull request #1806 from giuseppe/composefs-bugfixes
composefs: some fixes
2024-01-22 07:55:53 -05:00
Giuseppe Scrivano d800e0fae5
chunked: copy chunk struct
it prevents clobbering the chunk .Size element later.  This filed was
ignored previously, but composefs uses it to retrieve the file size.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-19 18:51:25 +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 fa794cb997
chunked: validate converted images
validate that the retrieved data for converted images matches the
expected digest.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-08 22:00:35 +01:00
Giuseppe Scrivano f435ce84a2
chunked: disallow both zstd:chunked and eStargz TOCs
reject a layer if it contains both a zstd:chunked and an eStargz TOC
since there are no guarantees that the two TOCs are consistent.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-15 11:31:04 +01: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 c1ccdf0d00
chunked: export toc as part of the Artifacts
so that the users of the function can get access to the already
unmarshalled TOC instead of having to unmarshal it again.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-16 13:09:45 +02:00
Giuseppe Scrivano b737dc6caf
chunked: provide digest for empty files
if the file doesn't have a digest but its size is 0, we can hard code
the known sha256 digest.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-16 13:09:45 +02:00
Giuseppe Scrivano 423c0dc207
chunked: move GetTOCDigest to a subpackage
The purpose of this move is to reduce dependencies for the new
package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-08-08 08:59:38 +02:00
Giuseppe Scrivano 58405a5940
chunked: skip validation for prefetched images
if the image is created locally there is no need to validate again the
files.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-26 10:46:15 +02:00
Giuseppe Scrivano 303100391e
chunked: support converting existing images
if the "convert_images" option is set in the configuration file, then
convert traditional images to the chunked format on the fly.

This is very expensive at the moment since the entire zstd:chunked
file is created and then processed.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-26 10:46:15 +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 7a5f2bef36
chunked: file fd leak
The file descriptor was not closed before, thus leaking all the opened files.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-04 17:45:41 +02:00
Giuseppe Scrivano 7304a21410
chunked: add function to retrieve TOC digest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:40 +02:00
Giuseppe Scrivano 5d10b9459a
chunked: report used UIDs/GIDs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:40 +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
Giuseppe Scrivano 7846152fde
chunked: drop superfluous variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02:00
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07: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
Nalin Dahyabhai 769814edfe Fix typos in error messages
Two error messages suggest that podman-system-migrate is a binary that
can be run, when the command is "podman system migrate".

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-03-09 15:04:04 -05:00
Giuseppe Scrivano 39cac28763
chunked: report the correct size
report the correct size for a layer that was pulled
using the chunked package.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-02-27 20:25:55 +01:00
Miloslav Trmač a1ccc9d862 Use os.WriteFile instead of ioutil.WriteFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:34 +02: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
Giuseppe Scrivano 268af00013
chunked: drop host dedup feature
drop host deduplication by just looking at the file path.  It could be
useful in very specific use cases, but it is too expensive for generic
images.  If the need arises, we first need to create an index of the
files that we can deduplicate so there is no need to calculate the
checksum on the fly.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-06-07 15:32:34 +02:00
Giuseppe Scrivano 75fd4d6c7b
chunked: recalculate correctly the chunks to request
after the missing parts are merged, it is necessary to recalculate the
chunks to ask to the server.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-05-11 17:21:38 +02:00
Giuseppe Scrivano 90fd24cd05
chunked: validate number of chunks received
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-05-11 17:21:38 +02:00
Valentin Rothberg f0324e1976 insufficient IDs errors: mention podman-system-migrate
Based on a conversation on the Podman mailing list:
Mentioning podman-system-migrate in the error message may help users
resolve their issues faster.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-02-23 14:52:47 +01:00
Giuseppe Scrivano 33f973c732
Revert "chunked: use valyala/gozstd"
This reverts commit 5bb6d8e65e.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 16:16:46 +01:00
Giuseppe Scrivano 198820877c
pkg/chunked: add support for sparse files
automatically detect holes in sparse files (the threshold is hardcoded
at 1kb for now) and add this information to the manifest file.

The receiver will create a hole (using unix.Seek and unix.Ftruncate)
instead of writing the actual zeros.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-13 13:32:13 +01:00
Giuseppe Scrivano 5bb6d8e65e
chunked: use valyala/gozstd
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:28:15 +01:00
Giuseppe Scrivano 2edca4eb72
chunked: validate chunk digest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:43 +01:00
Giuseppe Scrivano 63be926601
chunked: copy local files from multiple goroutines
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 0d21b61022
chunked: use just created parent directory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 9b95fc1428
chunked: factor out function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano ed714c799b
chunked: avoid duplicated file path in error message
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 0621da79cc
chunked: improve json parsing
reduce the number of allocations done by the parser by reading into a
bytes.Buffer.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 048f7c08ad
chunked: use json-iterator
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 10697a05a2
chunked: implement lookaside cache
avoid parsing each json TOC file for the layers in the local storage,
but attempt to create a lookaside cache in a custom format faster to
load (and potentially be mmap'able).

The same cache is used to lookup files, chunks and candidates for
deduplication with hard links.

There are 3 kind of digests stored:

- digest(file.payload))
- digest(digest(file.payload) + file.UID + file.GID + file.mode + file.xattrs)
- digest(i) for each i in chunks(file payload)

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano a5f0cddf2b
chunked: use just created parent directory
a reference to the just created parent directory is already opened, so
use it directly.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 834db5aab5
chunked: split appendCompressedStreamToFile
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:40 +01:00
Giuseppe Scrivano 12e9b991dc
chunked: optimize mergeTocEntries
avoid using slices.  I've seen a drop of ~20M in memory
usage with a fedora image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:26:15 +01:00
Giuseppe Scrivano b04b70a8bc
chunked: move file close to separate goroutine
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:26:15 +01:00
Giuseppe Scrivano 373605310d
chunked: use a static buffer for io operations
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:17 +01:00
Giuseppe Scrivano 4e8554e228
storage: reuse zstd decoder
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 96fc5c872a
chunked: omit empty fields in json manifest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano ba1c626d68
chunked: release zstd on termination 2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 526c57d8b0
chunked: reuse cache
try to reuse an existing cache object, instead of creating it for
every layer.

Set a time limit on how long it can be reused so to clean up stale
references.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano be4e8f622d
chunked: move copy logic to storage_linux.go
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
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