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>
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>
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>
Error during creating history or failure in graph concistency
checks are signs of either bugs or system configuration issue. This
makes sure that gRPC error code in the API error based on these
cases has correct value to signify it.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Client can send a finalize update to build record that
will complete saving the traces and block until the record
has been updated. If no request is sent then the traces will be
sent after a 3 second timeout as before.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Check that the result returned from the frontend
matches the user request conventions and show a
warning if it doesn't.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
20 sec stall on an platter old hdd is not unexpected.
Nor is 20s write on a low-tier cloud environment drive unexpected.
300s should however be enough to tell the difference between crappy hardware and actual failure.
fixes#4327
Signed-off-by: Dennis Haney <davh@davh.dk>
The trace recorder is now a separate entity and does not wrap another
span exporter. It is added as another span processor to the underlying
tracer provider so the two can be disconnected from each other and this
removes the need to use `detect.Exporter()` to find the TraceRecorder
along with the need to invoke flush manually.
The trace recorder is wrapped with a simple span processor instead of
the batch one. That makes the flushing irrelevant for this purpose.
The trace recorder itself is also modified to avoid leaking goroutines
and respecting context cancellations.
This is part of a general refactor of the detect package to separate the
buildkit-specific functionality from the external exporter detection.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Follow-up to ce332e1952 - this didn't
resolve the access to sysSampler.Close, we need to stub this one out as
well!
Signed-off-by: Justin Chadwell <me@jedevc.com>
Running interactive container APIs was done by giving
the gateway implementation access to worker controller
directly, but it should be passed with a build job instead.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 0971dffaab93d91e51af984b44c745b35b3c5b4d)
The solver has a Close method to shutdown the scheduler, which releases
a goroutine. We should call it on shutdown.
While in the area, we can also close the sysSampler.
Signed-off-by: Justin Chadwell <me@jedevc.com>
This is possible with llb.Scratch in a multi-platform build. We were
accidentally discarding the nil entries in Refs.
Instead, we just skip over nil refs. This isn't ideal - we *should* be
able generate provenance for a nil ref. However, 1. this isn't handled
for llb.Scratch as a single-platform result, and 2. this is tricky,
since the ResultProxy is nil at this point (so there's no ID to match
on). This should be ok for a quick fix, but we can come back and fix
this later.
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 support for multiple exporters at the control API, and
propogates the resulting required changes through the client and the
solver.
A few notable changes:
- Each exporter instance now has an associated identifier
- Build records in the build history now have multiple possible
descriptors to built content
- Exporter responses are all merged together (like we currently do with
multiple cache exporters). We likely will need to revisit this design
later, since now cache exporters do not line up one-to-one with
exporters.
For backwards compatability, new clients will continue to produce
requests that contain the now deprecated exporter fields, as well as the
new ones. New servers will attempt to use deprecated fields if they
are present.
Co-authored-by: a-palchikov <deemok@gmail.com>
Co-authored-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
This preps for the case where a single exporter source does not map
neatly onto a single inline cache - such as introducing multiple
exporters.
We also introduce laziness here - each exporter chooses to attempt
extracting the inline cache on demand, which ensures that we avoid
creating inline caches for exporters that do not support them.
Co-authored-by: a-palchikov <deemok@gmail.com>
Co-authored-by: fahed dorgaa <fahed.dorgaa@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
This exposes the otel metrics through the environment variables for the
otel collector or through the prometheus `/metrics` endpoint through the
debug address.
This also adds metrics for the grpc endpoints from the opentelemetry
libraries.
For the opentelemetry collector, the metric temporality is delta which
reduces the amount of data that goes over the wire overall. Prometheus
metrics are cumulative because prometheus metrics require that.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
The older of rules in policy matters. Eg. in [DENY *, ALLOW ref]
mixing the order would deny all sources so map can't be used
to deduplicate the rules.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
If resultProxy has been created but the result has not been
evaluated then it shouldn't show missing provenance error
for that result.
This patch works together with previous one that fixes
error reporting on provenance creation.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
We were using a mixture of own custom const and the vendored const. For
consistency, we should use only the vendored const everywhere.
Signed-off-by: Justin Chadwell <me@jedevc.com>
Recording build history calls into LeaseManager, which can block for
several seconds. This can trigger a 3 second timeout in GatewayForwarder
while it waits for a build ID to be registered. Longer-term, we should
figure out the performance issues in the containerd metadata DB, but
this addresses the immediate problems of timeouts that manifest in these
error messages:
forwarding Ping: no such job 93oss3bmbagcpq8yokla3921z
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>