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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>