Commit Graph

515 Commits (46dcd7d9a626bef5312e3527f125d18abde50782)

Author SHA1 Message Date
Erik Sipsma 6ac4a81486 progress: fix sync issue in controller.
A panic was encountered where writes to progress status hit a nil
writer. While not easy to reproduce, this commit fixes a likely culprit.
The use of atomics in the controller was not safe against a race such as
the following:
1. One goroutine calls Start, incrementing count but not yet setting
   writer.
2. A second goroutine calls Start, increments count again but sees that
   count >1 and thus doesn't try to set writer.
3. The second goroutine then calls Status, assuming the writer has been
   set, but the first goroutine still hasn't set the writer yet, causing
   a nil pointer exception.

This commit fixes that issue by just using a mutex instead of atomics.
It also adds a nil check for the writer just to be safe against panics
due to unknown issues in the future as missing a status update is much
better than buildkitd crashing.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-15 09:57:44 -08:00
Tõnis Tiigi 0b9cd24a74
Merge pull request #2630 from tonistiigi/cross-repo-fix
Fix cross-repo push fallback when access to the source repo is not granted
2022-02-14 14:23:38 -08:00
CrazyMax 9cd97fb726
buildinfo: check nil attrs
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 22:55:37 +01:00
CrazyMax b42e54726c
docs: update metadata output example with buildinfo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:21 +01:00
CrazyMax cdaafb9303
buildinfo: use metadata to set frontend build sources
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:20 +01:00
CrazyMax b2e5d1938d
buildinfo: set frontend attrs to bridge result
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:20 +01:00
CrazyMax 7d0f8e4408
buildinfo: filter out control args
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:19 +01:00
CrazyMax 83a483a9fe
buildinfo: opt-in inline build attributes
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:19 +01:00
CrazyMax c29411b41a
buildinfo: add build attributes and frontend
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:19 +01:00
CrazyMax b4e37a867f
buildinfo: refactor
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-02-14 21:55:18 +01:00
Tõnis Tiigi 58bac77c86
Merge pull request #2588 from tonistiigi/amd64-variants-support
amd64 variants support
2022-02-14 11:45:56 -08:00
Tonis Tiigi ed0408ac52 authorizer: default token expiration to 60s
When server does not return expiration time for token
default to 60s. This replaces previous solution
in error handling that broke cross-repo push.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-13 21:51:15 -08:00
Tonis Tiigi 9004de8804 Revert "Remove potentially expired tokens."
This reverts commit 9b7a5fc618.

This patch casues issues for cross-repo mounts
when user doesn't have credentials for source repo
and fallback needs to happen.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-13 21:24:23 -08:00
Tõnis Tiigi 45fc3ed510
Merge pull request #2561 from cpuguy83/keep-non-distributable
Do not re-tag non-distributable blob descriptors
2022-02-10 18:19:43 -08:00
Tõnis Tiigi 196efb911a
Merge pull request #2593 from tonistiigi/user-agent
resolver: set buildkit own user-agent
2022-02-10 17:42:32 -08:00
Brian Goff c332148dd5 push: always skip foreign layers
Foreign layers are only kept as foreign at this point if the user
requested it to be.
Since foreign layers are not meant to be pushed, automatically skip
those layers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-02-11 00:59:53 +00: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
Tõnis Tiigi a813906e85
Merge pull request #2600 from ktock/fixconversionfailure
Resolver: ensure `WithSession` to pass the session to the resolver
2022-02-08 16:33:53 -08:00
Erik Sipsma 2dfec01fed progress: support vertex start/stop intervals.
Previously, vertexes sent to progress might have multiple intervals in
which they started+stopped, but the output only knew about the most
recent interval. Now, all the intervals are tracked and the total time
spent on each (after accounting for overlaps) is displayed. This is
implemented both for normal vertexes and progress group vertexes.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-08 11:27:51 -08: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
Kohei Tokunaga 6b97f25d6f Resolver: ensure `WithSession` to pass the session to the resolver
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2022-02-07 13:02:07 +09:00
Tonis Tiigi dd992414a3 resolver: set buildkit own user-agent
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-02-05 19:40:50 -08: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
Tonis Tiigi 9598fa243b archutil: amd64 variants support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-31 11:28:02 -08:00
Tonis Tiigi e38f34c7d4 archutil: refactor to return structs
Working with strings is error-prone because a platform
can be in multiple string forms and less flexible.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-31 11:28:02 -08:00
CrazyMax 07dea88ee0
otel: update semconv
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-01-28 10:19:00 +01:00
Tonis Tiigi ffce8218e3 keep buffer of logs to show on failure when regular logs are clipped
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-24 21:30:46 -08:00
Tõnis Tiigi c18af390ef
Merge pull request #2572 from tonistiigi/tracing-env-update
tracing: move to newer env names
2022-01-20 12:58:05 -08:00
Tonis Tiigi f5dbcf6e99 tracing: move to newer env names
open-telemetry/opentelemetry-specification#740 has decided to
promote different set of env for CLI propagation.

