276 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
50b548a135 vendor: migrate to github.com/gohugoio/hashstructure
The github.com/mitchellh/hashstructure/v2 module was archived, and
there's a maintained fork in the gohugoio org.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-17 10:02:52 +02:00
CrazyMax
d13b3ac2ce Revert "executor: fix containerd stdin close race"
This reverts commit cb6df1c266.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-06-10 18:25:51 +02:00
CrazyMax
7a2c61eefd Merge pull request #6810 from tonistiigi/containerd-exec-test-fix
test: stabilize worker exec pid1 lifetime
2026-06-10 11:18:19 +02:00
Tonis Tiigi
cb6df1c266 executor: fix containerd stdin close race
Delay containerd stdin CloseIO until BuildKit's stdin reader reaches EOF.
This avoids racing the shim FIFO copy path, where closing stdin before
the copy completes can leave execs stuck or missing stdin data.

Add a client gateway regression that runs concurrent execs writing stdin
into files and verifies every payload is present.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-09 17:28:39 -07: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
63e37e87d1 Merge pull request #6815 from tonistiigi/stdin-fix
executor: avoid runc stdin shutdown hangs
2026-06-09 10:36:53 +02:00
Tonis Tiigi
953437b102 executor: avoid runc stdin shutdown hangs
Forward non-tty stdin through an os.Pipe so runc receives an *os.File
instead of the caller's reader. This lets runc exit after the container
process is killed without waiting on Go's internal stdin copy.

Add gateway coverage for graceful pid1 exit, release-based cleanup, and
explicit SIGKILL while pid1 stdin is still open.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-06-08 18:10:52 -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
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
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
Jonathan A. Sternberg
87627f0115 runcexecutor: change how the runc executor kills runc processes
Change how the runc executor kills runc processes by removing the
previous warning message that occurred every 50 milliseconds with a bit
more precision in how it sends the warning.

The previous version could potentially successfully kill the runc
process and then the runc process could take some time to exit. It would
spam the logs every 50 milliseconds until the process exited and would
attempt to rekill a container that was already marked as killed.

This change makes it so we detect a successful kill. If we detect a
successful kill, we then wait for the process while writing a warning to
the log that the process is taking a long time to end. We print one
message 50 milliseconds after the kill and then an additional one with
the exact time it took to exit after the exit succeeds.

If the kill is not successful, we stay in the same loop as previously
existed.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-05-19 14:19:04 -05:00
Tõnis Tiigi
550cf8b8b7 Merge pull request #6774 from tonistiigi/0513-dev-tools-updates
dev tools updates
2026-05-14 17:37:14 -07: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
Maya Chen
3786f4e24d chore: fix duplicated words in llb, executor and dockerfile_test comments
Signed-off-by: Maya Chen <275405107+otjdiepluong@users.noreply.github.com>
2026-05-14 06:42:49 +00:00
Jonathan A. Sternberg
265c6e08ff otel: refactor tracing helpers for child processes
Merge the `tracing/env` and `tracing/exec` package into a single package
with some common types shared between the two.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2026-04-16 10:28:19 -05:00
Tonis Tiigi
b46ee07a5d executor/oci: scope state files to roots
Use os.OpenRoot for resolv.conf and hosts state file creation, and
adapt executor callers and tests to the root-relative helper API.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-25 08:14:31 -07:00
Tonis Tiigi
6e9d3d4bbc executor: validate container IDs centrally
Add executor.ValidContainerID and enforce it in runc/containerd Run paths.

Only runc executor used the ID in filesystem operations.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 789df2422341960b7549d14ea475add43e73cd74)
2026-03-25 08:14:29 -07:00
Tonis Tiigi
481132ff14 refactor: deduplicate NopWriteCloser into util/iohelper
Replace duplicate nopCloser, nopWriteCloser, and bufferCloser
type definitions across test and production code with the
shared iohelper.NopWriteCloser type.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-09 22:16:14 -07:00
Tonis Tiigi
b61489948c tests: use t.Context in unit tests
Replace context.TODO/background calls in targeted unit tests with
t.Context().

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-02-25 16:41:54 -08:00
Tonis Tiigi
a8b83196f3 ci: update golangci to v2.8.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-01-13 22:09:20 -08:00
Vigilans
30ef2919a9 Rename isolated to hypervIsolation
Signed-off-by: Vigilans <vigilans@foxmail.com>
2025-09-16 23:59:37 +08:00
Vigilans
209509356a Support isolated option in containerd executor in Windows
Signed-off-by: Vigilans <vigilans@foxmail.com>
2025-09-15 17:32:18 +08:00
CrazyMax
d31230ea96 lint: gopls fixes
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-09-09 14:13:04 +02:00
CrazyMax
9b68dbe71d simplify resolvconf path resolution
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-23 09:26:32 +02:00
CrazyMax
05c55e56fd move resolvconf package to util
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-23 09:26:31 +02:00
Sebastiaan van Stijn
db725345ce executor/oci: migrate to moby/profiles/seccomp module
The moby/profiles/seccomp module was extracted from the Moby repository
at commit [e1281f09fceec4aab518267c319a7bd4c79cf3c5][1].

