Repository navigation
[ABLD-525] Point Bazel-built FIPS Go binaries to the embedded OpenSSL - #60334
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
Conversation
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is correct. No actionable issues found in the diff. The Linux FIPS linker flags use the shared embedded-library paths and add the stable fallback for versioned installs. Build and runtime validation were not run in this read-only environment.
03468b9 to
30ca43e
Compare
Static quality checks✅ Please find below the results from static quality gates 33 successful checks with minimal change (< 2 KiB)
|
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: fa3b80c Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | quality_gate_security_mean_fs_load | memory utilization | +0.50 | [+0.46, +0.53] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | +0.47 | [+0.21, +0.74] | 1 | Logs |
| ➖ | quality_gate_private_action_runner | memory utilization | +0.44 | [+0.32, +0.56] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle_all_features | memory utilization | +0.31 | [+0.27, +0.36] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_logs | % cpu utilization | +0.28 | [-0.61, +1.18] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.14 | [-0.80, +0.52] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle | memory utilization | -0.15 | [-0.19, -0.10] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | -0.26 | [-0.30, -0.22] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_no_fs_load | memory utilization | -0.30 | [-0.37, -0.23] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_metrics_logs | memory utilization | -0.49 | [-0.72, -0.26] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | -0.79 | [-1.34, -0.23] | 1 | Logs |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | -0.93 | [-1.14, -0.71] | 1 | Logs |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 75.02 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1348.17 ≤ 1500 | bounds checks dashboard |
| ✅ | python_openmetrics | memory_usage | 10/10 | 4.31GiB ≤ 4.75GiB | bounds checks dashboard |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 5 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 187.60MiB ≤ 190MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 767.93KiB ≤ 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 | 458.54MiB ≤ 544MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | total_bytes_received | 10/10 | 1.16MiB ≤ 1.25MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 16 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 221.40MiB ≤ 234MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B ≤ 0B | bounds checks dashboard |
| ✅ | quality_gate_logs | total_bytes_received | 10/10 | 263.75MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 363.80 ≤ 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 | 426.14MiB ≤ 463MiB | 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 | 953.41MiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 77.13MiB ≤ 78MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 28.09 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 332.92MiB ≤ 365MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 39.75 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 315.37MiB ≤ 343MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 23.14 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 320.79MiB ≤ 356MiB | 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_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check total_bytes_received: 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 memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check total_bytes_received: 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_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check total_bytes_received: 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 intake_connections: 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_metrics_logs, 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 cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_idle, bounds check memory_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_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
### What does this PR do? Give Linux FIPS Go binaries a RUNPATH to their embedded libraries with Go's `-r` in `dd_agent_go_binary`, so that `msgo` loads the embedded OpenSSL. For "versioned" install directories, as under `datadog-packages`, have that RUNPATH fall back to the "stable" version's libraries, for the installer, which an upgrade runs _before its version is unpacked_. :bulb: This is the last prerequisite to lifting #59511's guard against Bazel-built FIPS binaries, which #60204 will do. ### Motivation Bazel-built FIPS binaries had no RUNPATH to the embedded libraries, so `msgo` `dlopen`ed OpenSSL from the default search path, loading the **system** one (or panicking without one). Omnibus' `CGO_LDFLAGS`, whose `-rpath` the external linker honors for cgo binaries, never reach Bazel, whose own rpath only lists its `$ORIGIN`-relative solib directories, while Go's internal linker, which cgo-less binaries go through, ignores such flags anyway. Go's `-r` sets the search path whichever linker writes it, as #56351 does for the omnibus-built installer, listing both directories since #57045's `patchelf --set-rpath` of the bootstrap copy **segfaults** on such a binary once stripped. ### Describe how you validated your changes - the FIPS installer has `<install_dir>/embedded/lib` as `DT_RUNPATH` and loads `libcrypto.so.3` from there, - in a versioned install directory, its RUNPATH then lists the stable version's libraries, from which it loads `libcrypto.so.3` when its own version lacks it, - the FIPS agent uses cgo for `rtloader`, so the external linker writes its rpath: those directories come first, then Bazel's solib ones, - `replace_prefix`, which `--enable-bazel` agent builds run, keeps `<install_dir>/embedded/lib` in that rpath, - non-FIPS binaries keep their RUNPATH. ### Additional Notes The RUNPATH comes from an `EMBEDDED_LIB_DIRS` make variable of `//bazel/rules/variables`, which already derives `AGENT_PACKAGE_VERSION` from the install directory.
#60334 (comment) > As discussed offline, this is inconsistent with the overall policy of > delaying rpath setting to the last moment via patchelf. It's fine if > we land it like this (due to the patchelf bug you described), but we > should at some point strive to make things consistent; and in the > meantime a somewhat longer comment explaining the reason why we're > doing this here. => `dd_agent_go_binary` now explains why Linux FIPS binaries get their rpath at link time rather than through packaging's `patchelf` rewrite, and lists the upstream patchelf reports and fixes.
30ca43e to
b85a958
Compare
#60334 (comment) > 👍 Thanks (though as a nit I'll say that the comment should probably be > closer to the line with the `-r`). => The comment now sits right above the `-r` it explains.
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through a `fips_backend` of `bazel()` and `build_binary_with_bazel`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, including `go_build`'s, which then always runs `@rules_go//go`, the FIPS target platform selecting `msgo`. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. Explicit is better than implicit: the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. ### Describe how you validated your changes - `installer.build --enable-bazel --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--enable-bazel --flavor fips`, build `msgo` FIPS binaries without `AGENT_FLAVOR`, the FIPS target platform applying to both their `build` and `cquery`, - `--fips-backend boringcrypto` still fails, - `bazel()` selects the FIPS target platform for the `msgo` backend only, and fails on `AGENT_FLAVOR=fips` without it, as `dogstatsd.build` then shows, - `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds through `@rules_go//go` a binary with `msgo`'s OpenSSL backend, - the `bazel()` calls FIPS omnibus builds reach, which `go_build`, `schema.compress`, `build_libpcap` and the Windows resource helpers make, pass the build's backend. ### Additional Notes `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, `process-agent.build` and `otel-agent.build` no longer passing a `//packages/agent:flavor` their targets don't read, which `bazel()` adds from `AGENT_FLAVOR` anyway. `agent.build` also passes it to `rtloader.install-with-bazel`, so that local FIPS builds get FIPS `rtloader` and CPython. `build_binary_with_bazel` now rejects `boringcrypto`, which `go_build` keeps running through the upstream `go` tool. `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, omnibus' FIPS symbol check running `@rules_go//go tool nm` with the FIPS target platform its `omnibazel_flags` already carry.
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through a `fips_backend` of `bazel()` and `build_binary_with_bazel`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. Explicit is better than implicit: the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - `installer.build --enable-bazel --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--enable-bazel --flavor fips`, build `msgo` FIPS binaries without `AGENT_FLAVOR`, the FIPS target platform applying to both their `build` and `cquery`, - `--fips-backend boringcrypto` still fails, - `bazel()` selects the FIPS target platform for the `msgo` backend only, and fails on `AGENT_FLAVOR=fips` without it, as `dogstatsd.build` then shows, - `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds through `@rules_go//go` a binary with `msgo`'s OpenSSL backend, - the `bazel()` calls FIPS omnibus builds reach, which `go_build`, `schema.compress`, `build_libpcap`, `build_object_files` and the Windows resource helpers make, pass the build's backend. ### Additional Notes `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, `process-agent.build` and `otel-agent.build` no longer passing a `//packages/agent:flavor` their targets don't read, which `bazel()` adds from `AGENT_FLAVOR` anyway. `agent.build` also passes it to `rtloader.install-with-bazel`, so that local FIPS builds get FIPS `rtloader` and CPython. `build_binary_with_bazel` now rejects `boringcrypto`, which `go_build` keeps running through the upstream `go` tool. `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, omnibus' FIPS symbol check running `@rules_go//go tool nm` with the FIPS target platform its `omnibazel_flags` already carry.
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `secret-generic-connector.build --fips-backend boringcrypto`, as CI runs it, one with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `go_build` selects through `GOEXPERIMENT` alone, passing no backend, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `secret-generic-connector.build --fips-backend boringcrypto`, as CI runs it, one with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `go_build` selects through `GOEXPERIMENT` alone, passing no backend, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.for_bazel()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus still sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than discard Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call guessing it from the environment. Developers then get exactly what their CLI arguments request, whatever their environment. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus _still_ sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`, which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than thrashing Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call _guessing_ it from the environment. Developers then get exactly what their CLI arguments request, without having to tweak environment variables. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm` with the FIPS target platform of its `omnibazel_flags`, whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way rules_go means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk
…mode (#60204) 🫤 _Sorry for the number of touched files, hence of requested reviewers: this structural change is needed to guard against builds mixing non-FIPS, `msgo`-based FIPS and `boringcrypto`-based FIPS. The situation will gradually improve as subsequent `bazel()` calls get inlined as 1st-class targets in `BUILD.bazel` files, on the one hand, and as Bazel gets a proper Go SDK with `boringcrypto`, on the other hand._ ### What does this PR do? Let `--enable-bazel` build tasks request FIPS through an explicit `fips_backend`, which selects the FIPS target platform, instead of failing as #59511 made them. Stop `bazel()` from inferring FIPS from `AGENT_FLAVOR=fips`, which omnibus _still_ sets, every omnibus build task already receiving its FIPS option explicitly, and make it fail hard instead when a call doesn't pass the `msgo` backend, rather than silently building without FIPS. Pass that backend down every `bazel()` call a FIPS build reaches, as each got the FIPS target platform from `AGENT_FLAVOR` so far. `go_build` needs it to get `msgo` from `@rules_go//go`[^1], which it then always runs, `cquery` and `info` to locate what `build` produced for that platform, and the other calls to share the configuration of `build` rather than thrashing Bazel's analysis cache. ### Motivation #59511 blocked FIPS `--enable-bazel` builds because their binaries were silently non-FIPS, and later lacked a RUNPATH to the embedded OpenSSL, which #60334 adds. [Explicit is better than implicit](https://peps.python.org/pep-0020/): the task that knows it builds FIPS says so, rather than every `bazel()` call _guessing_ it from the environment. Developers then get exactly what their CLI arguments request, without having to tweak environment variables. ### Describe how you validated your changes - with `--enable-bazel` and no `AGENT_FLAVOR`, `installer.build --fips-backend msgo`, and `process-agent.build` and `privateactionrunner.build` with `--flavor fips`, build `msgo` FIPS binaries, the FIPS target platform applying to both their `build` and `cquery`, while `--fips-backend boringcrypto` fails, - without it, `installer.build --fips-backend msgo` with `AGENT_FLAVOR=fips`, as omnibus runs it, still builds a binary with `msgo`'s OpenSSL backend, and `cluster-agent.build` and `secret-generic-connector.build` with `--fips-backend boringcrypto`, as CI runs them, ones with BoringSSL, - `AGENT_FLAVOR=fips` fails the `bazel()` calls not passing the `msgo` backend, such as `dogstatsd.build`'s, - every `bazel()` call FIPS omnibus builds reach passes the build's backend. ### Additional Notes - `agent.build`, `process-agent.build`, `otel-agent.build` and `privateactionrunner.build` pass their flavor's backend, the 2nd and 3rd dropping a `//packages/agent:flavor` their targets don't read, - `agent.build` also passes it to `rtloader.install-with-bazel`, for local FIPS builds to get FIPS `rtloader` and CPython, - `bazel()` rejects `boringcrypto`, which `FipsBackend.strip_boringcrypto()` turns into no backend with a warning for `go_build`, whose `GOEXPERIMENT` alone selects it, and `schema.compress`, - `//:msgo`, its `msgo_binary` wrapper and the root module's `use_repo` of `@msgo` go away, as they were transitional until a target platform selected `msgo`, which #56440 did, - omnibus' FIPS symbol check runs `@rules_go//go tool nm`[^1] with the FIPS target platform of its `omnibazel_flags`. [^1]: whose `@rules_go//go/toolchain:sdk_name` resolves `@rules_go//go` to `msgo`, the way `rules_go` means an SDK to be selected and its `go` tool run: https://github.com/bazel-contrib/rules_go/blob/master/docs/go/core/bzlmod.md#using-a-go-sdk Co-authored-by: regis.desgroppes <[email protected]>
What does this PR do?
Give Linux FIPS Go binaries a RUNPATH to their embedded libraries with Go's
-rindd_agent_go_binary, so thatmsgoloads the embedded OpenSSL.For "versioned" install directories, as under
datadog-packages, have that RUNPATH fall back to the "stable" version's libraries, for the installer, which an upgrade runs before its version is unpacked.This is the last prerequisite to lifting #59511's guard against Bazel-built FIPS binaries, which #60204 will do.
Motivation
Bazel-built FIPS binaries had no RUNPATH to the embedded libraries, so
msgodlopened OpenSSL from the default search path, loading the system one (or panicking without one).Omnibus'
CGO_LDFLAGS, whose-rpaththe external linker honors for cgo binaries, never reach Bazel, whose own rpath only lists its$ORIGIN-relative solib directories, while Go's internal linker, which cgo-less binaries go through, ignores such flags anyway.Go's
-rsets the search path whichever linker writes it, as #56351 does for the omnibus-built installer, listing both directories since #57045'spatchelf --set-rpathof the bootstrap copy segfaults on such a binary:💡 the PR/commit is therefore meant to be reverted when
patchelfno longer exhibits the issue.Describe how you validated your changes
<install_dir>/embedded/libasDT_RUNPATHand loadslibcrypto.so.3from there,libcrypto.so.3when its own version lacks it,rtloader, so the external linker writes its rpath: those directories come first, then Bazel's solib ones,replace_prefix, which--enable-bazelagent builds run, keeps<install_dir>/embedded/libin that rpath,Additional Notes
The RUNPATH comes from an
EMBEDDED_LIB_DIRSmake variable of//bazel/rules/variables, which already derivesAGENT_PACKAGE_VERSIONfrom the install directory.