Commit Graph

134 Commits

Author SHA1 Message Date
Tõnis Tiigi
16d3799a19 Merge pull request #5517 from jsternberg/deterministic-llb-for-gateway
gateway: ensure llb digests are deterministic when sent by frontends
2024-11-21 09:53:00 -08:00
Jonathan A. Sternberg
56ffa9f66b protobuf: fix casing of json attributes with the switch from gogo
With the switch from gogo, the `oneof` fields no longer have their
`json:"name"` fields emitted. Protobuf doesn't formally support these
fields and tells users to use the `protojson` package, but we didn't and
the official format is incompatible with the current format we use.

This adds some custom marshaling code to the already existant custom
unmarshaling code to ensure these fields are marshaled with the correct
casing.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-11-15 13:17:42 -06:00
Jonathan A. Sternberg
9f65f8c1fa gateway: ensure llb digests are deterministic when sent by frontends
This ensures different valid protobuf serializations that are sent by
frontends will be rewritten into digests that are normalized for the
buildkit solver.

The most recent example of this is that older frontends would generate
protobuf with gogo and the newer buildkit is using the google protobuf
library. These produce different serializations and cause the solver to
think that identical operations are actually different.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-11-14 16:12:28 -06:00
Tonis Tiigi
c9a25c4d8a pb: regenerate protobuf
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-28 12:56:03 -07:00
Tõnis Tiigi
6860c8097d Merge pull request #5359 from tonistiigi/gc-free-max-support
update default and basic gc control to use free and max storage
2024-10-08 08:28:40 -07:00
Tonis Tiigi
d45a506aac cache: rename new prune/gc control fields
Naming that was chosen during review was
reservedSpace, maxUsedSpace and minFreeSpace.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-04 17:23:04 -07:00
Tonis Tiigi
a75b5eb15b add capability to detect if new storage filters are supported
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-04 17:21:53 -07:00
Jonathan A. Sternberg
41a0a0c37d protobuf: add vtproto as a supplemental marshaler
vtproto is an extra protobuf compiler that generates special methods
suffixed with `VT` that create typed and unrolled marshal and unmarshal
functions similar to gogo that can be used for performance sensitive
code. These extensions are optional for code to use but buildkit uses
them.

A codec is also included to utilize vtproto for grpc code. If the
package `github.com/moby/buildkit/util/grpcutil/encoding/proto` is
imported then vtproto will be used if it exists and otherwise it will
use the standard marshaling and unmarshaling methods.

This codec has an important difference from the default codec. The
default codec will always reset messages before unmarshaling. In most
cases, this is unnecessary and is only relevant for `RecvMsg` on
streams. In most cases, if we are passing in an existing message to this
method, we want to reuse the buffers. This codec will always merge the
message when unmarshaling instead of resetting the input message.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-04 12:52:15 -05:00
Jonathan A. Sternberg
ffd8ff490e protobuf: normalize how protobuf files are generated
The relative paths option for protoc generators doesn't work well when
it comes to dependencies. This simplifies the code generation to avoid
using `go generate` and to use one global command for protoc generation.

This is similar to https://github.com/docker/buildx/pull/2713 since the
same problems with code generation occur here too.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-03 17:40:53 -05:00
Tonis Tiigi
25632fb074 client: allow non-octal chmod config for fileop.copy
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-01 12:52:38 -07:00
Jonathan A. Sternberg
1a3fc0aa15 protobuf: remove gogoproto
Remove gogoproto in favor of the standard protobuf compiler. This
removes any nonstandard extensions that were part of gogoproto such as
the custom types.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-09-26 12:57:45 -05:00
Justin Chadwell
7e6c20a0db exec: allow specifying non-zero exit codes for execs
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-09-17 11:36:07 +01:00
Erik Sipsma
7bc06cb0b7 add support for AlwaysReplaceExistingDestPaths in llb copy
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2024-04-02 12:11:06 -07:00
Justin Chadwell
0eb25a6bf7 exec: allow caller-controlled content-based cache
This allows LLB-directed content-based cache enablement for each mount.

Some mounts may not be explicitly unabled (because it would be unsafe) -
for these cases we explicitly error out.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-02-06 11:44:25 +00:00
Justin Chadwell
88221133af solver: add cap for multiple exporters
Higher-level clients should be able to check server-side caps to ensure
that when they attempt to use multiple exporters, that the feature is
actually supported.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Jonathan A. Sternberg
40fb5ce649 llbsolver: unmarshal protobuf objects into the provenance attestation correctly
This modifies how build steps are unmarshaled from JSON into the
provenance attestation. The current method doesn't correctly handle
protobuf attributes that are used with `oneof`.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-11-13 09:57:30 -06:00
Paul "TBBle" Hampson
98e0d8dcff Whenever copying OCI Platform data, include OSVersion and OSFeatures
Trivially created by looking for every reference to .Variant and adding
OSVersion and OSFeatures, except the ones related to the string
representation of a Platform instance.

