Commit Graph

74 Commits

Author SHA1 Message Date
Giuseppe Scrivano c98840f31d 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 a2ab46c2ae 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 4a5370c6c0 driver: extend ApplyDiff with differOpts
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-07-04 17:45:41 +02:00
Giuseppe Scrivano c8fb6156cc 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 4f2e7b1064 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 5e2a43eb7a chunked: report used UIDs/GIDs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:40 +02:00
Giuseppe Scrivano f175ccecd3 driver: keep TOC digest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02:00
Giuseppe Scrivano 8ef163a990 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 1047ed768c chunked: drop superfluous variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02:00
Kir Kolyshkin fa414d963d 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 1bf0078883 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 c2d54c58d7 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 d8b0a2bde4 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č 733f4a5613 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 6a06791855 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 a41ae81840 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 e0cdfa41a6 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 d8744313dc 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 11788c427c chunked: validate number of chunks received
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-05-11 17:21:38 +02:00
Valentin Rothberg f1b15b1658 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 805d021c0a Revert "chunked: use valyala/gozstd"
This reverts commit 38db634502.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 16:16:46 +01:00
Giuseppe Scrivano 7d9acebc6e 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 38db634502 chunked: use valyala/gozstd
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:28:15 +01:00
Giuseppe Scrivano f3be949830 chunked: validate chunk digest
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:43 +01:00
Giuseppe Scrivano 88deb61566 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 44c1b4441d chunked: use just created parent directory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 0ed5da5ff3 chunked: factor out function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 398cb13fcb 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 92c177fbfb 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 ab312b0f33 chunked: use json-iterator
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:42 +01:00
Giuseppe Scrivano 1cf9fface9 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 22b4de168b 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 05c959406b chunked: split appendCompressedStreamToFile
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-10 11:27:40 +01:00
Giuseppe Scrivano 126a172519 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 46d10f7a27 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 4f34223528 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 2b3207cdbf storage: reuse zstd decoder
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 66029ddeb4 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 65b0c4b592 chunked: release zstd on termination 2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 9d808fd79e 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 f19256c6aa 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 1c67dafd91 chunked: chunk deduplication
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:15 +01:00
Giuseppe Scrivano efdb305775 chunked: move cache to separate file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano 10ed9d2168 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 1f91974b86 chunked: support copy from uncompressed stream
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-24 13:28:25 +01:00
Giuseppe Scrivano fdb414ede4 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 b3f7520616 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 7c509b750e chunked: rename types
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00
Giuseppe Scrivano b717e225f4 chunked: drop argument mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00
Giuseppe Scrivano 1da7a3c179 chunked: move check to helper function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01:00