Commit Graph

358 Commits (e6c96c80fd1dc0e77dca20e71cd0fcdd66cb17fe)

Author SHA1 Message Date
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 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
Kohei Tokunaga 2d00773bd5 cache: write blob to the content store via bufio during conversion
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-07 20:24:07 +09:00
Tonis Tiigi cab33b1e31 exporter: support for compression-level
compression-level option can be set on export to
define the preferred speed vs compression ratio. The
value is a number dependent on the compression algorithm.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-01 15:21:46 -08:00
CrazyMax 3df7865fbb
Merge pull request #2571 from tonistiigi/lint-update
hack: update linter to v1.43
2022-01-20 17:23:10 +01:00
Erik Sipsma 417ba9e0ed cache: improve diff ref release logic.
Before this change, the lower and upper parents provided to the cache
manager Diff method were not cloned, which resulted in some code paths
incorrectly providing them directly as the parents of the returned ref.
This meant that if they were released after the call to Diff, the diff
ref could become incorrectly invalidated.

Now, the lower and upper are cloned and unit test coverage has been
added to test that ref release is handled correctly.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-19 14:03:49 -08:00
Tonis Tiigi dc21885891 hack: enable more linters
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-19 12:20:30 -08:00
Tonis Tiigi 01e935cff5 hack: update linter to v1.43
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-19 11:48:57 -08:00
Erik Sipsma eb935e525f cache: handle crash after snapshot commit
Before this, there could be crash during a call to finalize a ref that
occured after the snapshot was committed but before committing the
metadata that indicates the immutable ref no longer had an
equalMutable. This resulted in a situation where any future calls to
finalize that ref would fail.

Now, if that situation happens, the cache will notice when it's
initially loaded that the ref has an equalMutable that's missing its
snapshot and that its own snapshot exists. It will then just use the
correctly committed snapshot and clear the equalMutable field.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-18 12:22:52 -08:00
Erik Sipsma 0eca53360b cache: add coverage for Mount readonly parameter.
This adds test coverage for ensuring the readonly parameter is honored
as expected in the ref Mount methods. There was a regression introduced
during #2335 that went unnoticed until identified and fixed in #2562.
This test coverage should help prevent similar regressions in the
future.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-17 16:47:44 -08:00
Erik Sipsma 6471f316d3
Merge pull request #2562 from ktock/refmountcachero
cache: do not ignore readonly option
2022-01-16 16:37:34 -08:00
Kohei Tokunaga f8c9a756e3 cache: do not ignore readonly option
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-01-16 13:20:17 +09:00
Erik Sipsma ce012ab70c remote cache: support arbitrary layers as results
This change enables inline cache to work as expected with MergeOp by
supporting a new type of result, DiffResult, which enables results to be
specified as a specific ordered set of layers inside an image.
Previously, results could only be specified with a singe layer index,
which meant that they had to start at the image's base layer and end at
that index. That meant that merge inputs couldn't be specified as they
are often a subset of the image layers that don't begin at the base.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-11 13:27:05 -08:00
Erik Sipsma 5c4dcb2741 cache: add support for Diff refs.
This allows you to create refs that are single layers representing the
diff between any two arbitrary refs. The primary use case for this is
to allows users to extract the changes created by ops like Exec and
rebase them elsewhere through MergeOp. However, there is no restriction
on the inputs to DiffOp and the resulting ref's layer is simply the
layer created by running the differ on the two inputs refs
(specifically, the same differ used during exports).

A Diff ref can be mounted by itself, in which case it is defined as the
result of applying the diff to Scratch. Most use cases though will use
Diff refs as the input to a MergeOp, in which case the diff is just
applied on top of the lower merge inputs, as was the case before.

In cases like Diff(A, A->B->C) (i.e. cases where the diff is between two
refs where the lower is an ancestor of upper), the diff will be defined
as the layers separating the two refs. In other cases, the diff is just
a single layer, not re-used from the inputs, representing the diff
between the two refs (which can be defined as the layer "Diff(A,B)" that
satisfies "Merge(A, Diff(A,B)) == B").

Note that there is technically a meaningful difference between the
"unmerge" behavior of extracting the layers separating diffs and the
"simple diff" of just running the differ on the two refs. Namely, in the
case where there are "intermediate deletes" (i.e. deletes that only
exist in layers between A and B but not between A and B by themselves),
then the simple diff and unmerge can create different results when
plugged into a MergeOp. This is due to the fact that intermediate
deletes will apply to the merge when using the unmerge behavior, but not
when using the simple diff. This is on top of the fact that the simple
diff inherently has a "flattening" behavior where multiple layers are
squashed into a single one.

So, in the case where lower is an ancestor of upper, we choose to follow
the unmerge behavior, but it's possible users may prefer the simple diff
behavior. As of right now, they won't be able to do so, but if needed we
can add the ability to choose which behavior is followed in the future.
This could be done through a flag provided to DiffOp or possibly by
adapting llb.Copy to support this type of behavior with the same
efficiency as DiffOp.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-06 11:05:51 -08:00
Tõnis Tiigi b9c4e0b302
Merge pull request #2486 from alexcb/acb/update-fsutil-and-docker
update fsutil and docker
2021-12-10 21:35:31 -08:00
Erik Sipsma abf373a3b6 cache: Disable overlay diff for native snapshotter
Before this change, test cases were running with an env var that forces
the overlay differ to be on even when the native snapshotter was being
used, which resulted in failures. Now, that env var is skipped when
using the native snapshotter.

