Commit Graph

35 Commits

Author SHA1 Message Date
Tonis Tiigi
c45cd8fa16 history: handle gracefulstop when history is active
When GracefulStop is called gRPC waits for current requests to finish
before closing. While this is generally the behavior we want, it is
not always same for the History.Listen endpoint. That endpoint is
usually open even if buildkit is not actively processing any builds,
because client may be waiting for new events.

The new logic is that if GracefulStop will happen, history will
close active listeners if there are no active builds. If there are
active builds then active listeners will be closed after all the
active builds have completed their finalizers.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-15 10:58:48 -08:00
Tonis Tiigi
65f5dad9ff fix gc after delete history records
Current implementation based on leases.SynchronousDelete only works
with the containerd worker and is ignored otherwise. This means that
blobs referenced by history records were left on disc until the
periodic background GC was initialized later.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-12 17:43:55 -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
CrazyMax
2c10f56e47 history: remove records without attached blobs at startup
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-02 13:12:43 +02: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
13bd25cd58 db: move DB dependencies to transactor interface
This allows more flexible control over DB transactions
and compaction.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-25 12:55:16 -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
3d00c54779 llbsolver: fix possible early delete of external error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-10 00:09:47 -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
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
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
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
Tonis Tiigi
eb942eae5b unify ReadAt to ReadCloser conversion
Also removes dependency from pkg/ioutils

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-05 16:24:40 -07:00
Justin Chadwell
a1826acd72 history: wrap os.ErrNotExist errors
While debugging around, I found some instances of os.ErrNotExist
appearing in the logs from the history API - however, no stack traces
were available, since they're not wrapped.

This patch just adds wrapping for them, with some additional debbuging
info.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-22 13:27:52 +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
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
CrazyMax
9d39af0e62 llbsolver: fix possible panic when setting event to nil
When a record is marked for deletion the event is set to nil
but we don't check if it's nil when sending events which could
cause a panic.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2023-11-29 17:48:53 +01:00
Tonis Tiigi
1ed9931af1 llbsolver: fix possible deadlock in history listen
The events for currently active builds were sent through
pubsub channel instead of directly to the current request,
like it was done for completed builds for example.

This meant that if there are more active builds running
than the pubsub channel buffer (32) the sends will block.
Because the history API mutex is held in this process it
will eventually block the requests for builds that try to
update their history records.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-20 15:00:38 -07:00
Tonis Tiigi
20b3cea734 containerimage: keep layer labels for exported images
When moving blobs to history namespace also move the blobs
the labels point to, but don't move actual image layers.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-06-28 23:38:16 -07:00
Alex Couture-Beil
1c551a45b0 llbsolver: set temporary lease in Commit context
The temporary lease must be passed via the context for the call to
w.Commit() to prevent the cleanup of metadata resources before they are
fully referenced.

This fixes https://github.com/moby/buildkit/issues/3921

Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
2023-06-06 18:52:21 -07:00
Tonis Tiigi
f044e0a946 llbsolver: move history blobs to a separate namespace
Migrate history objects to separate namespace to holding
reference to a blob does not interfer with the GC labels
held for same blobs by the containerd image store.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-11 17:56:12 -07:00
Tõnis Tiigi
44facdde95 Merge pull request #3827 from tonistiigi/history-fixes
fixes for history events
2023-05-10 21:56:57 -07:00
Tonis Tiigi
51039e4b82 llbsolver: send active event only to current client
Previously this caused event for active builds to be
resent to all client who are monitoring when new
client makes a request.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-03 11:04:41 -07:00
Tonis Tiigi
c267c7e894 llbsolver: send delete status event
This was defined in proto but looks like it
was never actually implemented.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-03 11:04:41 -07:00
Tonis Tiigi
546622c313 llbsolver: filter out records marked deleted from list responses
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-03 11:04:35 -07:00
Justin Chadwell
e06c96274f buildkitd: allow durations for gc config
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-04-03 19:10:15 +01:00
Tonis Tiigi
f6d18450cd llbsolver: fix sorting of history records
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-03-22 15:49:26 -07:00
Tonis Tiigi
7f432bff38 history: save completed steps with cache stats
Otherwise the cache steps count values are useless
for canceled and errored builds.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-01-24 18:25:55 -08:00
Tonis Tiigi
853d56e56e add cache stats to the build history API
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-27 23:40:42 -08:00
Tonis Tiigi
179bed6b4c history api: save provenance to history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:41 -08:00
Tonis Tiigi
301ea54fb8 history api: deletion and pinning support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Tonis Tiigi
8a2addb899 history api: tracing storage support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Tonis Tiigi
be6e1cf55e history api: support for logs of completed builds
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -08:00
Tonis Tiigi
dbee61670d add build history APIs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-22 23:59:33 -08:00