2029 Commits
Author SHA1 Message Date
Tonis Tiigi 11bc14ad70 solver: release results of builds outliving Discard
A build still running when its job was discarded stored its results
in states that were already released, leaking them. Keep the states
until the last running build returns, and reject new builds on a
discarded job. Release refs of a gateway solve that returns after the
forwarder was discarded.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-11-04 11:27:58 -08:00
Tõnis Tiigi 30785d7cd4 Merge pull request #7344 from tonistiigi/dockerfile-reset
dockerfile: add `--unset`, `FROM --reset` and `BUILDKIT_DISABLE_ONBUILD`
2026-11-04 09:49:10 -08:00
Tõnis Tiigi 7c3b6ba69e Merge pull request #7348 from tonistiigi/fix-ref-release
gateway: fix double release of failed exec refs
2026-11-03 22:59:47 -08:00
Tõnis Tiigi 5fb98cee48 Merge pull request #7300 from Zaczero/fix-exec-stream-failure
grpcclient: unblock processes when exec stream ends
2026-11-03 22:37:15 -08:00
Tonis Tiigi dd289a29ee gateway: create pipe only for served forwarders
newBridgeForwarder created an os.Pipe pair for every forwarder, but
only serveLLBBridgeForwarder uses it. Forwarders created through
NewBridgeForwarder for client-side frontends never used or closed
the pipe, leaving four fds open until GC cleanup.

Create the pipe in serveLLBBridgeForwarder instead.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-11-02 22:28:12 -08:00
Tonis Tiigi 3b5730e257 gateway: close frontend stdio after exec returns
Cancellation closed the frontend's stdin and stdout pipe ends from
serve() while the executor could still be starting the frontend.
The runc executor passes stdout to exec.Cmd as an *os.File, so a
concurrent close can free the fd number after StartProcess reads it
and before the child dups it, letting an unrelated file take its
place in the child. The stdout case predates the previous commit.

Make conn.Close() close only the gateway-side pipe ends, and close
the frontend ends in Solve once exec.Run has returned.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-11-02 22:28:12 -08:00
Tonis Tiigi 85697ddb8e gateway: fix double release of failed exec refs
Repeated gateway solves of a failed exec with several mounts sharing
a base lost the exit error and returned "releasing already released
reference". Since 2b9717c88 the gateways registered and released the
result wrappers of an exec error. Those wrappers are distinct clones
that share a worker ref ID, and the result proxy released them too, so
the second release failed.

Make ExecError the owner of the original handles. The first Release
wins Borrow, and result proxies and gateways retain the *ExecError
instead of its refs. Each gateway keeps one independent clone per
worker ref ID and releases the retained errors and clones on discard.
If the proxy or gateway is already released or discarded, the error is
released immediately. ExecError.Release now returns the release error
instead of dropping it.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-11-02 11:36:57 -08:00
Tonis Tiigi 4e903ae61d dockerfile: add BUILDKIT_DISABLE_ONBUILD build arg
Setting BUILDKIT_DISABLE_ONBUILD skips the ONBUILD triggers of all
base images and stages. It can be passed as a build argument or set
as a global ARG in the Dockerfile.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-29 20:43:02 -07:00
Tonis Tiigi c141818ba8 dockerfile: add FROM --reset
Allow resetting configuration inherited from the base image with
FROM --reset=<field>[,<field>...]. Fields are named after the
instructions that set them: cmd, entrypoint, env, expose,
healthcheck, label, onbuild, shell, stopsignal, user, volume and
workdir. "all" resets all of them. Resetting onbuild skips the
ONBUILD triggers of the base image.

Available in the labs channel (dfreset build tag).

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-29 20:43:02 -07:00
Tonis Tiigi cf916e5089 dockerfile: add --unset to ENV, LABEL and VOLUME
Allow removing environment variables, labels and volumes,
including ones inherited from the base image. ENV --unset also
removes a build argument with the same name from the stage.

