1169 Commits

Author SHA1 Message Date
Tõnis Tiigi
28fb74fa00 Merge pull request #6874 from thaJeztah/rm_deprecated_otel_envs
util/tracing: remove fallbacks for OTEL_TRACE_PARENT, OTEL_TRACE_STATE
2026-06-22 23:57:29 -07:00
MohammadHasan Akbari
8086fae369 gitutil: preserve SUDO_UID for git subprocesses
When git runs as root under sudo it consults SUDO_UID to decide whether a
repository's ownership can be trusted, additionally granting access to
repositories owned by the user who invoked sudo. GitCLI builds a
restricted environment for the git subprocess and did not forward
SUDO_UID, so commands such as `sudo docker build` tripped git's "detected
dubious ownership" check and silently lost commit provenance: the build
still succeeds but prints "current commit information was not captured by
the build".

Forward SUDO_UID (only when present) on the host git config path enabled
via WithHostGitConfig, i.e. client-side local git inspection. The default
isolated path used by daemon-side callers is left untouched so it does not
pick up host environment. This matches git's own default behavior under
sudo: it does not disable safe.directory checks and is not equivalent to
safe.directory=*; it merely lets git trust repositories owned by the
invoking user. Only SUDO_UID is forwarded (git's ownership check is
uid-based and never consults SUDO_GID).

Fixes the root cause for docker/buildx#3855. buildx inspects the build
context through this GitCLI with WithHostGitConfig enabled, so buildx
picks the fix up via a moby/buildkit dependency bump with no buildx-side
code change.

Signed-off-by: MohammadHasan Akbari <jarqvi.jarqvi@gmail.com>
2026-06-18 10:28:08 +04:00
Sebastiaan van Stijn
61e69f5da0 util/tracing: remove fallbacks for OTEL_TRACE_PARENT, OTEL_TRACE_STATE
The OTEL_TRACE_PARENT and OTEL_TRACE_STATE environment variables were
deprecated in BuildKit v0.10 (f5dbcf6e99)
because they were deprecated in the OTel specification in favor of the
TRACEPARENT and TRACESTATE env-vars, aligning with the [W3C traceparent]
and [W3C tracestate] headers.

[W3C traceparent]: https://www.w3.org/TR/trace-context/#traceparent-header
[W3C tracestate]: https://www.w3.org/TR/trace-context/#tracestate-header

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-15 11:12:12 +02:00
CrazyMax
bac24d3910 cniprovider: keep loopback DNS dials in caller netns
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-11 11:27:10 -07:00
Tonis Tiigi
4015a3c77c cniprovider: keep proxy dials in CNI netns
Dialing from a CNI namespace with the standard net.Dialer can escape the
namespace through happy-eyeballs connection attempts or resolver goroutines.

Use a serial dialer and route Go resolver sockets through the target
namespace, while preserving host loopback DNS stubs such as systemd-resolved
and Docker embedded DNS.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-11 11:27:09 -07:00
CrazyMax
3719550704 proxyprovider: test HTTP/2 transport clone with custom dialer
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-11 11:39:21 +02:00
Tonis Tiigi
19bcaabb39 proxyprovider: fix exec proxy HTTPS regressions
Commit 91cc422d5 split exec proxying from exec network mode and
started cloning the proxy transport per egress namespace with a custom
DialContext.

Without ForceAttemptHTTP2, the cloned transport could advertise h2 via
ALPN without a registered HTTP/2 RoundTripper, causing Alpine apk update
requests to fail with proxy 502 responses.

Restoring HTTP/2 upstream also exposes unknown-length HTTP/2 responses.
When those responses are rewritten for the MITM HTTP/1.1 client, close
the client-facing connection so clients can delimit the response body.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-10 22:32:37 -07:00
Tonis Tiigi
cd33910d58 network: fix proxy default egress
Use the worker default provider for proxy UNSET egress so host fallback
is preserved when no CNI config is configured.

Extend proxy integration coverage across default, host, bridge, and
default-no-cni worker network modes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-10 08:33:16 -07:00
CrazyMax
ef191af965 vendor: github.com/urfave/cli/v3 v3.9.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 10:12:36 +02:00
Tonis Tiigi
91cc422d5f network: split exec proxy from net mode
Keep exec network modes limited to sandbox, host, and none, and pass proxy
network configuration separately through solve and executor runtime state.