Switch to use them so we are more consistent with other
tools. Old ones should be removed in a future release.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-19 21:46:10 -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
Akihiro Suda 15fb1145af
Merge pull request #2491 from ktock/overlayfs-redirect
Disable redirect_dir for avoiding incorrect diff
2022-01-05 14:03:04 +09:00
Kohei Tokunaga bc5cfe960b Disable redirect_dir for overlayfs snapshotter
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-12-24 11:58:44 +09:00
Tõnis Tiigi 76234fa1c7
Merge pull request #2498 from tonistiigi/warnings-updates
Updates to warnings handling
2021-12-14 17:01:46 -08:00
Tõnis Tiigi ccd6964323
Merge pull request #2517 from sipsma/diffop-prep
DiffOp Preparation Commits
2021-12-10 10:50:41 -08:00
Erik Sipsma 0ddfb544b5 snapshot: cleanup diffApply and prepare for DiffOp
This breaks the giant blob that was the diffApply function into two
separate parts, a differ and an applier, which results in more modular
code that should be easier to follow and easier to make any future
updates to. For example, if we want to optimize by allowing differ and
applier to run in parallel in the future, that's straightforward now.

There are also some fixes that weren't needed for MergeOp, but will be
for DiffOp, such as correctly handling the case where a deletion is
applied that is under parent directories which don't exist yet (the
correct behavior is, surprisingly, to create the parent directories as
that is what the image import/export code ends up doing).

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-12-09 21:21:35 -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
Erik Sipsma 2bfad4b0dc Change integration.Test from a func to a interface
Using an interface instead of a func is more flexible while achieving
the same effect. It allows you to succintly define a large number of
test cases as structs, as is common in table-driven testing.

A helper func is added that converts the existing test funcs into the
interface, so the change is fairly seamless.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-12-09 20:35:48 -08:00
Tonis Tiigi 86b4bdbca4 archutil: update generator
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-12-06 22:25:25 -08:00
Tonis Tiigi 71316c6f29 split warning message into short and detail
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-12-02 18:17:35 -08:00
Sebastiaan van Stijn 314bedc808
util/sshutil: minor linting / warning nits
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-12-01 17:01:15 +01:00
Tonis Tiigi 0dd260bcf5 progessui: return warnings from printer
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-11-30 21:58:37 -08:00
Tonis Tiigi d100814aad progressui: show warnings
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-11-30 21:58:37 -08:00
Erik Sipsma 18292913c4 overlay differ: Do file comparison in some cases.
This change results in the overlay differ comparing files to determine
if they are actually part of the diff. This is needed to resolve
differences between the blobs created by the overlay differ and the
double-walking differ.

Before this change, the overlay differ always just assumed that if a
file was in the upperdir it must be part of the diff and included it as
an add or a modify change. However, there are situations in which files
can appear in the upperdir without having been modified or even opened.
For example, if "foo" is a file or dir present in the lowerdirs of an
overlay mount and you run "mv foo footmp; mv footmp foo", then the
upperdir will contain foo (in addition to any files found under foo if
it's a dir). In this situation, the double-walking differ would not
include foo as part of the diff, but the overlay differ would.

This meant that the overlay differ would potentially include extra files
in each blob for such diffs relative to the double-walking differ. As of
now, while this does increase image size, it doesn't result in any
inconsistencies in terms of the contents of images because it just
results in files/dirs getting duplicated on top of their equivalents.

However, for the upcoming DiffOp support, this inconsistency could
actually result in the same operation producing mounts with different
contents depending on which differ is used. This change is therefore
necessary in order to enforce DiffOp consistency (on top of the possible
improvements to exported image size).

The main concern here is that this could undo the performance benefits
that the overlay differ was intended to fix. However, in practice the
situations where this has worse performance are quite obscure and the
benefits should still be present.

First, consider the case where foo is a directory and the user does the
equivalent of "mv foo footmp; mv footmp foo". Even before this change,
the overlay differ would see that foo is marked as opaque and thus fall
back to using the double-walking differ. So there's no performance
regression in this case as the double-walking differ does the same
file comparisons as were added in this commit.

For the case where the user shuffles a file back and forth, there will
potentially be a slow file content based comparison if the underlying
file has a truncated nanosecond timestamp (i.e. it was unpacked from a
tar file). However, the situations in which you shuffle an individual
file without changing it (or open it for writing but then write nothing)
that is large enough in size for content comparisons to be slow are
obscure. Additionally, while the content comparison may be slow, there
will be time saved during export because the file won't be included
unnecessarily in the exported blob, so it's a tradeoff rather than a
pure loss.

In situations where the user actually did change a file and it shows up
in the upperdir, it should be extremely rare that the content comparison
code path is followed. It would require that the user changed no other
metadata of the file, including size, and both mod timestamps were the
same (which could only really happen if their underlying filesystem
lacked support for nanosecond precision and they modified the file
within 1 second of its modification in the lowerdir or they manually
changed the modtime with chtimes).

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-24 11:27:32 -08:00
Aaron Lehmann f71293f5de Fix ticker leak in DisplaySolveStatus
The "defer" is bound to the original value of the ticker, and won't stop
a ticker that's created later in the function. Example:
https://play.golang.org/p/puat5JEf5Jw

Ran into this in a health checker that periodically created buildkit
clients.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2021-11-18 15:36:46 -08:00
Tõnis Tiigi fce4a32258
Merge pull request #2335 from sipsma/mergeop-impl
MergeOp
2021-11-18 11:52:15 -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
Tonis Tiigi b449431019 imageutil: make mediatype detection more stricter
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-11-17 15:44:18 -08:00