Available in the labs channel (dfunset build tag).

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-29 20:43:02 -07:00
Tonis Tiigi b7ac874aff dockerfile: parse flags for ARG and STOPSIGNAL
ARG and STOPSIGNAL never called flags.Parse(), so unknown flags
were silently ignored. For example `ARG --unset FOO` declared FOO
instead of failing.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-29 20:43:02 -07:00
Tonis Tiigi 44e8bc7a68 gateway: wait for frontend before HTTP/2 handshake
Wait for initial frontend data before starting ServeConn so
container startup does not consume the HTTP/2 preface timeout.
Close pipe descriptors on cancellation to unblock the wait.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-28 18:24:32 -07:00
Tonis Tiigi b11ba3d44e llbsolver: serialize provenance predicate access
When a build has several exporters, runExporters runs them in parallel
and each one calls the same provenance attestation ContentFunc. Every
call finalized the shared ProvenanceCreator predicate (FinishedOn,
Layers, SysUsage, CompatibilityVersion) while another exporter could be
JSON-encoding it, which the race detector reports as a data race.

Add PredicateJSON, which finalizes and encodes the predicate under a
per-creator mutex and returns the encoded bytes, so no caller keeps a
reference to the shared predicate. Make Predicate unexported so all
callers go through the locked path.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-27 22:56:01 -07:00
Tõnis Tiigi 6d392427ee Merge pull request #7318 from infosiftr/expose-history
Fix `EXPOSE` history to be valid syntax
2026-10-27 22:02:10 -07:00
Tonis Tiigi 5225f50f0b dockerfile: wait for ssh-agent before reading its output
testSSHFileDescriptorsClosed read ssh-agent's stderr buffer while the
agent was still running and os/exec's copy goroutine was writing to
it, which races when the test binary is built with -race. Kill the
agent and Wait for it before reading; Wait guarantees the copy has
finished and the full output is available.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-25 20:08:26 -07:00
Tonis Tiigi 80c4a21c4f dockerfile: set resolve cache CacheError at construction
withResolveCache set g.CacheError on every ResolveImageConfig call.
Base images of different stages are resolved in parallel, so these
writes raced with each other and with CachedGroup.Do reading the field,
which is documented as not safe to change after the first Do call.
Set it once when the wrapper is created.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-24 22:57:15 -07:00
CrazyMax 14f59cadb7 grpcclient: preserve process errors during stdin cleanup
Keep sending stdin EOF during cleanup so the gateway can finish its Done
handshake, but ignore send failures when the input copy was interrupted by
closing the pipe. Preserve send errors when the input reaches EOF naturally.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-23 15:42:26 +02:00
Tianon Gravi 27881bd634 Fix EXPOSE history to be valid syntax
Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2026-10-23 05:44:53 -07:00
Tõnis Tiigi 1d3897ae8c Merge pull request #6588 from crazy-max/git-debug-command-tracing
git: add opt-in command tracing
2026-10-22 09:17:10 -07:00
CrazyMax c08835d1ad git: add opt-in command tracing
Print executed Git commands in build logs to help diagnose source
resolution, fetch, and checkout behavior, including bundle staging.
Enable tracing with BUILDKIT_GIT_DEBUG_COMMANDS=1 or llb.GitDebugCommands().

Redact URL credentials and HTTP extra headers without changing command
execution or snapshot cache keys. Tracing is disabled by default.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-22 11:11:56 +02:00
Tõnis Tiigi ce2b38c3a2 Merge pull request #7286 from hezhizhen/codex/dockerfile-check-psw
dockerfile: check PSW variables for secrets
2026-10-21 10:37:11 -07:00
Zhizhen He 3865c3eb5d Dockerfile: Reuse existing secret lint test
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2026-10-21 21:54:19 +08:00
Kamil Monicz 3c23c1a85a grpcclient: unblock processes when exec stream ends
Process receivers only observe their caller context and deregistration,
so Start and Wait can hang after the shared ExecProcess receiver exits.
Transport errors cancel the forwarder context without notifying them;
EOF and cancellation leave even that context live.

Cancel the forwarder on every receive error and let process receivers
return its cause. Preserve normal deregistration and Release semantics,
and use the existing output-handler cleanup to unblock pending stdin.

Exercise EOF and three gRPC status errors over a real stream with two
processes starting or waiting, plus successful completion before stream
termination. Check that Release still reports only failures other than
EOF and cancellation.

