Repository navigation
fix(ci): propagate CPU limits in Linux Bazel jobs (instead of 96 on x86_64) - #56994
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
Conversation
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
^ ❓❓❓
The patch is incorrect: the new CPU-limit parser mishandles valid Kubernetes millicore quantities, defeating the intended concurrency limit.
(obsolete)
Gitlab CI Configuration ChangesChanges Summary
ℹ️ Diff available in the job log. |
Files inventory check summaryFile checks results against ancestor 4433f597: Results for datadog-agent_7.85.0~devel.git.784.cc0ecf5.pipeline.140995231-1_amd64.deb:No change detected Results for datadog-iot-agent_7.85.0~devel.git.784.cc0ecf5.pipeline.140995231-1_amd64.deb:No change detected |
0938d1f to
39b1512
Compare
39b1512 to
59b948d
Compare
3531378 to
a289657
Compare
|
I am not going to block this change but I don't think it's right to hide kubernetes specific logic inside of the wrapper that is used everywhere. I still think we should explicitly set CPU requests everywhere and just use --jobs= with the value read from requests or a similar approach. First, it's somewhat "cloud native" approach when you set parameter from both ends - provider and consumer. Second, it makes it clearer what are the requirements towards compute to perform that chunk of work. As I mentioned, I am not ready to die for it, just sharing my opinion. |
a289657 to
f8c8b5a
Compare
|
@JSGette Fair point on the general principle, and I don't disagree that config coming from both ends (provider and consumer) is usually the right instinct. However, I checked whether With a minimal isolated Bazel workspace running a binary that just prints its own
Both flags are Bazel's own internal action-scheduling bookkeeping: they don't touch a spawned process' environment or affinity mask. => On putting it in => None of this rules out also setting |
f8c8b5a to
9ce9b38
Compare
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
🚬 🚭
The patch is correct based on static review. No actionable issues were identified in the changed CI resource settings or Bazel CPU-affinity wrapper. CI execution was not validated.
KevinFairise2
left a comment
There was a problem hiding this comment.
Thanks for that change!
I do agree that it is not ideal to have logic that is very coupled to how our CI runners are made inside that wrapper. But in the other ends this is the best solution we have available that works for now. And I think it will drastically help us to have more predictable resource consumption for our jobs!
…6_64
### What does this PR do?
Pin Bazel, and everything it spawns, to `KUBERNETES_CPU_LIMIT` CPUs via
`taskset` in `tools/bazel`, Linux only.
Set the default on `.bazel:defs:cache:progressive`, the cache mixin
every Bazel-invoking job extends, to `KUBERNETES_CPU_REQUEST: 8` /
`KUBERNETES_CPU_LIMIT: 16`, reaching every one of those jobs instead of
the handful that previously declared their own `KUBERNETES_CPU_LIMIT`.
Double the limit relative to the request so jobs can opportunistically
use idle node capacity, since `taskset` only binds our own process tree,
not a cgroup guarantee.
Remove the per-job `KUBERNETES_CPU_REQUEST`/`LIMIT` overrides that just
duplicated this default, and the now-redundant explicit
`--jobs=$KUBERNETES_CPU_REQUEST` on `bazel coverage`/`bazel test`.
Drop the now-redundant `--cpus $KUBERNETES_CPU_REQUEST` from
`lint/{cross,linux}.yml` and `ebpf.yml`'s `linter.go` calls, since
golangci-lint's own default concurrency, `runtime.NumCPU()`, already
reads the `taskset`-restricted affinity mask on its own.
Halve `go_e2e_test_binaries`'s `KUBERNETES_MEMORY_REQUEST`/`LIMIT` from
64Gi to 32Gi.
### Motivation
Datadog's internal Kubernetes clusters, CI included, run job pods as
`Burstable` QoS rather than `Guaranteed`, because sidecar containers
like `emissary` don't declare a matching CPU request and limit, and
`Guaranteed` is what actually triggers `cpuset` pinning and a CFS quota.
https://datadoghq.atlassian.net/wiki/spaces/cxg/pages/3473212607/Container+CPU+limits+in+internal+environments
Without either, `cpu.max` reads `max` no matter what
`KUBERNETES_CPU_LIMIT` resolves to, so any cgroup-aware CPU
auto-detection, Bazel's own `--jobs=auto`/`--local_resources` sizing
included, sees the full host core count instead of what was granted,
anywhere from 48 cores on an arm64 runner to 96 on amd64, and so does
every action Bazel spawns, since e.g. `GoCompilePkg`'s own internal
compiler concurrency defaults to `runtime.GOMAXPROCS(0)`.
`go_e2e_test_binaries` is what actually surfaced this: it was OOM-killed
110 times over 15 days in datadog-agent's own CI logs, still the single
biggest source of these failures in the whole pipeline, because it moved
from a Python thread pool, where `KUBERNETES_CPU_LIMIT` genuinely capped
`GOMAXPROCS`, to a single `bazel run` call that never read that variable
at all.
`taskset` fixes this regardless of QoS class, because CPU affinity is
inherited across `fork`/`exec` all the way down, unlike passing
`--jobs`/`--local_resources` explicitly, which only bounds Bazel's own
scheduling and leaves every spawned action to size itself off the same
wrong host-wide number.
### Describe how you validated your changes
Verified `taskset` reaches spawned actions, not just the Bazel server,
with a stubbed `$BAZEL_REAL` and a grandchild process, and exercised the
wraparound, fractional, and unset `KUBERNETES_CPU_LIMIT` cases under
`bash -n` and real `taskset` invocations.
Compared durations against three recent `main` pipelines and retried
each job at least once on the PR pipeline, for every job extending
`.bazel:defs:cache:progressive`:
| Job | main 140467914 | main 140459135 | main 140451211 | PR baseline | PR retry |
|---|---|---|---|---|---|
| `bazel:coverage:linux-amd64` | 6m44s | 11m56s | 7m00s | 6m26s | 10m07s |
| `bazel:coverage:linux-arm64` | 9m44s | 9m55s | 9m52s | 8m40s | 10m46s |
| `bazel:test:linux-amd64` | 10m58s | 12m13s | 15m41s | 9m58s | 10m37s |
| `bazel:test:linux-arm64` | 14m00s | 13m18s | 15m00s | 23m18s | 9m39s |
| `bazel:mod-deps` | 1m17s | 1m25s | 3m07s | 1m09s | 1m18s |
| `bazel:mod-tidy` | 2m54s | 1m19s | 1m29s | 1m06s | 1m14s |
| `bazel:query-missing-manual-tags` | 4m09s | 2m00s | 1m54s | 4m52s | 1m45s |
| `bazel:run-buildifier-test` | 1m35s | 1m39s | 3m15s | 1m08s | 1m23s |
| `bazel:run-gazelle` | 3m47s | 2m16s | 1m52s | 1m31s | 1m41s |
| `bazel:run-go-mod-tidy` | 4m06s | 5m59s | 4m36s | 3m11s | 3m43s |
| `lint_cross_windows-x64` | 7m16s | 7m29s | 7m17s | 6m45s | 7m28s |
| `lint_cross_macos-x64` | 9m41s | 7m20s | 7m04s | 11m28s | 9m25s |
| `lint_cross_macos-arm64` | 6m51s | 7m37s | 6m33s | 8m23s | 7m55s |
| `lint_cross_aix-ppc64` | 6m38s | 6m36s | 5m56s | 5m52s | 6m22s |
| `lint_linux-x64` | 9m29s | 8m53s | 10m33s | 9m58s | 10m19s |
| `lint_linux-arm64` | 13m40s | 9m40s | 12m10s | 12m32s | 14m00s |
| `lint_flavor_iot_linux-x64` | 8m14s | 8m13s | 7m51s | 9m47s | 9m04s |
| `lint_flavor_dogstatsd_linux-x64` | 7m48s | 8m55s | 7m48s | 9m15s | 11m41s |
| `lint_flavor_heroku_linux-x64` | 9m46s | 8m19s | 8m02s | 10m58s | 8m38s |
| `cross_build_agent-binary_aix_ppc64` | 3m51s | 4m13s | 4m04s | 3m32s | 3m58s |
| `cross_build_trace_agent-binary_aix_ppc64` | 2m31s | 2m32s | 2m58s | 2m14s | 2m58s |
| `cluster_agent-build_amd64` | 3m45s | 3m45s | 3m49s | 3m15s | 3m32s |
| `cluster_agent-build_arm64` | 6m52s | 4m56s | 5m49s | 5m58s | 7m44s |
| `cluster_agent_fips-build_amd64` | 3m37s | 6m14s | 3m54s | 3m20s | 3m35s |
| `cluster_agent_fips-build_arm64` | 7m13s | 4m31s | 4m03s | 4m59s | 4m32s |
| `cluster_agent_cloudfoundry-build_amd64` | 2m47s | 3m19s | 4m23s | 2m47s | 2m36s |
| `cws_instrumentation-build_amd64` | 1m48s | 2m43s | 2m01s | 1m33s | 1m31s |
| `cws_instrumentation-build_arm64` | 2m11s | 2m06s | 3m37s | 1m46s | 2m10s |
| `cws_instrumentation-build_injector_amd64` | 1m59s | 1m51s | 1m54s | 1m29s | 1m43s |
| `cws_instrumentation-build_injector_arm64` | 4m38s | 2m08s | 2m08s | 1m56s | 1m46s |
| `build_dogstatsd_static-binary_x64` | 2m06s | 2m05s | 2m07s | 1m44s | 1m41s |
| `build_dogstatsd_static-binary_arm64` | 2m36s | 2m20s | 2m30s | 2m35s | 1m59s |
| `build_dogstatsd-binary_x64` | 2m16s | 2m09s | 4m01s | 1m42s | 1m56s |
| `build_dogstatsd-binary_arm64` | 7m14s | 2m34s | 2m23s | 2m12s | 2m19s |
| `build_iot_agent-binary_x64` | 3m19s | 2m46s | 2m36s | 2m41s | 2m17s |
| `build_iot_agent-binary_arm64` | 5m51s | 3m17s | 2m51s | 2m39s | 3m51s |
| `secret_generic_connector-build_amd64` | 1m53s | 2m15s | 2m20s | 1m39s | 1m46s |
| `secret_generic_connector-build_arm64` | 2m19s | 2m30s | 4m22s | 2m06s | 1m49s |
| `secret_generic_connector_fips-build_amd64` | 2m04s | 2m23s | 2m17s | 1m56s | 1m42s |
| `secret_generic_connector_fips-build_arm64` | 6m16s | 2m26s | 2m29s | 2m04s | 2m13s |
| `build_system-probe-x64` | 7m24s | 7m30s | 7m40s | 7m44s | 7m06s |
| `build_system-probe-arm64` | 7m30s | 8m02s | 6m07s | 6m40s | 6m43s |
| `tests_linux-x64-py3` | 22m23s | 21m56s | 21m47s | 9m55s | 10m48s |
| `tests_linux-arm64-py3` | 30m53s | 26m06s | 26m21s | 10m34s | 12m14s |
| `tests_serverless-init` | 4m31s | 3m32s | 3m51s | 3m13s | 3m16s |
| `tests_serverless-init-logs` | 2m40s | 2m21s | 2m47s | 2m34s | 2m16s |
| `new-e2e-unit-tests` | 7m27s | 8m46s | 7m32s | 7m28s | 7m17s |
| `tests_ebpf_x64` | 13m52s | 14m27s | 13m21s | 12m33s | 13m34s |
| `tests_ebpf_arm64` | 16m16s | 18m44s | 20m24s | 14m53s | 14m34s |
| `security_go_generate_check` | 3m09s | 3m15s | 3m06s | 3m00s | 2m44s |
| `go_e2e_test_binaries` | 6m50s | 5m06s | 5m11s | 3m51s | 4m26s |
The `bazel:test:linux-arm64` baseline outlier didn't reproduce on retry.
Every other job landed within its `main` range across all three
reference pipelines.
### Additional Notes
`.bazel:defs:cache:progressive` also covers jobs that never declared any
`KUBERNETES_CPU_REQUEST` at all (`cws_instrumentation`,
`secret_generic_connector`, plain Go unit tests, fuzzing), so they get
`taskset`-bounded for the first time too, at the plain default.
Jobs keeping their own lower `KUBERNETES_CPU_REQUEST` (`aix_cross`,
`cluster_agent`, `system_probe`, ...) still inherit the shared
`KUBERNETES_CPU_LIMIT: 16`, so they can opportunistically use more than
they reserve, same as the default case.
`invoke_unit_tests` inherits the new default too, but couldn't be
validated: its rule (`.on_invoke_tasks_changes`) never fired in this
diff or in any of the three reference pipelines.
The previous wraparound bound came from `getconf _NPROCESSORS_ONLN`, the host's **raw** CPU count, not the set actually **allowed** to this process. A container that already excludes some CPUs, for example Kubernetes' system-reserved ones, made `taskset` silently intersect that computed range down to **fewer** CPUs than `KUBERNETES_CPU_LIMIT` requested. A sweep of a real CI pipeline found this mismatch in about half of the sampled jobs, one of them landing on a single usable CPU despite requesting 16! => replace the `bash` and `awk` arithmetic with an embedded `python` snippet that; 1. reads the real permitted set from `os.sched_getaffinity(0)`, 2. splits it at the last CPU this shell ran on via `bisect.bisect_left`, 3. rotates so the selection always starts from an actually allowed CPU. This also drops the separate wraparound branch, since slicing the rotated list naturally stops at however many CPUs are really available.
9ce9b38 to
cc0ecf5
Compare
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: 5ce35eb Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | quality_gate_metrics_logs | memory utilization | +1.42 | [+1.19, +1.65] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | +1.32 | [+0.83, +1.81] | 1 | Logs |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | +0.78 | [+0.56, +1.00] | 1 | Logs |
| ➖ | quality_gate_logs | % cpu utilization | +0.32 | [-0.51, +1.16] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle_all_features | memory utilization | +0.13 | [+0.07, +0.19] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_no_fs_load | memory utilization | +0.00 | [-0.07, +0.08] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle | memory utilization | -0.02 | [-0.06, +0.02] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.06 | [-0.74, +0.62] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | -0.25 | [-0.29, -0.21] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_private_action_runner | memory utilization | -0.25 | [-0.38, -0.12] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_mean_fs_load | memory utilization | -0.87 | [-0.92, -0.83] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | -0.91 | [-1.13, -0.68] | 1 | Logs |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 81.14 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1335.58 ≤ 1500 | bounds checks dashboard |
| ✅ | python_openmetrics | memory_usage | 10/10 | 4.32GiB ≤ 4.75GiB | bounds checks dashboard |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 4 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 176.55MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 761.67KiB ≤ 819.20KiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 2 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 464.54MiB ≤ 542MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | total_bytes_received | 10/10 | 1.12MiB ≤ 1.25MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 18 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 212.37MiB ≤ 228MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_logs | total_bytes_received | 10/10 | 263.50MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 348.92 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 19 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 431.88MiB ≤ 455MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | total_bytes_received | 10/10 | 0.93GiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 72.83MiB ≤ 75MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 30.26 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 327.30MiB ≤ 357MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 63.67 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 307.56MiB ≤ 337MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 25.72 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 311.57MiB ≤ 348MiB | bounds checks dashboard |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
- quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
- quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
The gotest-custom build was the last direct OS-go invocation in e2e jobs, bypassing the tools/bazel taskset CPU pin from #56994: it sized its parallelism off the host core count (up to 96 on x86_64) instead of the pod's CPU limit. Route it through the wrapper like every other go call in these jobs (gotestsum runs via bazel run //internal/tools:gotestsum), so CPU affinity is inherited all the way down. Suggested-by: Régis Desgroppes <[email protected]>
### What does this PR do? Route the `go build` of `gotest-custom` in `new-e2e-tests.run` through `bazel run //:go -- build …` instead of calling the OS-provided `go` directly. ### Motivation It was the last direct OS-`go` invocation left in the e2e jobs — everything else (gotestsum, `go test`, the test binaries) already runs under `bazel run //internal/tools:gotestsum`. Going through the `tools/bazel` wrapper means the `taskset` CPU pin from #56994 is inherited by this build too, instead of sizing its parallelism off the host core count (up to 96 on x86_64) against the job's RAM limit. https://datadoghq.atlassian.net/browse/ACIX-2077 Replaces the earlier GOMAXPROCS/GOMEMLIMIT approach from this PR, per the review discussion (thanks @rdesgroppes). Resource requests and limits are left untouched. ### Describe how you validated your changes Smoke-tested the exact invocation (`bazel run //:go -- build -o … ./internal/tools/gotest-custom`) locally — it compiles and produces the binary. Co-authored-by: nicolas.schweitzer <[email protected]>
…57555) ### What does this PR do? Patch `rules_go` with bazel-contrib/rules_go#4727, which declares a 2048MB `resource_set` for `GoLink` instead of Bazel's 250MB default. ### Motivation `go_e2e_test_binaries` OOM kills resurfaced on `main` ([#incident-61714](https://dd.enterprise.slack.com/archives/C0C6V8J63B3)) after #56683 bumped a constant in a package every e2e test depends on, forcing all test binaries to relink at once instead of hitting the remote cache, leading to either: - `OOMKilled` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108531979)): ``` ERROR: Job failed (system failure): Error in container build: exit code: 137, reason: 'OOMKilled' ``` - or `Segmentation fault` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108458779)): ``` collect2: fatal error: ld terminated with signal 11 [Segmentation fault] ``` Bazel accounts 250MB per action and thus runs 16 of them at once, one per CPU granted since #56994, whereas a Go link peaks at up to 2490MB RSS, beyond the 32Gi memory limit (shared with Bazel's JVM, among others). ### Describe how you validated your changes `//pkg/version:version_test` builds with the patch applied and `MODULE.bazel.lock` stays unchanged. Co-authored-by: regis.desgroppes <[email protected]>
…57555) ### What does this PR do? Patch `rules_go` with bazel-contrib/rules_go#4727, which declares a 2048MB `resource_set` for `GoLink` instead of Bazel's 250MB default. ### Motivation `go_e2e_test_binaries` OOM kills resurfaced on `main` ([#incident-61714](https://dd.enterprise.slack.com/archives/C0C6V8J63B3)) after #56683 bumped a constant in a package every e2e test depends on, forcing all test binaries to relink at once instead of hitting the remote cache, leading to either: - `OOMKilled` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108531979)): ``` ERROR: Job failed (system failure): Error in container build: exit code: 137, reason: 'OOMKilled' ``` - or `Segmentation fault` ([example](https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2108458779)): ``` collect2: fatal error: ld terminated with signal 11 [Segmentation fault] ``` Bazel accounts 250MB per action and thus runs 16 of them at once, one per CPU granted since #56994, whereas a Go link peaks at up to 2490MB RSS, beyond the 32Gi memory limit (shared with Bazel's JVM, among others). ### Describe how you validated your changes `//pkg/version:version_test` builds with the patch applied and `MODULE.bazel.lock` stays unchanged. Co-authored-by: regis.desgroppes <[email protected]> 353a00a
What does this PR do?
Pin Bazel, and everything it spawns, to
KUBERNETES_CPU_LIMITCPUs viatasksetintools/bazel, Linux only (as of today's setup).Set the default on
.bazel:defs:cache:progressive, the cache mixin every Bazel-invoking job extends, toKUBERNETES_CPU_REQUEST: 8/KUBERNETES_CPU_LIMIT: 16, reaching every one of those jobs instead of the handful that previously declared their ownKUBERNETES_CPU_LIMIT.Double the limit relative to the request so jobs can opportunistically use idle node capacity, since
tasksetonly binds our own process tree, not acgroupguarantee.Remove the per-job
KUBERNETES_CPU_REQUEST/LIMIToverrides that just duplicated this default, and the now-redundant explicit--jobs=$KUBERNETES_CPU_REQUESTonbazel coverage/bazel test.Drop the now-redundant
--cpus $KUBERNETES_CPU_REQUESTfromlint/{cross,linux}.ymlandebpf.yml'slinter.gocalls, sincegolangci-lint's own default concurrency,runtime.NumCPU(), already reads thetaskset-restricted affinity mask on its own.Halve
go_e2e_test_binaries'sKUBERNETES_MEMORY_REQUEST/LIMITfrom 64Gi to 32Gi (we might even need less).Motivation
Datadog's internal Kubernetes clusters, CI included, run job pods as
BurstableQoS rather thanGuaranteed, because sidecar containers likeemissarydon't declare a matching CPU request and limit, andGuaranteedis what actually triggerscpusetpinning and a CFS quota, see:https://datadoghq.atlassian.net/wiki/spaces/cxg/pages/3473212607/Container+CPU+limits+in+internal+environments
Without either,
cpu.maxreadsmaxno matter whatKUBERNETES_CPU_LIMITresolves to, so anycgroup-aware CPU auto-detection, Bazel's own--jobs=auto/--local_resourcessizing included, sees the full host core count instead of what was granted, anywhere from 48 cores on an arm64 runner to 96 on x86_64, and so does every action Bazel spawns, since e.g.GoCompilePkg's own internal compiler concurrency defaults toruntime.GOMAXPROCS(0).go_e2e_test_binariesis what actually surfaced this the most: it was OOM-killed ~110 times over 15 days in datadog-agent's own CI logs, still the single biggest source of these failures in the whole pipeline, because it moved from a Python thread pool, whereKUBERNETES_CPU_LIMITgenuinely cappedGOMAXPROCS, to a singlebazel runcall that never read that variable at all.💡
tasksetfixes this regardless of QoS class, because CPU affinity is inherited acrossfork/execall the way down, unlike passing--jobs/--local_resourcesexplicitly, which only bounds Bazel's own scheduling and leaves every spawned action to size itself off the same wrong host-wide number.Describe how you validated your changes
Verified
tasksetreaches spawned actions, not just the Bazel server, with a stubbed$BAZEL_REALand a grandchild process, and exercised the wraparound, fractional, and unsetKUBERNETES_CPU_LIMITcases underbash -nand realtasksetinvocations.Compared durations against three recent
mainpipelines and retried each job at least once on the PR pipeline, for every job extending.bazel:defs:cache:progressive:Additional Notes
The PR doesn't address whether
KUBERNETES_CPU_REQUESTcould be unset (scheduling != capping).