Skip to content

Commit 47c8431

Browse files
authored
Merge pull request #6105 from crazy-max/max-parallelism-flag
buildkitd: add flag to set max parallelism
2 parents 0396f3e + 7400820 commit 47c8431

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

cmd/buildkitd/main_containerd_worker.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ func init() {
124124
Name: "containerd-worker-selinux",
125125
Usage: "apply SELinux labels",
126126
},
127+
cli.IntFlag{
128+
Name: "containerd-max-parallelism",
129+
Usage: "limit the number of parallel build steps that can run at the same time",
130+
Value: defaultConf.Workers.Containerd.MaxParallelism,
131+
},
127132
}
128133
n := "containerd-worker-rootless"
129134
u := "enable rootless mode"
@@ -258,6 +263,9 @@ func applyContainerdFlags(c *cli.Context, cfg *config.Config) error {
258263
if c.GlobalIsSet("containerd-worker-selinux") {
259264
cfg.Workers.Containerd.SELinux = c.GlobalBool("containerd-worker-selinux")
260265
}
266+
if c.GlobalIsSet("containerd-max-parallelism") {
267+
cfg.Workers.Containerd.MaxParallelism = c.GlobalInt("containerd-max-parallelism")
268+
}
261269

262270
return nil
263271
}

cmd/buildkitd/main_oci_worker.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ func init() {
121121
Name: "oci-worker-selinux",
122122
Usage: "apply SELinux labels",
123123
},
124+
cli.IntFlag{
125+
Name: "oci-max-parallelism",
126+
Usage: "limit the number of parallel build steps that can run at the same time",
127+
Value: defaultConf.Workers.OCI.MaxParallelism,
128+
},
124129
}
125130
n := "oci-worker-rootless"
126131
u := "enable rootless mode"
@@ -252,6 +257,9 @@ func applyOCIFlags(c *cli.Context, cfg *config.Config) error {
252257
if c.GlobalIsSet("oci-worker-selinux") {
253258
cfg.Workers.OCI.SELinux = c.GlobalBool("oci-worker-selinux")
254259
}
260+
if c.GlobalIsSet("oci-max-parallelism") {
261+
cfg.Workers.OCI.MaxParallelism = c.GlobalInt("oci-max-parallelism")
262+
}
255263

256264
return nil
257265
}

docs/buildkitd.toml.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
6969
# Whether run subprocesses in main pid namespace or not, this is useful for
7070
# running rootless buildkit inside a container.
7171
noProcessSandbox = false
72-
7372
# gc enables/disables garbage collection
7473
gc = true
7574
# reservedSpace is the minimum amount of disk space guaranteed to be
@@ -87,7 +86,6 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
8786
# collector will attempt to leave - however, it will never be bought below
8887
# reservedSpace.
8988
minFreeSpace = "20GB"
90-
9189
# alternate OCI worker binary name(example 'crun'), by default either
9290
# buildkit-runc or runc binary is used
9391
binary = ""
@@ -116,7 +114,6 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
116114
# collector will attempt to leave - however, it will never be bought below
117115
# reservedSpace.
118116
minFreeSpace = "10GB"
119-
120117
# keepDuration can be an integer number of seconds (e.g. 172800), or a
121118
# string duration (e.g. "48h")
122119
keepDuration = "48h"
@@ -148,7 +145,8 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
148145
# collector will attempt to leave - however, it will never be bought below
149146
# reservedSpace.
150147
minFreeSpace = "20GB"
151-
148+
# limit the number of parallel build steps that can run at the same time
149+
max-parallelism = 4
152150
# maintain a pool of reusable CNI network namespaces to amortize the overhead
153151
# of allocating and releasing the namespaces
154152
cniPoolSize = 16
@@ -195,7 +193,6 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
195193

196194
[frontend."gateway.v0"]
197195
enabled = true
198-
199196
# If allowedRepositories is empty, all gateway sources are allowed.
200197
# Otherwise, only the listed repositories are allowed as a gateway source.
201198
#
@@ -208,5 +205,4 @@ insecure-entitlements = [ "network.host", "security.insecure", "device" ]
208205
[system]
209206
# how often buildkit scans for changes in the supported emulated platforms
210207
platformsCacheMaxAge = "1h"
211-
212208
```

0 commit comments

Comments
 (0)