Additionally, this includes a related change to skip even trying to use
the overlay differ when the native snapshotter is in use. Previously,
the blob creation code first tried to use the overlay differ and then
failed and fell back to the double-walking differ. Now, it just jumps
right to the double-walking differ when the native snapshotter is in
use.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-12-09 21:02:44 -08:00
Alex Couture-Beil c55a0b888c
use newer MatchesUsingParentResults
switch to using newer MatchesUsingParentResults methods which were
introduced in https://github.com/moby/moby/pull/43037

Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
2021-12-08 09:41:55 -08:00
Erik Sipsma 441f1e7b27 cache: log missing providers for blobchainID ref
Before this, if you try to get a ref with an equal blobchain in
GetByBlob but hit a missing provider, the error was just returned. While
we never expect this situation to happen (you shouldn't be able to hit
this line if you didn't already have providers for each blob in the
chain), it technically shouldn't fail the build as you can just continue
on without re-using the ref with equal blobchainID.

Now, we log this at error level but allow the build to continue.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-12-02 12:28:28 -08:00
Erik Sipsma 5872bf3dd1 cache: fix merge ref chain IDs.
This fixes an issue where merge refs were incorrectly setting their
chain IDs to their last input's ID. This resulted in errors where
GetByBlob thought the merge ref and the final input ref were equivalent.

Now, merge refs have their chain IDs computed by digesting each blob in
the full chain.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-12-02 12:21:44 -08:00
Erik Sipsma d73e62f878 Add initial MergeOp implementation.
This consists of just the base MergeOp with support for merging LLB
results that include deletions using hardlinks as the efficient path
and copies as fallback.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-18 11:10:48 -08:00
Erik Sipsma 9321ec2f82 Refactor cache record mount cache.
This is mostly just preparation for merge-op. The existing
Extract method is updated to be usable for unlazying any type of refs
rather than just lazy blobs. The way views are created is simplified and
centralized in one location.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-17 11:02:16 -08:00
Erik Sipsma 03ed0548ef cache: Replace Parent method with LayerChain.
The Parent method will no longer make sense with forthcoming Merge and
Diff support as refs will become capable of having multiple parents. It
was also only ever used externally to get the full chain of refs for
each layer in the ref's chain.

The newly added LayerChain method replaces Parents with a method that
just returns a slice of refs for each layer in the ref's chain. This
will work more seamlessly with Merge and Diff (in which case it returns
the "flattened" ancestors of the ref) in addition to being a bit easier
to use for the exiting cases anyways.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-17 11:02:16 -08:00
Erik Sipsma 2fcce87cf4 Include DescHandler CacheOpts during export.
Before this, descriptor handlers were not included with calls to the
exporter, which then sometimes called LoadRef and failed to get a ref
because it was lazy. This change results in the DescHandlers of the
already loaded refs to get plugged into context so they can be re-used
by the exporter if it needs to load the ref again.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-17 11:02:16 -08:00
Erik Sipsma 982f4b8687 Move overlay diff to util package.
This allows the overlay diff logic to be re-used by the snapshot package
as part of merge+diff op.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-15 14:19:37 -08:00
Tonis Tiigi faf5ad9e96 push: workaround deadlock in containerd pusher
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-11-12 17:33:08 -08:00
Akihiro Suda 0279989d7f
Merge pull request #2433 from tonistiigi/gha-export-fix
gha: fix handling removed blobs on reexport
2021-11-01 13:23:57 +09:00
Tonis Tiigi 962c287b1b gha: fix handling removed blobs on reexport
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-10-28 20:30:48 -07:00
CrazyMax 54b8ff2fc8
go fmt: add //go:build
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-28 13:26:43 +02:00
Tõnis Tiigi 4b86211bed
Merge pull request #2405 from ktock/cachecompression
Propagate compression options to the inline cache export
2021-10-27 20:58:53 -07:00
Erik Sipsma 3adb271954 Re-add Finalize method to ImmutableRef.
It turns out that while Buildkit code did not need this method to
be public, moby code does still use it, so we have to re-add it
after its removal in #2216 (commit b85ef15).

This commit is not a revert because some of the changes are
still desireable, namely the removal of the "commit" parameter
which didn't serve any purpose.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-10-25 10:51:30 -07:00
Kohei Tokunaga f9e0346b34 Propagate compression options to the inline cache export
Co-authored-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-10-22 15:43:32 +09:00
Kohei Tokunaga 5c27a53a15 Converter: make sure uncompressed digest annotation is set
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-10-05 15:02:05 +09:00
Tõnis Tiigi 78e88560e1
Merge pull request #2387 from tonistiigi/gha-fixes
fixes for github actions cache
2021-10-04 08:53:08 -07:00
Akihiro Suda 10947b040c
Merge pull request #2388 from ktock/containerd-overlaydiff-bufcopy
Differ: write diff to the content store over bufio writer
2021-10-04 17:05:49 +09:00
Kohei Tokunaga 9ffd7f24cb Do not enable overlayfs differ for fuse-overlayfs-snapshotter
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-10-04 13:50:05 +09:00
Kohei Tokunaga 4f3e74c0ca Differ: write diff to the content store over bufio writer
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-10-04 11:43:00 +09:00
Tonis Tiigi 066a011c01 gha: handle missing blob gracefully
FromRemote now calls CheckDescriptor to validate
if the blob still exists. Otherwise cache loading
fallback does not get triggered because cache is
actually lazily pulled in only on exporting phase.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-10-02 14:52:09 -07:00