Signed-off-by: Kamil Monicz <kamil@monicz.dev>
2026-10-20 02:24:31 +02:00
Tamir Duberstein c3fdbd4bf5 Omit definitions from returned references
Returning a gateway frontend result serialized the solved references'
LLB definitions again. The Return handler already resolves those
references by ID [1], so a large definition plus result metadata could
exceed the gRPC message limit after Solve succeeded.

Omit definitions from references serialized in Return. Keep them in
Solve responses and client references so Reference.ToState can still
reconstruct their LLB state.

Prepared by Codex on Tamir's behalf.

[1]: https://github.com/moby/buildkit/blob/64aefaef4d7dbb993156a0839958e4342aeb4c51/frontend/gateway/gateway.go#L1102-L1168

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
2026-10-19 18:03:22 -04:00
Zhizhen He 04c80e3e79 Dockerfile: Test DIPSWITCH token boundaries
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2026-10-16 22:41:22 +08:00
Zhizhen He e24c71e358 Dockerfile: Check PSW variables for secrets
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2026-10-16 22:41:18 +08:00
CrazyMax 43d4cae9ee update alpine linux to 3.24
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-13 12:27:12 +02:00
Tonis Tiigi d4f5924b25 lint: support Go 1.27 validation
Build golangci-lint with Staticcheck v0.8.0-rc.1 to handle the Go 1.27
AST. Disable SA4023 because unsupported platform stubs cause false
positives during multiplatform linting.

Apply Go 1.27 formatting and replace the deprecated plain HTTP resolver
option.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-12 17:07:16 +02:00
Sebastiaan van Stijn c3292e1abe update to go1.27
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-10-12 17:06:54 +02:00
CrazyMax 3090a253a1 dockerfile: update xx to 1.10.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-10-12 13:26:42 +02:00
Tonis Tiigi a6603467f2 dockerfile: update embedded version to 1.29
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-06 17:24:39 -07:00
Tõnis Tiigi c445f55059 Merge pull request #7247 from tonistiigi/exec-release-fix
solver: fix failed exec ref ownership
2026-10-06 10:16:13 -07:00
CrazyMax 9734cd037b Merge pull request #7246 from ruzansasuri/docs-cache-mount-export
docs: clarify that cache mounts are not included in exported build cache
2026-10-06 11:34:53 +02:00
Tonis Tiigi d8e22c19ae solver: fix failed exec ref ownership
ExecOp returned failed outputs together with ExecError. When the exec was
canceled, sharedOp dropped those outputs without releasing them, leaving
their cache records in use.

Make Op.Exec return nil outputs on error and move failed ExecOp outputs into
ExecError. sharedOp now retains clones of a cached error's refs until the
vertex is released, so builds sharing a failed vertex can still use its
snapshots after another build is discarded.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-10-05 17:49:26 -07:00
Ruzan Sasuri f74a37c4c9 docs: clarify that cache mounts are not included in exported build cache
Signed-off-by: Ruzan Sasuri <24909376+ruzansasuri@users.noreply.github.com>
2026-10-05 13:21:41 -07:00
Tõnis Tiigi 106f55ce1f Merge pull request #7243 from Zaczero/grpcclient-exec-output-cleanup
grpcclient: release process cleanup on output errors
2026-10-02 17:16:41 -07:00
Kamil Monicz 1a34037bde grpcclient: release process cleanup on output errors
A failed stdout or stderr write returns from output handling without
closing done. The stdin cleanup goroutine remains blocked on that
channel, so process Wait cannot finish or return the write error even
after cancellation.

Close done on every return from output handling. Keep the early close on
Exit so stdin can shut down before the server sends Done.

Cover closed stdout and stderr readers with and without stdin, and a
gateway container whose output consumer closes while stdin stays open.

Signed-off-by: Kamil Monicz <kamil@monicz.dev>
2026-10-02 17:49:00 +02:00
Kamil Monicz e815ed875e grpcclient: fix exec stream flow-control deadlock
messageForwarder.Send holds the process registry mutex while sending on
the gRPC stream. A flow-controlled send can block the receive loop on
that mutex, preventing it from draining process output. Once the output
pipe fills, an echoing process stops reading stdin and the server stops
draining the client's sends.

