Commit Graph

393 Commits

Author SHA1 Message Date
Justin Chadwell
feaba880de chore: refactor cache to use errors pkg
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-23 12:29:27 +00:00
Tonis Tiigi
a20e48f36d provenance: add layers support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:03 -08:00
Alex Couture-Beil
0bb8505e86 Skip boltdb update call when queue is empty
This prevents unnecessary calls (and disk writes) to the metadata cache db when there are
no items in the queue.

Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
2022-11-08 12:29:11 -08:00
Tõnis Tiigi
5b7315c381 Merge pull request #2581 from imeoer/nydus-compression-type
Support for exporting nydus compression type
2022-11-07 22:21:33 -08:00
a-palchikov
cf45d2842d Add support for multiple cache exports.
Fix cache import/export tests w.r.t inline caching.

Signed-off-by: a-palchikov <deemok@gmail.com>
2022-11-03 14:10:52 +01:00
Yan Song
3e9e898782 nydus: adjust code structure for independence
Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2022-11-03 02:50:17 +00:00
Yan Song
cf70ab6723 cache: support nydus compression type
Nydus image is a container accelerated image format provided by the
Dragonfly image-service project, which offers the ability to pull
image data on demand, without waiting for the entire image pull to
complete and then start the container. It has been put in production
usage and shown vast improvements over the old OCI image format in
terms of container launching speed, image space, and network bandwidth
efficiency, as well as data integrity. Nydus image can be flexibly
configured as a FUSE-based user-space filesystem or in-kernel
EROFS (from Linux kernel v5.16) with Nydus daemon in user-space,
integrating with VM-based container runtime like KataContainers
is much easier.

Nydus has provided a conversion tool Nydusify for converting OCIv1
image to Nydus image and integrated into Harbor Acceld as a conversion
driver, which assumes that the OCI image is already available in the
registry, but a better way would be to build the Nydus images directly
from the build system instead of using the conversion tool, which would
increase the speed of the image export, so we experimentally integrated
the Nydus export in Buildkit.

Unlike other compression formats (gzip, estargz, etc.) in OCI image,
nydus is divided into two types of layer, blob, and bootstrap, where
blob serves as the data part of each layer of the image, and bootstrap
serves as the metadata of the whole image, the bootstrap is equivalent
to the view of the whole image filesystem after all layers overlay. For
example, for an OCI image with 3 layers, the corresponding nydus image
is 4 layers (3 layers of blob + 1 layer of bootstrap).

The nydus-snapshotter project provides a package to do the actual layer
compression, this commit imports the package to implement the export of
nydus compression type.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2022-11-01 03:20:23 +00:00
Tõnis Tiigi
9940833aea Merge pull request #3227 from gabriel-samfira/fix-contenthash-on-windows
Use path.Join to generate cache keys
2022-10-28 15:47:53 -07:00
Gabriel Adrian Samfira
b1d33dd474 Use path.Join to generate cache keys
Using filepath.Join() breaks convertPathToKey() on Windows.
Windows should be able to deal with both forward and backslashes.
Using backslashes in paths here, will break the way we generate
cache keys. convertPathToKey() currently replaces '/' with 0.
Changing every code path to accomodate the Windows specific path
separator is a lot more involved than allowing Windows to just
handle the forward slash paths.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2022-10-27 10:09:38 +03:00
Tõnis Tiigi
99f3663717 Merge pull request #3136 from imeoer/compression-type-interface
compression: introduce compression.Type interface
2022-10-25 19:40:33 -07:00
Justin Chadwell
6ef0db91e7 lint: add nolintlint and fix violations
We should be able to detect nolint comments that point to linters that
are disabled (such as with the removed structcheck).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-10-19 19:39:37 +01:00
Yan Song
1cfbf1059b iohelper: move some public codes into
Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2022-10-19 08:46:25 +00:00
Yan Song
6a1430e7cf compression: introduce compression.Type interface
Introduce a new compression.Type interface, which needs
to be implemented for each compression type, by that we can
reduce the number of switch case statements and ensure that
we don't miss the handle of any compression types, and also
make more easily for supporting new compression types.

