Commit Graph

491 Commits

Author SHA1 Message Date
Tonis Tiigi
a7d4e8c018 buildkitd: allow unix address for debug address
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-12-04 17:21:08 -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
Tõnis Tiigi
e853c88d3b Merge pull request #5522 from tonistiigi/history-gracefulstop-fix
history: handle gracefulstop when history is active
2024-11-20 11:48:59 -08:00
Tonis Tiigi
e05a89e0b8 improve stacks of cancels from defers
In this case the current stack trace points to the line
where the context was created. Instead the stack should be
captured when the defer is running so the return path to
the defer call is also part of the stack.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-19 18:40:00 -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
Sergio Garcez
29a7e5afb7 fix: set h2 protocol identifier to comply with TLS-ALPN
Signed-off-by: Sergio Garcez <sergio.garcez@docker.com>
2024-10-09 17:04:44 +01:00
Tõnis Tiigi
6860c8097d Merge pull request #5359 from tonistiigi/gc-free-max-support
update default and basic gc control to use free and max storage
2024-10-08 08:28:40 -07: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
Tonis Tiigi
a73e1b09c6 update default and basic gc control to use free and max storage
Update default policy to include maximum and free storage controls.

New default policy is combination of all three controls.

Minimum reserved storage: 10GB / 10% (10% was old default)
Maintain free storage: 20%
Maximum allowed storage: 100GB / 80%

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-04 17:21:50 -07: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
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
Tõnis Tiigi
a146d2a416 Merge pull request #5337 from fiam/alberto/debug-flight-record
debug: add trace flight recorder
2024-09-23 13:44:37 -07: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
Marat Radchenko
64f4631d8b Add stub implementations to make buildkitd build for Darwin
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-09-16 12:18:36 +03:00
Marat Radchenko
c8c5024758 Cleanup Linux-isms in code
appdefaults_unix.go, constants_unix.go:
/run is a thing only for Linux. Other Unixes use /var/run.

diffapply_linux.go and source_linux.go:
These files use Linux-only API.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2024-08-26 11:21:12 +03:00
Sebastiaan van Stijn
b4a189390e migrate to github.com/moby/sys/userns
Commit 4b85f11164 migrated the use of the
userns package to the github.com/moby/sys/user module.

After further discussion with maintainers, it was decided to move the
userns package to a separate module, as it has no direct relation with
"user" operations (other than having "user" in its name).

This patch migrates our code to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 12:36:57 +02: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
Sebastiaan van Stijn
86b550e427 migrate to github.com/moby/sys/user/userns
The userns package in libcontainer was integrated into the moby/sys/user
module at commit [3778ae603c706494fd1e2c2faf83b406e38d687d][1].

The userns package is used in many places, and currently either depends
on runc/libcontainer, or on containerd, both of which have a complex
dependency tree. This patch is part of a series of patches to unify the
implementations, and to migrate toward that implementation to simplify
the dependency tree.

[1]: 3778ae603c

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 14:11:04 +02: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
Justin Chadwell
8f4aa21257 Merge pull request #5143 from Ignas/pass-cache-imports-to-solve
Pass cache imports from solve ptions to solve request
2024-07-16 10:45:20 +01:00
Tonis Tiigi
d7b3e02a55 lint: finish up testifylint
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-12 16:03:18 -07:00
Ignas Mikalajunas
955f289360 Pass cache imports from solve ptions to solve request
Signed-off-by: Ignas Mikalajunas <ignas@devzero.io>
2024-07-10 14:40:43 +00:00
Sebastiaan van Stijn
175973babc switch to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 22:59:12 +02:00
Alano Terblanche
c3925da302 Refactor containerd NewWorkerOpt & containerdexecutor New parameters
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-06-25 10:24:47 +02:00
Tonis Tiigi
6737deb443 vendor: add go-csvvalue for more efficient CSV parsing
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-21 08:05:56 -07:00
Anthony Nandaa
9e41728648 refactor: split runtime options definions by OS
address #5056

Split out the code for `getRuntimeOptionsType` so as
to reduce the unnecessary imports, hence binary size.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2024-06-19 12:26:22 +03:00
Tõnis Tiigi
935713cc88 Merge pull request #5033 from WanzenBug/option-for-cgroup-parent-in-containerd-worker
containerd: add option to set parent cgroup
2024-06-17 17:44:38 -07:00
Moritz "WanzenBug" Wanzenböck
5cb8618032 containerd: add option to set parent cgroup
Using the "runc.v2" runtime, it is possible to configure containerd to start
runc with the "systemd_cgroup" flag. This will cause runc to use systemd to
manage the container cgroups. For this configuration to work, runc needs the
cgroup name to be of a special form: "<systemd.slice>:<parent>:<name>".
This is already implemented in the containerd runtime package, provided that
a parent cgroup of the form "<systemd.slice>:<parent>:" is set.

This commit adds the option to configure such a parent cgroup for the
containerd worker. By default, it will still use an empty string as cgroup
parent, keeping existing behaviour.

Using a configuration like:

  [worker.containerd]
  defaultCgroupParent = "system.slice:buildkit:"
  [worker.containerd.runtime]
    name = "io.containerd.runc.v2"
    [worker.containerd.runtime.options]
      SystemdCgroup = true

a user is able to have their container cgroups managed by systemd. This makes
it possible to set global resource constraints on a per-container basis using
systemd drop-in configuration. When using the example above, the following file
restricts every container spawned by buildkit to use only 1 CPU and 1G of RAM:

  $ cat /etc/systemd/system/buildkit-.scope.d/limits.conf
  [Scope]
  CPUQuota=100%
  MemoryMax=1G

