Commit Graph

81 Commits

Author SHA1 Message Date
Marat Radchenko
0a5a80cfec Remove pre-Go 1.17 build tags
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-11-21 10:58:27 +03:00
Tonis Tiigi
e05a89e0b8 improve stacks of cancels from defers
In this case the current stack trace points to the line
where the context was created. Instead the stack should be
captured when the defer is running so the return path to
the defer call is also part of the stack.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-19 18:40:00 -08:00
Tonis Tiigi
c9a25c4d8a pb: regenerate protobuf
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-28 12:56:03 -07:00
Jonathan A. Sternberg
c9029975da filesync: reuse data buffer for diffcopy
Reuse the bytes message data buffer for diffcopy to allow memory to be
reused when unmarshaling the bytes.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-10-21 12:50:46 -05: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
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
Tonis Tiigi
ab2c224e72 session: remove session name property
This seems to be completely unused.

I believe it is remnant of pre-buildkit session implementation
and was used for either logging of some transfer reuse.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-19 17:22:04 -07:00
Anthony Nandaa
e7ceb63b3c wip: tar and local exporter running with privileges
TODO: need to cross-check that there is no way the
SeBackupPrivilege can be abused/exploited.

WIP: how best to handle the files to be exclused
without touching `fsutil`

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2024-06-10 17:24:05 +03:00
Tonis Tiigi
03c7a6d769 lint: fix some testifylint warnings
This does not cover all warning yet but split
into chunks to ease review.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-30 11:32:55 -07:00
Justin Chadwell
44d62f23aa filesync: append metadata for CopyToCaller
This was a regression introduced in 81b4762291.

Similar in style to 4b56395369, we need to
ensure that CopyToCaller also doesn't overwrite the provided metadata,
but instead appends to it.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-16 15:55:10 +00:00
Justin Chadwell
1c1777b7c0 exporter: use implicit ids for exporters
We can derive exporter ids from their place in the exporter array in a
SolveRequest - this removes the need to manually generate and handle
multiple sets of IDs.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Justin Chadwell
81b4762291 session: add file send multiplexing
This patch adds multi-plexing to the local file transfer protocol (from
server to client). This is implementation-wise similar to the
multiplexing from the containerd content store transfer protocol, using
a GRPC header to select the appropriate target.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:04:28 +00:00
Justin Chadwell
a80b48544c session: create helper type for exporter file output
Co-authored-by: a-palchikov <deemok@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:03:39 +00:00
Justin Chadwell
578e8105c3 filesync: add doc comments in proto
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:03:39 +00:00
Tonis Tiigi
8a2a3e83ec replace context.WithCancel with WithCancelCause
Keep stack traces for cancellation errors where possible.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-12-06 22:15:06 -08:00
Tõnis Tiigi
892fbdfd0b Merge pull request #4313 from tonistiigi/session-grpc-message-size-fix
session: fix grpc message size limits for tar streams
2023-11-13 12:48:58 -08:00
Justin Chadwell
11b8c6e0b6 session: modify FSSync provider to take fsutil.FS objects
This patch modifies the function signature of the FSSync provider to
take an fsutil.FS instead of a simple raw path resolved to the client's
root filesystem.

Internally, we were already creating an fsutil.FS to Send to the
buildkit server, however, this abstraction didn't reach the session
attachable parameters, so we couldn't provide our own custom FS
implementation.

The rationale behind this change is to allow providing more abstract
custom filesystem implementations to a BuildKit client. This way, we can
start to build from filesystems that might not be on disk - for example,
we could use our Static filesystem implementation in tests to prevent
creating lots of temporary directories, or we could use our Merge
filesystem implementation to allow easily creating variants of a single
context.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:48:34 +01:00
Justin Chadwell
8ba1deb94a vendor: update fsutil to master@f09800878302
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-10-23 12:48:33 +01:00
Tonis Tiigi
329e945c25 filesync: split stream data into 3MB chunks to avoid message limits
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-09 18:23:48 -07:00
Tõnis Tiigi
eddfcd5265 Merge pull request #4049 from sipsma/append-grpc-headers
filesync: append rather than replace grpc md.
2023-08-29 09:20:02 -07:00
Justin Chadwell
85e2e252ee Merge pull request #4124 from jedevc/chore-refactor-filesync-encode 2023-08-14 15:23:36 +01: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
Justin Chadwell
c02f99dbce chore: tidy up filesync encode headers handling
Co-authored-by: a-palchikov <deemok@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-08 13:34:23 +01:00
CrazyMax
5b8f962c24 filesync: write closer err discarded
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-08-08 07:53:21 +02:00
Justin Chadwell
1ec36ece35 filesync: remove deprecated override-excludes
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-01 17:28:20 +01:00
Erik Sipsma
4b56395369 filesync: append rather than replace grpc md.
Before this, CopyFileWriter just used metadata.NewOutgoingContext to set
metadata, which results in any pre-existing metadata from the provided
context to be removed.

