Commit Graph

147 Commits

Author SHA1 Message Date
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
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
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
thompson-shaun
7c025bfbbe Merge pull request #5163 from tonistiigi/history-graphstate-errors-internal
solver: mark history and graph concistency errors as internal
2024-07-25 12:08:19 -04:00
Tonis Tiigi
ce9e28281a llbsolver: avoid nil releaser on error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-22 17:47:12 -07:00
CrazyMax
1aa17c046a history api: save number of warnings to build record
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-18 13:40:23 +02:00
Tonis Tiigi
5149ea81e9 solver: mark history and graph concistency errors as internal
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>
2024-07-17 16:28:41 -07:00
Tonis Tiigi
76945ca7d4 llbsolver: make sure stoptrace called on bolt error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-08 20:34:18 -07:00
Tonis Tiigi
3139b164d5 solver: allow finalizing history record traces
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>
2024-07-02 00:08:20 -07:00
Tonis Tiigi
6e38854262 llbsolver: move typed error to own blob in history
Avoid putting big error metadata to main history record
and instead write it to a separate blob.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-01 21:48:12 -07:00
Tõnis Tiigi
ff1674a396 Merge pull request #5031 from tonistiigi/context-withoutcancel
ensure context.WithoutCancel in defer funcs
2024-06-18 12:56:04 -07:00
Tonis Tiigi
4103099d94 ensure context.WithoutCancel in defer funcs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 19:18:32 -07:00
Tonis Tiigi
dfc35271ae simplify with maps pkg functions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 18:33:30 -07:00
CrazyMax
6b6fa9d5fa history: fix empty Exporters attribute
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-06-11 17:09:54 +02:00
Tonis Tiigi
031b3162ed llbsolver: add more otel spans for export and history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-05 19:52:49 -07:00
Tõnis Tiigi
c574c5874b Merge pull request #4908 from tonistiigi/platforms-verify
verifier: verify platforms of the build result
2024-05-31 08:18:08 -07:00
Tonis Tiigi
acb1bed96c verifier: verify platforms of the build result
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>
2024-05-30 11:05:52 -07:00
Tonis Tiigi
7b52fed89f llbsolver: create single temp lease for exports for performance
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-23 09:49:20 -07:00
Dennis Haney
bf1da9647c fix: 20 sec timeout for write to disc too short
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>
2024-05-22 06:38:04 +02:00
CrazyMax
8769cd5e3c solver: infer builder id from user input for provenance in build record
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-04-11 15:18:34 +02:00
Jonathan A. Sternberg
0e1cf1ce35 tracing: refactor the trace recorder
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>
2024-03-27 16:00:26 -05:00
Justin Chadwell
d0b170ceb8 solver: stub out sysSampler close
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>
2024-03-18 14:44:33 +01:00
CrazyMax
94e2370023 provenance: move types to a dedicated package
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-02-25 20:39:50 +01:00
Tõnis Tiigi
1981eb123d Merge pull request #4601 from tonistiigi/0131-fix-validate-nil
Add more validations for nil values
2024-01-31 14:07:20 -08:00
Tonis Tiigi
0c5daa2327 gateway: pass executor with build and not access worker directly
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)
2024-01-31 12:38:19 -08:00
Tonis Tiigi
e11862c24d sourcepolicy: add validations for nil values
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 4e2569e796aae398648082689d70ca1d4f4f74a8)
2024-01-31 12:37:22 -08:00
Justin Chadwell
6337e81b37 chore: close solver resources on shutdown
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>
2024-01-26 15:15:03 +00:00
Tõnis Tiigi
d2b7b92a38 Merge pull request #4526 from jedevc/fix-scratch-multiplatform
Fix scratch multi-platform images
2024-01-09 11:15:05 -08:00
Justin Chadwell
7c0f37b09b solver: avoid discarding nil refs entry
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>
2024-01-05 15:17:04 +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
7fb54984ea control: add multiple exporters
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>
2024-01-05 12:04:28 +00:00
Justin Chadwell
4c93f9d9bd exporter: pass inline cache directly to exporter
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>
2024-01-05 12:04:26 +00:00
Justin Chadwell
9c5816a317 chore: remove function indirection for cache exporters
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 12:03:39 +00:00
Tõnis Tiigi
f84cfe3d6a Merge pull request #4460 from jsternberg/otel-metrics
util: expose otel metrics through grpc and prometheus
2023-12-12 14:03:41 -08:00
Jonathan A. Sternberg
7de2e4fb32 util: expose otel metrics through grpc and prometheus
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>
2023-12-12 08:59:01 -06: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
Sebastiaan van Stijn
ce332e1952 executor/resource: stub out NewSysSampler on Windows
Commit 509cfa3916 introduced the SysSampler,
which measures resource consumption. However, for this it depends on
prometheus' procfs. That package does not have build-tags but is a Linux-only
implementation, which (by default) attempts to access `/proc`;
https://github.com/prometheus/procfs/blob/v0.9.0/fs.go#L26-L33
https://github.com/prometheus/procfs/blob/v0.9.0/internal/fs/fs.go#L23-L24

This patch splits the implementation of "resource" into platform-specific
files, and stubs out the NewSysSampler() on non-Linux platforms.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-20 14:28:53 +02:00
Tonis Tiigi
22d84461e4 llbsolver: fix policy rule ordering
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>
2023-07-12 10:09:45 -07:00
Tonis Tiigi
60b3aa72a0 handle missing provenance for non-evaluated result
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>
2023-06-27 22:44:55 -07:00
Tonis Tiigi
509cfa3916 llbsolver: add systemusage samples to provenance attestation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:52:02 -07:00
Tonis Tiigi
6a2f92d08f resources: add sampler for periodic stat reads
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:51:35 -07:00
Tonis Tiigi
6e87e4b455 resources: add build step resource tracking via cgroups
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-08 15:51:31 -07:00
Justin Chadwell
709b72a70e attestations: replace intoto media type with vendored const
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>
2023-05-15 10:15:48 +01:00
Seiya Miyata
9e9cd08494 Fix not to set the value on empty vertex
Signed-off-by: Seiya Miyata <odradek38@gmail.com>
2023-05-09 04:09:37 +09:00
Seiya Miyata
34b0b52860 Fix to import as digest
Signed-off-by: Seiya Miyata <odradek38@gmail.com>
2023-05-09 04:07:42 +09:00
Seiya Miyata
707d84f24b Drop unneeded variable
Signed-off-by: Seiya Miyata <odradek38@gmail.com>
2023-05-08 19:09:22 +09:00
Aaron Lehmann
396b276d45 Register builds before recording build history
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>
2023-03-17 11:06:32 -07:00
coryb
a8aa7b200c use bklog.G(ctx) instead of logrus directly
Signed-off-by: coryb <cbennett@netflix.com>
2023-03-15 12:07:44 -07:00
CrazyMax
6d9c24dc3a remove buildinfo
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-03-10 09:46:52 +01:00