[1]: e1281f09fc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-22 18:14:12 +02:00
Sebastiaan van Stijn
4e1e0fe7f6 executor/oci: use buildkit bklog instead of containerd/log
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:11:16 +02:00
Sebastiaan van Stijn
2614833a2a executor/oci: resolvconf: use buildkit errdefs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:08:40 +02:00
Sebastiaan van Stijn
ce4e767ffe executor/oci: resolvconf: remove unused code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:08:40 +02:00
Sebastiaan van Stijn
b2d103fecf executor/oci: use fork of libnetwork/resolvconf
Rewrite the resolvconf code to use libnetwork's internal packege, which
allows us to skip some of the moby-specific handling (writing to a file,
creating a hash of the file to detect changes made by the user (not
supported by BuildKit, which always mounts read-only).

This rewrite also allows us to skip GetNameservers, GetSearchDomains, GetOptions,
and FilterResolvDNS, which repeatedly would parse the resolvconf file for
each of them.

The new code parses the original resolvconf once, after which mutations
(overrides) are done in memory, after which we generate the resolv.conf to
write to disk.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:08:40 +02:00
Sebastiaan van Stijn
504b10d47b executor/oci: resolvconf: rewrite tests using testify
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:08:39 +02:00
Sebastiaan van Stijn
44a7014d69 executor/oci: add fork of moby resolvconf (does not compile)
Add a fork of github.com/docker/docker/daemon/libnetwork/internal/resolvconf,
taken at commit [254f64ded64027db0d2d1531a8ef9015de68e2f2]. I did not
preserve git history for this one (just a copy), but history can be found
in the Moby repository if needed.

[254f64ded64027db0d2d1531a8ef9015de68e2f2]: 254f64ded6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 15:08:39 +02:00
Tonis Tiigi
9fcedf9807 update gopls to go1.24 compatible version
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-07 18:23:20 -07:00
Tonis Tiigi
69d3d44145 lint: add unconvert
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:44:01 -07:00
Tonis Tiigi
c6a1dcd6b5 lint: correcting errorlint and some err113 cases
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:22 -07:00
Tonis Tiigi
f1f56c2b77 golangci-lint: v2 upgrade
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-02 12:19:17 -07:00
Jonathan A. Sternberg
66016a8c63 vendor: switch from idtools to moby/sys/user
Convert usages of `github.com/docker/docker/pkg/idtools` to
`github.com/moby/sys/user` in order to break the dependency between
buildkit and docker.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-02 10:22:02 -05:00
Tonis Tiigi
b5286f8dcb apply x/tools/modernize fixes
Autogenerated with couple of manual patches.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-07 08:18:45 -08:00
Anthony Nandaa
877d8a771e feat: wcow: add support for bind and cache mounts
Currently, mounts are not supported for WCOW builds,
see #5678. This commit introduces support for
bind and cache mounts. The remaining two require
a little more work and consultation with the platform
teams for enlightment.

WIP Checklist:

- [x] Support for bind mounts
- [x] Support for cache mounts
- [x] add frontend/dockerfile integration tests
- [x] add client integration tests (not all, `llb.AddMount` not
  complete)

Fixes #5603

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2025-02-20 21:19:03 +03:00
CrazyMax
3c072dcffc cdi: support custom and wildcard class for injection
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 16:38:23 +01:00
Tonis Tiigi
f61e01c14c llbsolver: on-demand CDI devices with automatic setup
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-11 11:21:48 +01:00
CrazyMax
6667434ec4 cdi: support optional devices
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:47 +01:00
CrazyMax
d69cc70521 cdi: use worker cdi manager when generating devices oci spec
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:47 +01:00
Tonis Tiigi
3adcf53d1a enable CDI by default for buildkitd
Access should be managed by entitlements checks

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-11 11:21:46 +01:00
CrazyMax
319bf56d8d exec: cdi device support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-02-11 11:21:44 +01:00
Marat Radchenko
5be7edb69c Upgrade to containerd 2
Co-authored-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2025-01-13 16:42:48 -08:00
Marat Radchenko
0a5a80cfec Remove pre-Go 1.17 build tags
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-11-21 10:58:27 +03:00