Signed-off-by: Moritz "WanzenBug" Wanzenböck <moritz@wanzenbug.xyz>
2024-06-14 08:46:45 +02:00
Tonis Tiigi
dfc35271ae simplify with maps pkg functions
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 18:33:30 -07:00
Tonis Tiigi
c241bcaad0 remove deprecated seed calls
Not needed since go1.20

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-12 15:21:42 -07:00
Tonis Tiigi
fc936ae3d7 lint: more testifylint fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-10 21:16:51 -07:00
Tõnis Tiigi
29d0620330 Merge pull request #4949 from tonistiigi/platforms-cache-timeout
allow controlling detected platforms cache timeout
2024-05-30 18:21:48 -07:00
Tonis Tiigi
9c29e212f6 allow controlling detected platforms cache timeout
Because detecting emulator changes can be relatively
expensive, avoid doing it very frequently. A new config
parameter allows controlling if users prefer more or
less frequent updates or want to disable detecting
changes completely and only rely on emultor configuration
at boot time.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-30 10:56:40 -07:00
Tonis Tiigi
29b4b1a537 ensure correct grpc max sizes for control API and frontends
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-29 20:55:51 -07:00
Zhizhen He
2f9860e97a tests: remove unnecessary declaration and fix typo
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
2024-05-25 13:18:14 +08:00
Kirill A. Korinsky
323c3a9718 Adjusts syscall.Statfs_t for OpenBSD
Here a small adjustmend for OpenBSD's syscall.Statfs_t which is backport
of 9c2aaca13b/sysutils/docker-buildx/patches/patch-vendor_github_com_moby_buildkit_cmd_buildkitd_config_gcpolicy_unix_go

Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
2024-05-20 10:36:59 +01:00
Tonis Tiigi
265d18f2e6 lint: enable gocritic
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-05-15 16:44:38 -07:00
Tõnis Tiigi
3dea10f7a5 Merge pull request #4882 from profnandaa/document-group-flag
docs: add documetation for --group and SecurityDescriptor config
2024-05-13 14:48:14 -07:00
Tõnis Tiigi
a17cbfda18 Merge pull request #4899 from dancysoft/frontend-restriction
buildkitd: Frontend restriction support
2024-05-13 14:46:54 -07:00
Ahmon Dancy
b5c50afa88 buildkitd: Frontend restriction support
This commit adds [frontend."dockerfile.v0"] and
[frontend."gateway.v0"] buildkitd.toml configuration sections.  Each
frontend can individually be disabled by setting `enabled = false`
(both frontends are enabled by default).

The [frontend."gateway.v0"] section has an `allowedRepositories`
setting.  If `allowedRepositories` is empty (the default), all gateway
sources are allowed.  Otherwise, only repositories in the list will be
allowed.  NOTE: Only the repository name (without tag) is compared.

Change-Id: Ia484401709ef6c13cf3e5a2e4d0e1c6bd0c47d13
Signed-off-by: Ahmon Dancy <adancy@wikimedia.org>
2024-05-09 08:50:56 -07:00
Jonathan A. Sternberg
228e250d77 detect: refactor the detect package
This refactors the detect package with the goal of making it more
similar to otel's `autoexport` package and splitting out the additional
functionality used by buildkit, like the trace recorder and delegated
tracer, to more explicit processors rather than implicit through
`autoexport`.

This removes the global variables for the trace provider and meter
provider along with the global variable for the exporters. This is
replaced with functions that create the exporters. The delegated tracer
has been removed from detect and moved into the normal tracing util
package. This is still used by the command line to send delegated
traces, but it's an explicit exporter that's added rather than implicit.

Some functions have been renamed mostly to force dependent packages to
change their usage rather than have a chance at incorrect usage because
the semantics changed.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-05-07 16:08:04 -05:00
Anthony Nandaa
205063bc7c docs: add documetation for --group and SecurityDescriptor config
This commit is a follow up of #4875, documenting the user of
`--group` flag and `grpc.SecurityDescriptor` toml config.

Also does a minor fix on the `help` for `--group` to specify
Windows named pipe alongside Unix socket.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2024-04-25 21:02:28 +03:00
Tonis Tiigi
68671bc9f9 buildkitd: allow --group for windows
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-24 12:17:38 -07:00
Anthony Nandaa
a5f9e42d7c fix: gc policy for windows to use percentage of disk space
Initially we had the GC Policy for Windows use only
2 GB (2e9 bytes) of disk space and this was limiting
for some build scenarios that need more than that,
especially ServerCore images.

This commit makes the policy to use percentages
as it is on Linux. Also going for 20%, double that
of Linux, since Windows images tend to be larger.

fixes #4858 docker/buildx#2411

Also, refactors the diskSize logic to simplify
it by bringing the `d.AsByte` function back from
platform specific files to `gcpolicy.go`.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2024-04-23 23:55:08 +03:00
Tonis Tiigi
a07a92e157 lint: unusedparams fixes for windows
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Tonis Tiigi
1f9988911f lint: unusedparams fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-04-09 07:23:16 -07:00
Jonathan A. Sternberg
c3105e49d9 otel: update usage of otelgrpc interceptors to use stat handlers
The otelgrpc interceptors were deprecated. This updates the areas where
these were used to use the stat handlers instead of the interceptors.
This helps with creating a single method for both unary and stream rpcs
and also ensures we aren't using a deprecated function for the future.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-03-29 16:39:25 -05:00
Höhl, Lukas
cda45ada82 fix: use default dialer for client
Uses the default grpc dialer to allow [proxy configuration](https://github.com/grpc/grpc-go/blob/v1.57.0/Documentation/proxy.md)

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>
2024-03-18 16:01:58 +01:00