I then went through and ensured every assignment of OSFeatures that
might leak out, i.e., not local-only or for marhsalling purposes, uses
the append-to-nil idiom to avoid sharing the slice storage and allowing
accidental mutation after-the-fact.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-11-03 12:19:29 +09:00
Justin Chadwell
c5402622bb lint: add protolint config
And tidy up the proto definitions to follow the new linting rules.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-10 13:11:18 +01:00
Tonis Tiigi
1553c2ad95 add language property for sourcemap
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-29 17:17:56 -07:00
Tõnis Tiigi
444cb34af7 Merge pull request #3426 from benlongo/fix-typo-in-exec-mount-bind-readwrite-nooutput
Fix typo in CapExecMountBindReadWriteNoOutput
2022-12-19 22:07:12 -08:00
Ben Longo
5896c5477c Fix typo in CapExecMountBindReadWriteNoOutput.
Signed-off-by: Ben Longo <benlongo9807@gmail.com>
2022-12-16 23:19:02 -05:00
Akihiro Suda
0d3f71ee18 llbsolver: support pinning sources
Alternative to PR 2816 ("dockerfile: support Dockerfile.pin for pinning sources")

This version is implemented on the llbsolver side and agnostic to the LLB frontends.
See `solver/llbsolver/vertex.go:loadLLB()`.

See `docs/build-repro.md` for the usage.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-12-13 13:01:54 -08:00
Justin Chadwell
a925cd7c4c solver: attach store id as explicit property of source
This breaking api change refactors the LLB API to prevent reference
mangling and demangling throughout OCI access. Once the session and
store IDs have been determined in the dockerfile frontend, we keep them
the same, and attach them as additional properties.

This has the additional effect of making the actual reference used in
the image resolution arbitrary, since we only parse and access the
digest. The rest of the name can be selected to optimize for log
readability.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-13 11:41:30 -08:00
Justin Chadwell
d81928a72f solver: delete caps for additional oci properties
We don't need multiple caps for a single feature - the caps that these
were copied by were addded over time, we don't immediately need all of
them to start with, only the main feature one is initially required.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-13 11:38:50 -08:00
Justin Chadwell
6b265b1bae gateway: add RemoveMountStubsRecursive to exec meta options
This allows a frontend to request a specific for stubs removal.

By default, if not specified, this will revert to the previous
behaviour. New gateway clients however will set the property to the
desired recursive removal mode.

This property needs to be set for both components that call the
executor: for ExecOp, as well as for the StartContainer API.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-07 19:06:47 +00:00
Tonis Tiigi
dbee61670d add build history APIs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-22 23:59:33 -08:00
Tonis Tiigi
ec0b7b9905 exporter: add SOURCE_DATE_EPOCH support for image exporter
Allows reproducible timestamps for layer and image timestamps.

Implemented as a frontend-opt because in the future same
option could be detected by frontend for custom behavior
and same value should also apply timestamps for FileOps.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-10-12 17:29:01 -07:00
Justin Chadwell
3c64e516ce attestations: enable attestations cap
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-09-07 17:24:19 +01:00
Justin Chadwell
d392e45ec0 attestations: fixup from review
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-09-07 17:23:46 +01: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
Tõnis Tiigi
c07a6562f1 Merge pull request #3022 from crazy-max/go-1.19
update to Go 1.19
2022-08-24 17:10:11 -07:00
CrazyMax
1353f411d9 update to go 1.19
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-19 10:26:24 +02:00
Justin Chadwell
d76e401d26 solver: add attestations capability
This will eventually clients to query the server to confirm if
attestations are supported. However, for now, we can keep it disabled
until the gateway api stabilizes.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-08-11 14:27:04 +01:00
Tonis Tiigi
d1b0d8a7c6 subrequests: normalize json fields to lowercase
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-08-05 00:40:41 -07:00
Tõnis Tiigi
a6a114a1a4 Merge pull request #2879 from jedevc/annotations-support
Add annotations support to output
2022-06-16 18:05:17 -07:00
Justin Chadwell
28b9f1e743 solver: add capability for annotations export
Allows clients to query if annotations exporting is supported.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-06-16 13:25:24 +01:00
Avi Deitcher
1fe66075b7 Add OCI source
Signed-off-by: Avi Deitcher <avi@deitcher.net>
2022-06-15 23:04:11 +03: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
5ac05cb482 Allow pulling partial layer chains from an image
Adds a new `WithLayerLimit` option to `llb.Image`
only pulls specified number of layers instead of
full image.

This can be used in combination with DiffOp/MergeOp
to pull any subset of layers from an image in any order.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-04-21 21:54:13 -07:00
Ce Gao
b150c29ac2 fix: Fix the comment
Signed-off-by: Ce Gao <ce.gao@outlook.com>
2022-03-17 14:46:40 +08:00
Erik Sipsma
cc1499e6d9 Add support for weak ProgressGroup membership.
A ProgressGroup will now only be displayed if a vertex member marked as
non-weak has started.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-02-25 10:24:15 -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
Tonis Tiigi
30a0b02479 exec: allow mounting secret environment variables
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-01-31 11:22:57 -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
Erik Sipsma
8c1e411d01 Add DiffOp support to solver and client.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2022-01-06 11:05:51 -08:00
Erik Sipsma
43a74261b3 Remove symlink, not target, in FileOp.Rm.
Before this change, if the path provided to FileOp.Rm was a symlink then
the target of the symlink would be removed instead of the symlink
itself. Now, the symlink will be removed instead. However, any symlinks
present in the parent dirs of the specified path will still be resolved
before calling os.Remove; this change only results in the base of the
specified path not being followed.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-11-18 12:44:12 -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
CrazyMax
c82ef274bf cgroup-parent support
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-27 23:50:20 +02:00
CrazyMax
87e1fa7ecb add size to tmpfs mounts
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-18 10:54:52 +02:00
CrazyMax
4e32ae5630 Add support for ulimit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-10-08 11:50:09 +02:00