Commit Graph

20 Commits

Author SHA1 Message Date
Giuseppe Scrivano 6a7ab2bc99
chunked: flush the input tarball to the output
Flush the entire input tarball to the output in the zstd:chunked
stream writer.  This is needed to include any trailing zeros that
affect the uncompressed digest.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-13 17:31:00 +01:00
Giuseppe Scrivano b0986ebb6b
chunked: close reader pipe before waiting for errors
close the pipe immediately when the file is closed to avoid a possible
deadlock if the other end is waiting for EOF on the writer side.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-13 17:30:56 +01: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 c3d13cca2e
chunked: drop superfluous flush
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
Miloslav Trmač 7f0dae6fea Rename ReadByte to readByte
It is only used internally, and this avoids a warning
about a conflict with io.ByteReader.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:53 +02:00
Miloslav Trmač 5e410ef763 Misc individual warning fixes
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:53 +02:00
Miloslav Trmač 02e6083c83 Rename identifiers to avoid conflicts with built-ins
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:53:06 +02:00
Miloslav Trmač 3926780ab1 Misc error handling fixes or warning silences
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:46:52 +02:00
Miloslav Trmač be449e9467 Remove unused fields from holesFinder
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:49 +02: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
Nalin Dahyabhai 14e95ef777 Don't try to use %w in testing package logging functions
Go 1.18's testing package is adamant that it doesn't support the %w
specifier for wrapping errors, which makes sense because it outputs
text rather than producing an error object like fmt.Errorf() does.
Change attempts to use %w to %v.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-06-01 10:55:08 -04: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 54096ca870
chunked: use rolling checksum to split files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 7476917b9e
chunked: add rollsum from go4.org/rollsum
these files are unlikely to change, so avoid another dependency.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-07 21:28:16 +01:00
Giuseppe Scrivano 315d4fb2ec
chunked: change zstd default compression level
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-23 14:11:16 +01: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
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