Commit Graph

98 Commits

Author SHA1 Message Date
Giuseppe Scrivano 8c3e6d7e3e
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>
(cherry picked from commit 639f1a62f9)
2024-04-20 13:18:00 +02:00
Miloslav Trmač 586ef7b39e
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>
(cherry picked from commit 1f47b38c09)
2024-04-20 13:17:59 +02:00
Miloslav Trmač d25ef4c963
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>
(cherry picked from commit 3beea1e21e)
2024-04-20 13:17:59 +02:00
Giuseppe Scrivano 128cac0abb
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>
(cherry picked from commit 1126d65aa7)
2024-04-20 13:17:59 +02:00
Giuseppe Scrivano 2455bbadba
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>
(cherry picked from commit 0f12ecea79)
2024-04-20 13:17:59 +02:00
Giuseppe Scrivano 04c198333e
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>
(cherry picked from commit f52cbe08c1)
2024-04-20 13:17:58 +02:00
Giuseppe Scrivano 9d309f6d0c
chunked: refactor private fields to internal struct
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit f6356d6ccd)
2024-04-20 13:17:58 +02: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