Commit Graph

147 Commits

Author SHA1 Message Date
Tonis Tiigi
7fc428cdfc solver: release unreferenced cache keys after gc
Previously this routine only ran after user ran
prune command or on reboot of the daemon.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-20 22:49:54 -08:00
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
Tonis Tiigi
d45a506aac cache: rename new prune/gc control fields
Naming that was chosen during review was
reservedSpace, maxUsedSpace and minFreeSpace.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-04 17:23:04 -07:00
Laurent Goderre
2782f14746 Added way to configure SBOM scanner
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2024-09-30 16:11:32 -04: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
Justin Chadwell
6382cf9e80 config: allow configuring free gc policies
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-09-25 10:48:59 +01:00
Alberto Garcia Hierro
892e756394 debug: add trace flight recorder
Use golang.org/x/exp/trace to implement an trace recorder that saves the trace
to a circular buffer and can be retrieved at any time.

Debug endpoints have been added under /debug/flight to start and stop the trace
as well as to set its period.

Due to golang.org/x/exp/trace, the minimum go version has been bumped to 1.22

Signed-off-by: Alberto Garcia Hierro <damaso.hierro@docker.com>
2024-09-23 21:01:19 +01: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
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
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
5d7d85f5a0 pb: add extra validation to protobuf types
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 838635998dcae34bbde59e3eab129ab85bd37bef)
2024-01-31 12:37:27 -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
Justin Chadwell
cfd320c5b7 control: fix typo in exporter slice comment
Signed-off-by: Justin Chadwell <me@jedevc.com>
2024-01-05 16:09:38 +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
6cd8c2a427 exporter: add new id parameter to exporter instances
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
Sebastiaan van Stijn
2d3722e50a migrate to github.com/distribution/reference v0.5.0
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf

Also updating docker/docker, which also switched to this new module;

vendor: github.com/docker/docker 032797ea4bcb (v25.0.0-dev)

full diff: afd4805278...032797ea4b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-05 15:29:27 +02:00
Chris Goller
4d4fc4dbd9 fix(boltdb): close cache and history dbs on exit
Signed-off-by: Chris Goller <goller@gmail.com>
2023-08-30 17:47:24 -05:00
Justin Chadwell
a609d2ea2f sbom: propogate image-resolve-mode for generator image
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-06-28 11:23:02 +01:00
Paweł Gronowski
cecab8d64b exporter/image/exptypes: Make strongly typed
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 09:38:25 +02:00
Paweł Gronowski
4fc2d7b5e7 containerimage: Export option keys
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-05-30 12:57:37 +02: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
Tonis Tiigi
6cc7b2aad9 control: fix possible deadlock on network error
When error appears on sending to network, channel
still needs to be read empty to ensure that the other
side does not get blocked on sending to the channel.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-05-10 18:05:43 -07:00
Erik Sipsma
2b30693409 Provide CacheManager to Controller instead of CacheKeyManager.
This makes it possible for callers to customize the full CacheManager
used by buildkitd without having to rewrite/fork the whole control
package.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-03-27 16:02:45 -07:00
joey
c0a839c256 chore: translateLegacySolveRequest does not need to return error checking.
Signed-off-by: joey <zchengjoey@gmail.com>
2023-03-15 10:13:16 +08:00
Tõnis Tiigi
664c119b7f Merge pull request #3581 from sipsma/skip-nil-cache-exporter
Skip configuring cache exporter if it is nil.
2023-02-21 12:21:17 -08:00
Tõnis Tiigi
0ad8d61575 Merge pull request #3109 from ktock/reuseremotelayers
Fix cache cannot reuse lazy layers
2023-02-14 16:51:41 -08:00
Erik Sipsma
bcdad5d1d9 Skip configuring cache exporter if it is nil.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2023-02-03 17:08:35 -08:00
Tonis Tiigi
216ee421a7 control: send current timestamp header with event streams
Status and ListenHistory API return events with one-sided timestamp
for events that have not been completed yet. Because client and
server may not have exactly the same time the client can't really
be sure what these values mean without knowing the current server
time as well.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-01-25 00:47:35 -08:00
Tonis Tiigi
a4f67efd7d history: fix exporter key not being passed
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-01-24 18:25:55 -08:00
Kohei Tokunaga
085bd8af7f Fix cache cannot reuse lazy layers
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-01-24 16:23:56 +09:00
JordanGoasdoue
e849b623c9 feat: allow ignoring remote cache-export error if failing
Signed-off-by: JordanGoasdoue <jordan.goasdoue@dailymotion.com>
2022-12-28 15:21:10 +01:00
Justin Chadwell
d3700c0a5a solver: apply no-cache to generated sboms
The fallback scanner should also respect the no-cache value if set.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-15 17:49:22 +00:00
Brian Goff
7526659ab0 Update source pinning to use proposed policy
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2022-12-13 13:01:54 -08:00
Akihiro Suda
0d3f71ee18 llbsolver: support pinning sources
Alternative to PR 2816 ("dockerfile: support Dockerfile.pin for pinning sources")