This is a commit for code improvement, so no logical changes.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
2022-10-19 08:46:00 +00:00
Sebastiaan van Stijn
d7d2a32ab1 cache: replace pkg/fileutils with github.com/moby/patternmatcher
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-10-06 16:51:28 +02:00
Tõnis Tiigi
91145270d4 Merge pull request #3010 from amrmahdi/pranavp/azblob-rebase
[remotecache] Add Azure Blob Storage support
2022-09-01 22:11:11 -07:00
CrazyMax
cc2553bf1a cache(s3): handle session token for temporary credentials
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-25 19:55:10 +02:00
Pranav Pandit
522573b29c [remotecache] Add Azure Blob Storage support
This adds experimental support for Azure Blob Storage based remote cache to buildkit. For usage instructions please refer to the updated Readme. We have tried to keep it similar to the S3 based implementation while using equivalent Azure Blob Storage specific semantics where appropriate.
This also adds end-to-end tests to exercise the Azure Blob Storage based cache using the [Azurite emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite).

Co-authored-by: Amr Mahdi <amrh@microsoft.com>
Co-authored-by: Pranav Pandit <pranavp@microsoft.com>
Signed-off-by: Pranav Pandit <pranavp@microsoft.com>
2022-08-25 06:20:22 -07:00
CrazyMax
4a15e742d8 update golangci-lint to 1.48.0 (go 1.19 support) and fix linting issues
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-19 10:26:52 +02:00
CrazyMax
00ee28175c progress: mutualize OneOff helper
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-08 12:52:59 +02:00
Eng Zer Jun
be6501b654 test: use T.TempDir to create temporary test directory
This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-07-24 02:27:26 +08:00
Bertrand Paquet
09c5a7c0ee Add s3 remote cache
Signed-off-by: Bertrand Paquet <bertrand.paquet@gmail.com>
2022-05-13 13:13:37 +02:00
Tonis Tiigi
dd4eb93c2e remotecache: update spec documentation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-04-26 21:48:32 -07:00
David Gageot
1245e43085 Enable gosimple linter
Signed-off-by: David Gageot <david.gageot@doctolib.com>
2022-04-23 23:57:16 +02:00
Erik Sipsma
182d9df984 cache: release parents if load fails
Before this, if a ref with multiple parents loaded some parents but then
failed, the already loaded parents would not be released and thus
leaked.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-04-12 22:27:36 -07:00
Erik Sipsma
a493fab603 cache: set all merge+diff refs non-mutable on load.
This fixes merge+diff refs from v0.10.{0,1} that weren't set as
committed.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-04-12 22:27:36 -07:00
Erik Sipsma
16699a4fa8 cache: set committed to true for merge+diff refs.
Before this, merge and diff refs were incorrectly not being marked as
committed, which meant that when cache was reloaded they would be marked
as mutable, which in turn lead to refs with them as an ancestor being
removed by the cache manager's init method. Additionally, if the merge/diff
ref was a parent, more inconsistent states could arise.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-04-12 22:27:36 -07:00
Tõnis Tiigi
63ad264423 Merge pull request #2729 from sipsma/use-temp-lease
snapshot: use temporary lease during diffapply
2022-03-15 14:46:23 -07:00
Erik Sipsma
54019e6a3a Set ProgressKey in solver instead of ops.
This centralizes the location where ProgressKey gets set, which works
because it only needs information about the vertex, nothing op-specific.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-03-15 14:11:38 -07:00
Erik Sipsma
e348445e16 cache: check that diff upper isn't nil
Before this, if you called DiskUsage when there was a Diff ref that had
a nil upper and that ref had not yet had a blob set, the
layerDigestChain method would get a nil pointer exception.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-03-15 13:16:10 -07:00
Sebastiaan van Stijn
21e9e9641e Remove uses of deprecated io/ioutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-10 00:57:07 +01:00
Tõnis Tiigi
0a7d8907ae Merge pull request #2685 from ktock/remotecachecompression
Enable selecting compression on registry/localdir cache export
2022-03-04 08:29:02 -08:00
Kohei Tokunaga
e3f6d7b99e Enable selecting compression on remote cache export
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-03-04 16:28:57 +09:00
Tonis Tiigi
52c933aae6 cache: set default compression for estargz
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-03-03 21:52:56 -08:00
Tõnis Tiigi
d1a8f137c1 Merge pull request #2662 from ktock/overlayfs-differ-cancel
overlay differ: cancel diff calculation cleanly
2022-03-02 21:53:42 -08:00
Tõnis Tiigi
e6c96c80fd Merge pull request #2651 from earthly/vlad/fix-layer-index-upstream
Eliminate auto-removal of empty layers
2022-02-25 11:35:40 -08:00
Kohei Tokunaga
ec09df1198 Fix refs ignoring gc reference labels of contents
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-24 15:19:03 +09:00
Kohei Tokunaga
3b7422996a cache: Clean up temporary mount pool on restart
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-23 16:33:25 +09:00
Tõnis Tiigi
02217d0b71 Merge pull request #2660 from ktock/rootless-containerd-worker
Support rootless containerd worker
2022-02-22 12:18:13 -08:00
Tõnis Tiigi
0154dfcfaf Merge pull request #2648 from ktock/cache-stargz-snapshotter
Enable estargz-based lazy pulling on registry cache importer
2022-02-22 09:24:17 -08:00
Kohei Tokunaga
63c939adbd overlay differ: cancel diff calculation cleanly
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-22 10:56:42 +09:00
Kohei Tokunaga
393bc5b7b0 Allow using compressions unsupported by containerd on non-overlayfs snapshotter
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-21 15:59:57 +09:00
Vlad A. Ionescu
d67243ed0b Fix invalid layer index error
Signed-off-by: Vlad A. Ionescu <vladaionescu@users.noreply.github.com>
2022-02-16 21:11:44 -08:00
Kohei Tokunaga
bed5a44d52 Enalbe estargz-based lazy pulling on registry cache importer
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-17 10:44:14 +09:00
Kohei Tokunaga
1a22b17852 Fix shared cache mounts result in overlay corruption
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-16 17:46:07 +09:00
Kohei Tokunaga
4280dfd489 cache: Allow sharing compression variants among refs
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-11 16:43:33 +09:00
Brian Goff
758410d74a Cleanup foreign-layers implementation
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-02-10 01:12:42 +00:00
Brian Goff
893bfddbc9 Move non-dist layer conversion to GetRemotes
This just makes sure the logic for the layer conversion is all in one
place and settable by a common option.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-02-10 01:12:42 +00:00
Brian Goff
78bb7137ee Do not re-tag non-distributable blob descriptors
Before this change buildkit was changing the media type for
non-distributable layers to normal layers.
It was also clearing out the urls to get those blobs.

Now the layer mediatype and URL's are preserved.
If a layer blob is seen more than once, if it has extra URL's they will
be appended to the stored value.

On export there is now a new exporter option to preserve the
non-distributable data values.
All URL's seen by buildkit will be added to the exported content.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-02-10 01:12:42 +00:00
Erik Sipsma
0566b9a345 Add support for progress groups.
This allows clients to specify that LLB states should be grouped in
progress output under a custom name. Status updates for all vertexes in
the group will show up under a single vertex in the output.

The intended use cases are for Dockerfile COPY's that use MergeOp as a
backend and for grouping some other internal vertexes during frontend
builds.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-08 11:27:49 -08:00
Erik Sipsma
bb09f3c032 Improve progress output for merge+diff ops.
Now, when a merge or diff ref is unlazied, the progress will show up
under the vertex for the merge/diff ref. Additionally, any ancestors of
the op that also need to be unlazied as part of unlazying the merge/diff
will show status updates under its vertex in the progress.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-08 11:26:05 -08:00