Commit Graph

191 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
Tonis Tiigi
c4a9c39e61 authprovider: add OTEL spans for loading credentials
Credential loading could take long depending on credentials storage.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-16 20:52:09 -07:00
Tonis Tiigi
a6e85c7fd0 tracing: enable OTEL on authprovider requests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-16 20:52:09 -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
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
Akihiro Suda
d58187752a Merge pull request #5254 from tonistiigi/uploadprovider-closer
uploadprovider: allow closing used sources
2024-08-18 06:50:49 +09:00
Tonis Tiigi
df0d9d791d ci: update golangci-lint to v1.60.1
Previous version runs out of memory on go1.23

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-08-14 16:29:22 +03:00
Tonis Tiigi
3294c68b99 uploadprovider: allow closing used sources
Helps detecting when uploadprovider has finished
with the source. This avoids deadlock, should the
same reader be shared by multiple uploads that sync
with each other.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-08-14 13:16:58 +03: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
Brian Goff
bffd55831d Always return non-nil contexts
This prevents cases where the returned nil context ends up overwriting
another context in the caller which can mess up defers.

Ex:

```go
ctx := context.Background()

defer func() {
  cleanup(ctx)
}()

ctx, done, err := leaseutil.WithLease(...)
```

In this cae when `leaseutil.WithLease` has an error, before this change
the returned context is nil.
The solver this can trigger a panic when the context is cancelled
because leaseutil will error out and then a prior defer function will
call `context.WithoutCancel(ctx)` triggering the panic because context
should never be nil.

leaseutil seems like the only place this was problematic but changed a
couple of other places I found to make sure they don't cause problems if
the caller changes in the future.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-07-02 19:51:06 +00:00
Tõnis Tiigi
1ebbf434d3 Merge pull request #4994 from profnandaa/fix-windows-local-export-2
fix: acquire privileges to access special files on windows
2024-06-27 14:58:32 -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
Sebastiaan van Stijn
0f89a763aa vendor: github.com/containerd/containerd v1.7.18
Update to containerd 1.7.18, which now migrated to the errdefs module. The
existing errdefs package is now an alias for the module, and should no longer
be used directly.

This patch:

- updates the containerd dependency: https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18
- replaces uses of the old package in favor of the new module
- adds a linter check to prevent accidental re-introduction of the old package
- adds a linter check to enforce using an alias, to prevent accidental use
  of the errdefs package in BuildKit or Moby.
- adds a linter check to prevent using the "log" package, which was also
  migrated to a separate module.

There are still some uses of the old package in (indirect) dependencies,
which should go away over time.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-05 08:54:22 +02: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
guoguangwu
b94bdb0bbc fix: close files in the toAgentSource func
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
2024-04-26 09:50:24 +08:00
Tonis Tiigi
1f9988911f lint: unusedparams fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Tonis Tiigi
c7d2543482 lint: stdmethods fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:15 -07:00
Jonathan A. Sternberg
c3105e49d9 otel: update usage of otelgrpc interceptors to use stat handlers
The otelgrpc interceptors were deprecated. This updates the areas where
these were used to use the stat handlers instead of the interceptors.
This helps with creating a single method for both unary and stream rpcs
and also ensures we aren't using a deprecated function for the future.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-03-29 16:39:25 -05:00
Sebastiaan van Stijn
841e397d54 vendor: OTEL v0.46.1 / v1.21.0
Temporarily adding some "nolint" tags, and a TODO for replacing some
deprecated features;

    client/client.go:105:43: SA1019: otelgrpc.UnaryClientInterceptor is deprecated: Use [NewClientHandler] instead. (staticcheck)
            unary = append(unary, filterInterceptor(otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators))))
                                                    ^
    client/client.go:106:27: SA1019: otelgrpc.StreamClientInterceptor is deprecated: Use [NewClientHandler] instead. (staticcheck)
            stream = append(stream, otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(tracerProvider), otelgrpc.WithPropagators(propagators)))
                                    ^
    solver/jobs.go:515:13: SA1019: trace.NewNoopTracerProvider is deprecated: Use [go.opentelemetry.io/otel/trace/noop.NewTracerProvider] instead. (staticcheck)
        _, span := trace.NewNoopTracerProvider().Tracer("").Start(ctx, "")
                   ^
    util/tracing/detect/detect.go:108:7: SA1019: trace.NewNoopTracerProvider is deprecated: Use [go.opentelemetry.io/otel/trace/noop.NewTracerProvider] instead. (staticcheck)
        tp = trace.NewNoopTracerProvider()
             ^
    cmd/buildkitd/main.go:273:19: SA1019: otelgrpc.StreamServerInterceptor is deprecated: Use [NewServerHandler] instead. (staticcheck)
            streamTracer := otelgrpc.StreamServerInterceptor(
                            ^
    cmd/buildkitd/main.go:664:15: SA1019: otelgrpc.UnaryServerInterceptor is deprecated: Use [NewServerHandler] instead. (staticcheck)
        withTrace := otelgrpc.UnaryServerInterceptor(
                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-22 18:46:05 +01: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
09648f4d29 replace WithTimeout with WithTimeoutCause
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-12-06 22:15:12 -08: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
x893675
50990100c5 buildctl: Add insecure config for registry-auth-tlscontext flag
Signed-off-by: x893675 <x893675@icloud.com>
2023-11-16 11:25:25 +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
463bdab463 uploadprovider: avoid too big grpc messages on tar upload
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-09 18:23:56 -07:00
Tonis Tiigi
ac33aec24e session: raise grpc message size limits for session endpoint
These limits were already set for control API requests but
not for session requests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-09 18:23:56 -07: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
75896378d7 Merge pull request #4211 from njucjc/support-auth-tls
buildctl: Add configured TLS certificate to trust store when making calls to registry auth
2023-09-15 17:28:40 -07:00
njucjc
2bd8d76504 buildctl: Add configured TLS certificate to trust store when making calls to registry auth
Signed-off-by: njucjc <njucjc@gmail.com>
2023-09-14 14:28:38 +08:00
Aaron Lehmann
95e5f6b76f authprovider: Fix error return from Credentials when logger is nil
This would segfault if SetLogger had not been called, because
progresswriter.Wrap returns nil when its logger arg is nil, causing
Credentials to return nil, nil.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2023-09-11 11:16:18 -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