This version is implemented on the llbsolver side and agnostic to the LLB frontends.
See `solver/llbsolver/vertex.go:loadLLB()`.

See `docs/build-repro.md` for the usage.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-12-13 13:01:54 -08:00
Tonis Tiigi
fe0c8d352a history api: allow internal builds that are not tracked
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-12-12 22:15:40 -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
Justin Chadwell
063056313f Revert "exporter: detect if multi-platform is set"
This reverts commit 6f21d6b403.

We don't need the exporter opts for multiplatform, they were a hack to
attempt to preserve the semantics of converting between Ref->Refs
freely (both buildkit-side and frontend-side).

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-12 14:55:00 +00:00
Justin Chadwell
3b74e94b7d solver: remove force refs
We no longer need to (or should) force refs conversion.

A single Ref is distinctly different from a Refs map with a single
element - they express the user-specified difference between whether
multi-platform exports should be used or not. It's important to preserve
this sematic, especially on the side of the frontend, where it can't be
recovered if lost.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-12 14:22:00 +00:00
Justin Chadwell
6f21d6b403 exporter: detect if multi-platform is set
This is required now that the correspondence between platforms and refs
has been broken. Without it, there's no way to detect between the
following cases from the output that they emit:

	buildctl build --opt platform=linux/amd64 --opt attest:sbom
	buildctl build --opt platform=linux/amd64 --opt attest:sbom --opt build-arg:BUILDKIT_MULTI_PLATFORM=true

We'd like the former to produce a flat file structure through the local
exporter, and the latter to produce an explicitly nested file structure
through the same exporter. However, both of these produce Refs instead
of a singular Ref, so we can't just look at the Result to know which
one.

Similar to how we handle the SOURCE_DATE_EPOCH build-arg, we can handle
the multi-platform args at the control API boundary, setting the
explicit option multi-platform in the exporter if it is set. In the
future, we can guide users away from the BUILDKIT_MULTI_PLATFORM args
entirely, and towards the multi-platform exporter option if we want.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-08 14:15:10 +00:00
Justin Chadwell
50c2083304 epoch: refactor frontend attribute parsing
Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-12-08 14:14:51 +00:00
Tonis Tiigi
dbee61670d add build history APIs
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-22 23:59:33 -08:00
Tõnis Tiigi
ae9d0f57c7 Merge pull request #3271 from jedevc/duplicate-exporter
Don't allow duplicate cache exporters
2022-11-21 15:49:33 -08:00
Justin Chadwell
621ab1c0af cache: error on duplicate sets of cache options
Previously, we attempted to gracefully resolve duplicate cache export
options, however, we should explicitly error - a client has made an
error if the same options appear twice. If we really want
de-duplication, then clients such as buildx should implement it there.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2022-11-16 12:01:35 +00:00
Tonis Tiigi
9acc6d30eb refactor buildinfo into provenance capture
Change how provenance information is captured from builds.

While previously frontend passed the buildinfo
sources with metadata, now all information is captured
through buildkit. A frontend does not need to implement
buildinfo and can't set incorrect/incomplete buildinfo
for a build result.

All LLB operations can now collect as much provenance
info as they like that will be used when making the
attestation. Previously this was limited to a single Pin
value. For example now we also detect secrets and SSH IDs
that the build uses, or if it accesses network, if local
sources are used etc.. The new design makes sure this
can be easily extended in the future.

Provenance capture can now detect builds that do
multiple separate subsolves in sequence. For example,
first subsolve gathers the sources for the build and
second one builds from immutable sources without a
network connection. If first solve does not participate
in final build result it does not end up in provenance.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:03 -08:00
Tonis Tiigi
5d5a6b93e0 Add slsa provenance attestation unless disabled
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2022-11-15 19:37:02 -08:00