Commit Graph

79 Commits

Author SHA1 Message Date
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