Proxy execs now use bridge-style egress by default, host egress only for host
network mode with entitlement, and no proxy for none mode. Add integration
coverage for bridge, host, and none proxy behavior across OCI and containerd
workers.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-09 09:11:33 -07:00
CrazyMax
a23d9dbc0c Merge pull request #6842 from tonistiigi/progress-test-fix
test: stabilize nested progress assertions
2026-06-09 14:36:22 +02:00
Tonis Tiigi
3584437722 testutil: match exact platform for mirrored images
resolveDefaultPlatform used platforms.Default(), which also matches
sub-platforms (e.g. 386 for amd64, arm for arm64). When an index lists a
compatible variant before the host platform, the wrong single-arch
manifest could be copied to the local mirror.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 21:15:40 -07:00
Tonis Tiigi
1579c97dac test: stabilize nested progress assertions
Progress reads collapse unread updates by ID, so the raw item count can vary
with scheduling. Assert the final status for each nested writer instead.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 17:01:10 -07:00
Tõnis Tiigi
c6626669bc Merge pull request #6740 from tonistiigi/exec-net-proxy
solver: add proxy network mode
2026-06-08 10:09:34 -07:00
Tõnis Tiigi
74c7cb701f Merge pull request #6834 from thaJeztah/update_protos
remove deprecated github.com/golang/protobuf dependency
2026-06-05 16:05:11 -07:00
Sebastiaan van Stijn
94dcaca630 update protoc to v3.14.0
Updating to the lowest release that includes [protobuf@dfab275], which
removed use of the github.com/golang/protobuf/ptypes/timestamp.Timestamp
type alias (deprecated).

[protobuf@dfab275]: dfab275eca

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-05 18:01:59 +02:00
Sebastiaan van Stijn
b79c112e22 util/grpcerrors: remove import of deprecated github.com/golang/protobuf
The github.com/golang/protobuf/ptypes/any.Any type is an alias for
google.golang.org/protobuf/types/known/anypb.Any, so we can remove those
direct imports of the deprecated github.com/golang/protobuf module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-05 18:01:26 +02:00
CrazyMax
bd53b4191f bound telemetry shutdown when trace forwarding stalls
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-05 16:48:22 +02:00
Jonathan A. Sternberg
d4ac72d232 control: forward traces in a non-blocking goroutine
Traces are now forwarded in a non-blocking goroutine when sent through
the traces exporter. This prevents traces forwarded from the client from
being stalled while waiting for an upstream uploader to appear.

In addition, adds a shutdown context to `appcontext` that will only
cancel when an interrupt has been received twice. One interrupt will
signal the program should clean up and shut down, the second indicates
we should skip shutdown procedures (more forceful), and the third will
indicate that we should immediately terminate the program.

This gives a bit more of a degree of control to shutdown procedures like
the traces and metrics exporter so there's a difference between forcibly
calling exit and just waiting a long time for the shutdown to happen.

Includes a more aggressive shutdown timeout for `buildctl` that is
similar to the export timeout on `docker-buildx` for the tracing
shutdown as another preventative measure to ensure the CLI hangs up at
an appropriate time interval.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-06-05 15:55:22 +02:00
Tonis Tiigi
8cd053320c proxyprovider: bound proxy cert cache
Refresh generated proxy leaf certificates before they expire and cap cached
hosts to avoid daemon-lifetime growth. Clean stale proxy network namespaces
on provider startup to mirror CNI cleanup after daemon crashes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 13:33:36 -07:00
Tonis Tiigi
6f08a4ab4a test: cover proxy network source conversion
Add integration coverage for exec proxy source policy conversion. The test
requests /foo, rewrites it to /bar, and verifies exported content and
provenance materials use the converted source.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
217b4f7ebc proxyprovider: fix redirects capturing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
f30c4c57c1 proxyprovider: better url formatting
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
5e84b4f773 proxyprovider: avoid untracted requests because transfer encoding
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:03 -07:00
Tonis Tiigi
564e42d9b4 proxyprovider: log response status code
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
afc8765864 proxyprovider: fix early context cancel
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
d6973c12f6 solver: log proxy network requests
Record each proxied exec request and print a redacted method and URL list in
the exec progress logs after the process completes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
4f41b04f78 solver: reuse source policy for proxy network
Route proxy network policy checks through the existing source policy evaluator so
session metadata, deny messages, and URL converts use the same path as LLB
sources. Keep proxy-specific request rewriting in the proxy provider.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
2bdf6abf99 network: capture proxy exec materials
Record successful GET responses through the exec proxy as provenance
materials and report incomplete material coverage as a typed solve error.
Thread proxy policy and capture state through typed executor/network options.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:02 -07:00
Tonis Tiigi
3254832159 solver: add proxy network mode
Add a build request option that rewrites default exec networking to an
internal proxy network while preserving explicit none networking.

Route HTTP and HTTPS traffic through a BuildKit-owned proxy namespace, enforce
source policy checks for proxied requests, and inject a temporary CA into Linux
rootfs trust bundles for HTTPS interception.