Give stream sends their own mutex so receiving output can make progress
without allowing concurrent gRPC sends. This follows the server-side
execProcessServerThreadSafe pattern.

Add a blocked-send regression and an OCI integration case that transfers
16 MiB through cat. With the original locking, the integration case times
out with the sender waiting for write quota and the receiver waiting for
the registry mutex.

Signed-off-by: Kamil Monicz <kamil@monicz.dev>
2026-10-02 17:49:00 +02:00
Tõnis Tiigi 67aca4271c Merge pull request #7234 from crazy-max/fix-dockerfile-patch-release-version
dockerfile: fix patch release version validation
2026-09-30 14:55:02 -07:00
Tõnis Tiigi 6ba95e917f Merge pull request #7228 from tonistiigi/v0.33-deps-update
Dependency updates for v0.34
2026-09-30 11:39:47 -07:00
Tõnis Tiigi df0d1fc0be Merge pull request #7231 from crazy-max/forward-v0.33.1-patches
forward v0.33.1 patches
2026-09-30 11:38:20 -07:00
CrazyMax ebd5a78f77 dockerfile: fix patch release version validation
Match two-component builtin versions against the release minor series.

Exclude labs tags from mainline git describe when both tags share a commit.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-09-30 17:42:14 +02:00
CrazyMax 02fd014bbc forwarder: reconcile gateway test after rebase
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
(cherry picked from commit e488457672160996fbae5c2d9f7e0958607f7aa7)
2026-09-30 15:19:26 +02:00
Tonis Tiigi c44f11e138 security: limit daemon file reads
Bound gateway reference and container reads before allocation. Apply the same
limit when loading nested LLB definitions.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 03cfacc0c397eb8e5fe46df962df51131f667cb6)
2026-09-30 15:12:29 +02:00
Tonis Tiigi 2ed913ca29 dockerfile: limit epoch archive reads
Apply the frontend file-size limit when scanning HTTP archives for
SOURCE_DATE_EPOCH timestamps.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit f7eeece391b15b63a31074fdffc3b538fafc47b7)
2026-09-30 15:12:29 +02:00
Tonis Tiigi 4b8e349913 gateway: serialize container lifecycle
Close process admission before release waits, preventing concurrent starts from
racing errgroup bookkeeping and container cleanup.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit bc934589afa09090bc685644a6e0156d5617670a)
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 01e2aff8aa3ae0351dea17c0e42c8289659ef40f)
2026-09-30 15:12:27 +02:00
Tonis Tiigi ff89e08604 gateway: validate malformed requests
Reject missing results, process metadata, root mounts, and SSH mount options
before gateway requests reach execution paths.

Return InvalidArgument for malformed RPCs instead of allowing daemon panics.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 3e632afa27fcb10463c756495b2fdd267d8f9a86)
2026-09-30 15:12:27 +02:00
Tonis Tiigi 0d557a9949 dockerfile: limit frontend file reads
Bound Dockerfile and ignore-file reads to the gateway message size.
Reject oversized files before parsing to avoid unbounded daemon memory use.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 2508d93d8a2ac621955f0355258f9a4ec79b02b7)
(cherry picked from commit 69d8a4527d8435c50c1bcce92d7e8f0e7851706c)
2026-09-30 15:12:26 +02:00
Tonis Tiigi edc2718b4b gateway: resolve container reads inside the mount
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 64137a91962a5fdbe1d6c49d9915ad2501190600)
(cherry picked from commit 929ad12778e82215bffbdb593dccdf124912ac2b)
2026-09-30 15:12:24 +02:00
Tonis Tiigi cead37e6e9 gateway: synchronize forwarder state
Guard worker references and teardown state consistently across gateway
forwarders. This prevents concurrent solve and container requests from
triggering unsafe map access.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 504b528bf29c7108715400b856788753b6eb3f25)
(cherry picked from commit f3cde0c2610d59c8d9575ba5a46bf0ebb5ee7f86)
2026-09-30 15:12:23 +02:00