Now, it gets the current metadata and then sets its own on top of that,
so any pre-existing unrelated metadata is retained.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-07-25 13:39:12 -07:00
Tonis Tiigi
48b62404e3 filesync: fix backward compatibility with encoding + and %
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-07-12 09:31:17 -07:00
Justin Chadwell
5230f200ce filesync: escape special query characters
This ensures that files with '%' and '+' can still be properly copied.

To prevent regressions, this also adds in a couple of example test
cases.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-07-11 15:07:53 +01:00
Tonis Tiigi
a09e2d88dd filesync: mark if options have been encoded to detect old versions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-07-05 23:50:49 -07:00
Tonis Tiigi
9d491e7818 filesync: fix handling non-ascii in file paths
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-09 17:53:07 -07:00
Alex Suraci
3548517cf2 allow dynamic LocalDir access
Changes the filesync attachable to accept an interface instead of a
static allowlist of dirs. This way a single session can support syncing
directories not known ahead of time.

Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
2022-10-26 21:04:57 -04: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
Nick Santos
844618f506 vendor: upgrade github.com/tonistiigi/fsutil
fixes https://github.com/moby/buildkit/issues/2837

Signed-off-by: Nick Santos <nick@tilt.dev>
2022-05-10 12:38:42 -04: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
Edgar Lee
b3e8c63a48 Local should use session ID in op and only fallback to session group if failed before transfer started
Signed-off-by: Edgar Lee <edgarl@netflix.com>
2022-01-28 15:18:43 -08:00
Tonis Tiigi
35fcb28a00 Clean up old TODOs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-09-14 22:28:08 -07:00
Morlay
18b49fd7dc refactor to use util/bklog instead of using logurs directly
Signed-off-by: Morlay <morlay.null@gmail.com>
2021-07-13 11:42:31 +08:00
Tonis Tiigi
ee39f5dd68 dockerfile: use none differ for dockerfile/dockerignore
This avoids wrong metadata matches on small files

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-06-29 16:17:08 -07:00
Tonis Tiigi
baa4fcdb0f add differ support for local source
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-06-11 21:15:07 -07:00
Tonis Tiigi
ce27b7e638 filesync: ensure sendclose is always called
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2021-06-08 21:19:10 -07:00
Charles Korn
8854bbc431 Fix https://github.com/moby/buildkit/issues/2109.
Signed-off-by: Charles Korn <me@charleskorn.com>
2021-05-26 09:50:15 +10:00
Akihiro Suda
13ea18ad08 vendor containerd (requred for rootless overlayfs on kernel 5.11)
Required for rootless overlayfs on kernel 5.11
https://github.com/containerd/containerd/pull/5076

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-03-10 13:51:27 +09:00
Tonis Tiigi
b474dbf55f resolver: clean up unused resolver pool
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-08-13 17:27:18 -07:00
Tonis Tiigi
bd3354fea3 session: avoid deprecated grpc.Stream type
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-07-19 09:28:36 -07:00
Tonis Tiigi
6bd2d45527 filesync: avoid ignoring close error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-05-08 17:48:56 -07:00
Tonis Tiigi
37b8832d00 upgrade errors checks to Is()
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-04-18 22:53:38 -07:00
Akihiro Suda
7b579cdb98 vendor: update containerd (and various packages)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-28 10:24:10 +09:00
Tonis Tiigi
96b6a28312 exporter: allow oci exporters visibility to response metadata
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-07-31 10:21:19 -07:00
Tonis Tiigi
d3597181e0 session: wrap errors with debug info
Make sure to cover the grpc errors origins.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2019-06-06 21:15:21 -07:00