Share namespace pooling between CNI and proxy providers, and cover proxy mode
with unit and integration tests.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-04 11:23:00 -07:00
Tõnis Tiigi
2ff20da8b4 Merge pull request #6824 from tonistiigi/oci-mediatypes
exporter/containerimage: default to oci-mediatypes=true
2026-06-04 08:45:50 -07:00
Tonis Tiigi
aa246dce50 test: log integration helper timing
Add process runtime and socket wait diagnostics to integration test helpers
so future daemon startup flakes include useful timing data.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-03 12:04:14 -07:00
Tonis Tiigi
c4ce866e0f exporter: fix OCI media type test coverage
Allow annotation and attestation exports with OCI media types enabled, fix
the zstd media type map, and update integration tests for the new default.
Keep Docker media types explicit where legacy behavior is under test.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-03 08:52:31 -07:00
Tõnis Tiigi
174f4f07dd Merge pull request #6760 from crazy-max/session-empty-fallback
resolver: allow anonymous auth while preserving local image fallback
2026-06-03 08:40:56 -07:00
Bjorn Neergaard
c9f1690554 all: use well-known zstd mediaType constants
When support for zstd was introduced, these mediaTypes were not yet
available in released versions of their respective Go packages. That is
no longer the case.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2026-06-02 23:11:12 -07:00
Tonis Tiigi
28315c3500 test: avoid shared containerd worker env
Clone the containerd worker environment before sandbox setup so
parallel integration tests do not race while appending debug env.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-01 14:15:14 -07:00
CrazyMax
ca9bcf049c containerimage: preserve local fallback for default image resolution
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-29 17:17:04 +02:00
CrazyMax
eb866c3d23 session: use anonymous registry auth when sessions are unset
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-29 15:53:36 +02:00
Tõnis Tiigi
f5ec43c9e9 Merge pull request #6569 from jirimoravcik/feat/add-cpu-memory-limits
solver: add per-step CPU and memory resource limits
2026-05-27 10:29:57 -07:00
Jiří Moravčík
f85c740c2b solver: add per-step CPU and memory resource limits
Add support for setting cgroup resource limits (memory, memory-swap,
cpu-shares, cpu-period, cpu-quota, cpuset-cpus, cpuset-mems) on
individual build steps.

Signed-off-by: Jiří Moravčík <jiri.moravcik@gmail.com>
2026-05-27 11:34:13 +02:00
Tõnis Tiigi
811d5a0cdb Merge pull request #6776 from jsternberg/configurable-registry-concurrency-simple
util/resolver/limited: make registry concurrency configurable by the configuration file
2026-05-21 12:02:17 -07:00
Jonathan A. Sternberg
ac1f99224c util/resolver/limited: make registry concurrency configurable by the configuration file
Adds a new field to the system configuration that sets the maximum
concurrency for registry connections.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-05-21 13:08:27 -05:00
Tonis Tiigi
98e1113c6d lint: modernize Go lint findings
Update non-generated code for the newer lint recommendations by using typed
atomic values, strings.Cut, and slices.Backward where applicable.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-05-14 10:13:21 -07:00
Tonis Tiigi
bd3608ddc9 lint: update golangci-lint to v2.12.2
Update golangci-lint and adjust code for new gosec diagnostics. Use
root-scoped filesystem operations where appropriate, preserve explicit
user path behavior for SSH keys, and avoid background contexts in
request-scoped cleanup paths.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-05-14 10:13:15 -07:00
CrazyMax
44ffb56160 skip pin race test on workers without merge diff support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-13 11:11:46 +02:00
CrazyMax
ef997d63d3 Revert "session: use anonymous registry auth when sessions are unset"
This reverts commit 29ced684d2.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-07 17:42:49 +02:00
Tõnis Tiigi
5dc04eb6b1 Merge pull request #6741 from jsternberg/forwarding-ping-no-job-id
gateway: reduce potential lock contention in gateway forwarder
2026-05-06 13:16:26 -07:00
Jonathan A. Sternberg
4b9488be47 gateway: reduce potential lock contention in gateway forwarder
There's a large potential for a lock contention issue in the gateway
forwarder's logic. The previous iteration of this would keep a global
mapping of the build ids and, when a forwarder for a build id didn't
exist, the forwarder would wait 3 seconds for the build to register.

The issue with lock contention comes after this. Instead of having a
notification channel that a specific build was ready, the forwarder
would wake up all goroutines that were waiting each time a build was
registered. Since each of those builds took a read lock to check whether
its build was present and registering subsequent builds took a write
lock, it was very easy to end up in a lock contention scenario when
starting many builds at the same time. Then it was easy to hit the 3
second timeout especially when the machine itself was under load.

This changes the notification mechanism so the notify happens per build.
Looking up a build id creates a forwarder registrar with a channel that
can be polled for when the registration is complete. A forwarder will
then only be notified and woken when that specific build id is ready by
the go runtime rather than from the sync condition.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-05-06 14:21:50 -05:00
CrazyMax
29ced684d2 session: use anonymous registry auth when sessions are unset
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-05-06 14:11:47 +02:00
Tõnis Tiigi
c1b5264bfd Merge pull request #6681 from tonistiigi/compat-version
solver: add compatibility-version support
2026-04-27 14:21:38 +02:00