Repository navigation
[ABLD-525] Make FIPS a property of the target platform - #56440
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
Conversation
There was a problem hiding this comment.
AI review by Codex (OpenAI) - workflow run
The patch is incorrect: Windows FIPS task invocation fails on typical hosts, and ARM64/Windows FIPS platforms do not select Microsoft Go. The required module lockfile update is also missing. Review was static; builds were not run.
(outdated)
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: 9335a62 Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | quality_gate_idle_all_features | memory utilization | +0.18 | [+0.10, +0.26] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_idle | memory utilization | +0.04 | [-0.00, +0.09] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_private_action_runner | memory utilization | +0.02 | [-0.10, +0.15] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_no_fs_load | memory utilization | -0.06 | [-0.12, +0.00] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.17 | [-0.82, +0.48] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | -0.17 | [-0.22, -0.12] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | -0.42 | [-0.70, -0.15] | 1 | Logs |
| ➖ | quality_gate_metrics_logs | memory utilization | -0.66 | [-0.89, -0.44] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_mean_fs_load | memory utilization | -0.67 | [-0.71, -0.63] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | -0.69 | [-0.91, -0.47] | 1 | Logs |
| ➖ | quality_gate_logs | % cpu utilization | -1.45 | [-2.38, -0.53] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | -1.45 | [-1.99, -0.92] | 1 | Logs |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 82.55 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1350.55 ≤ 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 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 184.37MiB ≤ 190MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 767.66KiB ≤ 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 | 479.48MiB ≤ 544MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | total_bytes_received | 10/10 | 1.17MiB ≤ 1.25MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 17 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 223.05MiB ≤ 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.96MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 357.99 ≤ 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 | 421.26MiB ≤ 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 | 969.94MiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 75.02MiB ≤ 78MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 28.30 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 331.16MiB ≤ 365MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 41.73 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 309.46MiB ≤ 343MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 23.55 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 342.85MiB ≤ 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? Registers the Microsoft build of Go (msgo) as an additional toolchain and selects it for the agent's fips flavor through --platforms, via bazel/platform_mappings (wired in .bazelrc, since it is not at the default workspace-root location) mapping //bazel/platforms:linux_x86_64_fips to --@rules_go//go/toolchain:sdk_name=msgo. fips becomes an orthogonal //bazel/platforms:crypto constraint rather than a flavor value: packages/agent:flavor drops "fips" from its allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/ windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now match on that constraint instead of the flag. linux_fips is a plain config_setting repeating linux_default's criteria (base_flavor and linux) plus fips_flavor, rather than a sibling of it behind a selects.config_setting_group alias, so Bazel's own select() specialization rule (a match wins if its criteria are a strict superset of another match's) picks it automatically, with no separate exclusion needed. The @@ canonical-repository prefix is dropped from labels inside packages/agent/BUILD.bazel itself, since a plain // there already resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which is injected as a different repo's own root BUILD file and genuinely needs it. packages/rules/package_naming.bzl's product-name injection reads the same constraint directly (ctx.target_platform_has_constraint), since the flavor value it used to read can no longer be "fips". A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored in omnibus/lib/ostools.rb) computes the right --platforms=...fips value for the current host; every place that used to pass the retired --//packages/agent:flavor=fips now calls it instead, including the omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the cws-instrumentation, installer, security-agent, secret-generic-connector, otel-agent and process-agent invoke tasks. Also fixes four issues surfaced once CI ran on this PR (#56440). bazel:mod-tidy and bazel:run-buildifier-test (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528) failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries were single-line; buildifier wraps each sdks value and the experiments list, the same rule already applied to packages/agent/BUILD.bazel's linux_fips config_setting. Reformatted to match. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172) failed with "No fips platform for win32/AMD64": platform.machine() returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only had lowercase keys. Lower-cased the lookup. installer-fips-amd64-oci (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644) failed compiling msgo's own crypto/internal/backend/fips140/fips140.go with "undefined: systemFIPSMode" and "undefined: backendEnabled", right after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto." The failing action is go_tool_binary building msgo's own builder/pack/covdata tools, which has no C toolchain wired in. deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside systemcrypto, and a new rules_go patch (bazel/patches/rules_go-tool-binary-goexperiment.patch) threads sdk.experiments into that rule's own GOEXPERIMENT env, which go_tool_binary never set for either SDK. bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64 and bazel:test:windows-amd64 (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261) failed resolving toolchains for test_fips_flavor_{product_name,multiword,single_word}_inner with "No matching toolchains found for types: @@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS tests transition --platforms, and package_name_variables's unconditional find_cc_toolchain() then needs a cross C++ toolchain none of those hosts register, for fields these tests never check. package_naming.bzl gains flavor_naming_subject, a toolchain-free rule exposing just _inject_flavor()'s product_name, and the three FIPS tests now build against it instead of package_name_variables. ### Motivation rules_go's own toolchain selection is driven by --@rules_go//go/toolchain:sdk_name, matched via target_settings on its auto-generated toolchain() targets; deriving that flag from a custom one would need either patching go_transition (go_binary's rule() already claims the one incoming-transition slot Bazel allows) or hand-writing toolchain() registrations that duplicate rules_go's own exec/target platform matrix. platform_mappings avoids both: it is the native Bazel mechanism for mapping a --platforms value to other flag values, so this needs no patch and no duplicated toolchain logic. fips is orthogonal to flavor because omnibus's AgentFlavor enum, which packages/agent:flavor mirrored, conflates the two and makes a heroku or iot fips build unrepresentable; that conflation is legacy scaffolding being migrated away from, not a constraint worth carrying into new Bazel-only logic. Retiring "fips" as a flavor value without fixing its remaining callers would have left them silently building non-fips output: --//packages/agent:flavor=fips is no longer valid, but most of the affected builds never force analysis of the flavor flag itself, so the invalid value is dropped rather than rejected. ### Describe how you validated your changes Confirmed with cquery/aquery that --platforms=//bazel/platforms:linux_x86_64_fips resolves cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects requirefips/goexperiment.systemcrypto into its GoCompilePkg action, while a plain build with no flag resolves to @go_work_sdk and injects neither, both before and after moving platform_mappings under bazel/. Confirmed the same tags/toolchain split for cmd/dogstatsd and cmd/installer, and confirmed packages/agent/linux:debian (the actual .deb packaging target) and @openssl//:openssl analyze successfully under both configurations with no ambiguous select() matches. Reproduced the regression this fixes before fixing it: bazel test //packages/rules:* hard-failed on test_fips_flavor_product_name/multiword/single_word with "invalid value 'fips'", and cmd/installer silently resolved to @go_work_sdk with no fips tags under the retired flag. After the fix, the same test suite and tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and cmd/installer resolves to @msgo with the fips tags present. Confirmed the ambiguous-select error this design avoids is real by temporarily removing the exclusion and rebuilding, confirmed datadog-heroku-agent/datadog-agent package names are unaffected, and confirmed buildifier is clean on packages/agent/BUILD.bazel with no canonical-repository or other findings. Confirmed each of the four fixes above directly against real job traces fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed --raw, run on the host with no dev-env container), quoting the exact failures cited above. After the fixes, bazel run //bazel/buildifier:test is clean repo-wide, bazel mod tidy --lockfile_mode=off produces no diff, bazel test //packages/rules:* passes all 8 targets, tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips //cmd/agent:agent succeeds, with go version -m on the resulting binary still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the expected requirefips/goexperiment.systemcrypto tags. ### Additional Notes //:gazelle_binary built together with --platforms=...fips in the same invocation still inherits msgo, since nothing separates its configuration from cmd/agent's in that case. This is benign: cmd/agent's own build has no go_tool_transition-reached dependencies for msgo to leak into, and nobody invokes gazelle with a platform override in practice. cmd/agent and cmd/dogstatsd never force analysis of //packages/agent:flavor itself, so the retired --//packages/agent:flavor=fips invocation silently falls back to a non-fips build for them rather than erroring; that direction is safe, since BuiltForFIPS() correctly reports false rather than a false positive. Co-Authored-By: Claude Sonnet 5 <[email protected]>
7d11ade to
ea7c3fe
Compare
### What does this PR do? Registers the Microsoft build of Go (msgo) as an additional toolchain and selects it for the agent's fips flavor through --platforms, via bazel/platform_mappings (wired in .bazelrc, since it is not at the default workspace-root location) mapping //bazel/platforms:linux_x86_64_fips to --@rules_go//go/toolchain:sdk_name=msgo. fips becomes an orthogonal //bazel/platforms:crypto constraint rather than a flavor value: packages/agent:flavor drops "fips" from its allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/ windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now match on that constraint instead of the flag. linux_fips is a plain config_setting repeating linux_default's criteria (base_flavor and linux) plus fips_flavor, rather than a sibling of it behind a selects.config_setting_group alias, so Bazel's own select() specialization rule (a match wins if its criteria are a strict superset of another match's) picks it automatically, with no separate exclusion needed. The @@ canonical-repository prefix is dropped from labels inside packages/agent/BUILD.bazel itself, since a plain // there already resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which is injected as a different repo's own root BUILD file and genuinely needs it. packages/rules/package_naming.bzl's product-name injection reads the same constraint directly (ctx.target_platform_has_constraint), since the flavor value it used to read can no longer be "fips". A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored in omnibus/lib/ostools.rb) computes the right --platforms=...fips value for the current host; every place that used to pass the retired --//packages/agent:flavor=fips now calls it instead, including the omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the cws-instrumentation, installer, security-agent, secret-generic-connector, otel-agent and process-agent invoke tasks. Also fixes four issues surfaced once CI ran on this PR (#56440). bazel:mod-tidy and bazel:run-buildifier-test (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528) failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries were single-line; buildifier wraps each sdks value and the experiments list, the same rule already applied to packages/agent/BUILD.bazel's linux_fips config_setting. Reformatted to match. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172) failed with "No fips platform for win32/AMD64": platform.machine() returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only had lowercase keys. Lower-cased the lookup. installer-fips-amd64-oci (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644) failed compiling msgo's own crypto/internal/backend/fips140/fips140.go with "undefined: systemFIPSMode" and "undefined: backendEnabled", right after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto." The failing action is go_tool_binary building msgo's own builder/pack/covdata tools, which has no C toolchain wired in. deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside systemcrypto, and a new rules_go patch (bazel/patches/rules_go-tool-binary-goexperiment.patch) threads sdk.experiments into that rule's own GOEXPERIMENT env, which go_tool_binary never set for either SDK. bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64 and bazel:test:windows-amd64 (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261) failed resolving toolchains for test_fips_flavor_{product_name,multiword,single_word}_inner with "No matching toolchains found for types: @@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS tests transition --platforms, and package_name_variables's unconditional find_cc_toolchain() then needs a cross C++ toolchain none of those hosts register, for fields these tests never check. package_naming.bzl gains flavor_naming_subject, a toolchain-free rule exposing just _inject_flavor()'s product_name, and the three FIPS tests now build against it instead of package_name_variables. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378) then failed in build_object_files's bazel test --platforms=//bazel/platforms:windows_x86_64_fips //pkg/ebpf:verify_generated_files with "While resolving toolchains for target //pkg/windowsdriver/procmon:types_godefs_test: No matching toolchains found for types: @@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin test toolchain requires the execution platform to match every constraint of the target platform, and no auto-detected host platform carries the artificial :fips constraint value now baked into --platforms. Reproduced the same failure locally against //bazel/platforms:linux_x86_64_fips, confirming it is not Windows-specific. MODULE.bazel now registers linux_x86_64_fips, linux_arm64_fips and windows_x86_64_fips (the platforms fips_platform_flag() can produce) as execution platforms too, so a fips build's own host still qualifies as its exec platform. ### Motivation rules_go's own toolchain selection is driven by --@rules_go//go/toolchain:sdk_name, matched via target_settings on its auto-generated toolchain() targets; deriving that flag from a custom one would need either patching go_transition (go_binary's rule() already claims the one incoming-transition slot Bazel allows) or hand-writing toolchain() registrations that duplicate rules_go's own exec/target platform matrix. platform_mappings avoids both: it is the native Bazel mechanism for mapping a --platforms value to other flag values, so this needs no patch and no duplicated toolchain logic. fips is orthogonal to flavor because omnibus's AgentFlavor enum, which packages/agent:flavor mirrored, conflates the two and makes a heroku or iot fips build unrepresentable; that conflation is legacy scaffolding being migrated away from, not a constraint worth carrying into new Bazel-only logic. Retiring "fips" as a flavor value without fixing its remaining callers would have left them silently building non-fips output: --//packages/agent:flavor=fips is no longer valid, but most of the affected builds never force analysis of the flavor flag itself, so the invalid value is dropped rather than rejected. ### Describe how you validated your changes Confirmed with cquery/aquery that --platforms=//bazel/platforms:linux_x86_64_fips resolves cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects requirefips/goexperiment.systemcrypto into its GoCompilePkg action, while a plain build with no flag resolves to @go_work_sdk and injects neither, both before and after moving platform_mappings under bazel/. Confirmed the same tags/toolchain split for cmd/dogstatsd and cmd/installer, and confirmed packages/agent/linux:debian (the actual .deb packaging target) and @openssl//:openssl analyze successfully under both configurations with no ambiguous select() matches. Reproduced the regression this fixes before fixing it: bazel test //packages/rules:* hard-failed on test_fips_flavor_product_name/multiword/single_word with "invalid value 'fips'", and cmd/installer silently resolved to @go_work_sdk with no fips tags under the retired flag. After the fix, the same test suite and tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and cmd/installer resolves to @msgo with the fips tags present. Confirmed the ambiguous-select error this design avoids is real by temporarily removing the exclusion and rebuilding, confirmed datadog-heroku-agent/datadog-agent package names are unaffected, and confirmed buildifier is clean on packages/agent/BUILD.bazel with no canonical-repository or other findings. Confirmed each of the four fixes above directly against real job traces fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed --raw, run on the host with no dev-env container), quoting the exact failures cited above. After the fixes, bazel run //bazel/buildifier:test is clean repo-wide, bazel mod tidy --lockfile_mode=off produces no diff, bazel test //packages/rules:* passes all 8 targets, tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips //cmd/agent:agent succeeds, with go version -m on the resulting binary still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the expected requirefips/goexperiment.systemcrypto tags. Confirmed windows_msi_and_bosh_zip_x64-a7-fips's fix too: bazel test --platforms=//bazel/platforms:linux_x86_64_fips //pkg/ebpf:verify_generated_files now passes locally with no --extra_execution_platforms override needed, and a plain (non-fips) bazel test //pkg/ebpf:verify_generated_files is unaffected. ### Additional Notes //:gazelle_binary built together with --platforms=...fips in the same invocation still inherits msgo, since nothing separates its configuration from cmd/agent's in that case. This is benign: cmd/agent's own build has no go_tool_transition-reached dependencies for msgo to leak into, and nobody invokes gazelle with a platform override in practice. cmd/agent and cmd/dogstatsd never force analysis of //packages/agent:flavor itself, so the retired --//packages/agent:flavor=fips invocation silently falls back to a non-fips build for them rather than erroring; that direction is safe, since BuiltForFIPS() correctly reports false rather than a false positive. Co-Authored-By: Claude Sonnet 5 <[email protected]>
ea7c3fe to
37220eb
Compare
### What does this PR do? Registers the Microsoft build of Go (msgo) as an additional toolchain and selects it for the agent's fips flavor through --platforms, via bazel/platform_mappings (wired in .bazelrc, since it is not at the default workspace-root location) mapping //bazel/platforms:linux_x86_64_fips to --@rules_go//go/toolchain:sdk_name=msgo. fips becomes an orthogonal //bazel/platforms:crypto constraint rather than a flavor value: packages/agent:flavor drops "fips" from its allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/ windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now match on that constraint instead of the flag. linux_fips is a plain config_setting repeating linux_default's criteria (base_flavor and linux) plus fips_flavor, rather than a sibling of it behind a selects.config_setting_group alias, so Bazel's own select() specialization rule (a match wins if its criteria are a strict superset of another match's) picks it automatically, with no separate exclusion needed. The @@ canonical-repository prefix is dropped from labels inside packages/agent/BUILD.bazel itself, since a plain // there already resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which is injected as a different repo's own root BUILD file and genuinely needs it. packages/rules/package_naming.bzl's product-name injection reads the same constraint directly (ctx.target_platform_has_constraint), since the flavor value it used to read can no longer be "fips". A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored in omnibus/lib/ostools.rb) computes the right --platforms=...fips value for the current host; every place that used to pass the retired --//packages/agent:flavor=fips now calls it instead, including the omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the cws-instrumentation, installer, security-agent, secret-generic-connector, otel-agent and process-agent invoke tasks. Also fixes four issues surfaced once CI ran on this PR (#56440). bazel:mod-tidy and bazel:run-buildifier-test (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528) failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries were single-line; buildifier wraps each sdks value and the experiments list, the same rule already applied to packages/agent/BUILD.bazel's linux_fips config_setting. Reformatted to match. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172) failed with "No fips platform for win32/AMD64": platform.machine() returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only had lowercase keys. Lower-cased the lookup. installer-fips-amd64-oci (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644) failed compiling msgo's own crypto/internal/backend/fips140/fips140.go with "undefined: systemFIPSMode" and "undefined: backendEnabled", right after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto." The failing action is go_tool_binary building msgo's own builder/pack/covdata tools, which has no C toolchain wired in. deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside systemcrypto, and a new rules_go patch (bazel/patches/rules_go-tool-binary-goexperiment.patch) threads sdk.experiments into that rule's own GOEXPERIMENT env, which go_tool_binary never set for either SDK. bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64 and bazel:test:windows-amd64 (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261) failed resolving toolchains for test_fips_flavor_{product_name,multiword,single_word}_inner with "No matching toolchains found for types: @@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS tests transition --platforms, and package_name_variables's unconditional find_cc_toolchain() then needs a cross C++ toolchain none of those hosts register, for fields these tests never check. package_naming.bzl gains flavor_naming_subject, a toolchain-free rule exposing just _inject_flavor()'s product_name, and the three FIPS tests now build against it instead of package_name_variables. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378) then failed in build_object_files's bazel test --platforms=//bazel/platforms:windows_x86_64_fips //pkg/ebpf:verify_generated_files with "While resolving toolchains for target //pkg/windowsdriver/procmon:types_godefs_test: No matching toolchains found for types: @@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin test toolchain requires the execution platform to match every constraint of the target platform, and no auto-detected host platform carries the artificial :fips constraint value now baked into --platforms. Reproduced the same failure locally against //bazel/platforms:linux_x86_64_fips, confirming it is not Windows-specific. Registering those platforms as execution platforms did fix that, but a follow-up push then broke bazel:test:windows-amd64 (a plain, non-fips job) with "no such target '@@toolchains_llvm++llvm+llvm_toolchain_llvm//:install-name-tool'": that registration also makes linux_x86_64_fips and linux_arm64_fips candidate execution platforms for unrelated toolchain resolution repo-wide, and //bazel/tools:install_name_tool's own select() on @platforms//os then picked the linux branch on a real Windows host, whose actual @llvm_toolchain_llvm archive naturally has no such target. Confirmed bazel:test:windows-amd64 passes on main's own latest pipeline, ruling out a pre-existing, unrelated cause. Replaced that with a toolchain() (bazel/platforms:fips_test_toolchain) registered for just @bazel_tools//tools/test:default_test_toolchain_type, restricted via target_compatible_with to :fips and without use_target_platform_constraints, exactly the override the toolchain_type's own no_match_error suggests; this registers no new execution platform at all. ### Motivation rules_go's own toolchain selection is driven by --@rules_go//go/toolchain:sdk_name, matched via target_settings on its auto-generated toolchain() targets; deriving that flag from a custom one would need either patching go_transition (go_binary's rule() already claims the one incoming-transition slot Bazel allows) or hand-writing toolchain() registrations that duplicate rules_go's own exec/target platform matrix. platform_mappings avoids both: it is the native Bazel mechanism for mapping a --platforms value to other flag values, so this needs no patch and no duplicated toolchain logic. fips is orthogonal to flavor because omnibus's AgentFlavor enum, which packages/agent:flavor mirrored, conflates the two and makes a heroku or iot fips build unrepresentable; that conflation is legacy scaffolding being migrated away from, not a constraint worth carrying into new Bazel-only logic. Retiring "fips" as a flavor value without fixing its remaining callers would have left them silently building non-fips output: --//packages/agent:flavor=fips is no longer valid, but most of the affected builds never force analysis of the flavor flag itself, so the invalid value is dropped rather than rejected. ### Describe how you validated your changes Confirmed with cquery/aquery that --platforms=//bazel/platforms:linux_x86_64_fips resolves cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects requirefips/goexperiment.systemcrypto into its GoCompilePkg action, while a plain build with no flag resolves to @go_work_sdk and injects neither, both before and after moving platform_mappings under bazel/. Confirmed the same tags/toolchain split for cmd/dogstatsd and cmd/installer, and confirmed packages/agent/linux:debian (the actual .deb packaging target) and @openssl//:openssl analyze successfully under both configurations with no ambiguous select() matches. Reproduced the regression this fixes before fixing it: bazel test //packages/rules:* hard-failed on test_fips_flavor_product_name/multiword/single_word with "invalid value 'fips'", and cmd/installer silently resolved to @go_work_sdk with no fips tags under the retired flag. After the fix, the same test suite and tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and cmd/installer resolves to @msgo with the fips tags present. Confirmed the ambiguous-select error this design avoids is real by temporarily removing the exclusion and rebuilding, confirmed datadog-heroku-agent/datadog-agent package names are unaffected, and confirmed buildifier is clean on packages/agent/BUILD.bazel with no canonical-repository or other findings. Confirmed each of the four fixes above directly against real job traces fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed --raw, run on the host with no dev-env container), quoting the exact failures cited above. After the fixes, bazel run //bazel/buildifier:test is clean repo-wide, bazel mod tidy --lockfile_mode=off produces no diff, bazel test //packages/rules:* passes all 8 targets, tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips //cmd/agent:agent succeeds, with go version -m on the resulting binary still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the expected requirefips/goexperiment.systemcrypto tags. Confirmed windows_msi_and_bosh_zip_x64-a7-fips's fix still holds with fips_test_toolchain in place: bazel test --platforms=//bazel/platforms:linux_x86_64_fips //pkg/ebpf:verify_generated_files and a plain (non-fips) bazel test //pkg/ebpf:verify_generated_files both pass locally, with no --extra_execution_platforms override needed and no new execution platform registered. ### Additional Notes //:gazelle_binary built together with --platforms=...fips in the same invocation still inherits msgo, since nothing separates its configuration from cmd/agent's in that case. This is benign: cmd/agent's own build has no go_tool_transition-reached dependencies for msgo to leak into, and nobody invokes gazelle with a platform override in practice. cmd/agent and cmd/dogstatsd never force analysis of //packages/agent:flavor itself, so the retired --//packages/agent:flavor=fips invocation silently falls back to a non-fips build for them rather than erroring; that direction is safe, since BuiltForFIPS() correctly reports false rather than a false positive. Co-Authored-By: Claude Sonnet 5 <[email protected]>
37220eb to
0280e9c
Compare
### What does this PR do? Register the Microsoft build of Go (msgo) as an additional toolchain and select it for the agent's fips flavor through --platforms, via bazel/platform_mappings (wired in .bazelrc, since it is not at the default workspace-root location) mapping //bazel/platforms:linux_x86_64_fips to --@rules_go//go/toolchain:sdk_name=msgo. Make fips an orthogonal //bazel/platforms:crypto constraint rather than a flavor value: drop "fips" from packages/agent:flavor's allowed values, and match fips_flavor/linux_x86_64_fips/linux_arm64_fips/windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows on that constraint instead of the flag. Define linux_fips as a plain config_setting repeating linux_default's criteria (base_flavor and linux) plus fips_flavor, rather than a sibling of it behind a selects.config_setting_group alias, so Bazel's own select() specialization rule (a match wins if its criteria are a strict superset of another match's) picks it automatically, with no separate exclusion needed. Drop the @@ canonical-repository prefix from labels inside packages/agent/BUILD.bazel itself, since a plain // there already resolves to the same repo; keep it in deps/openssl.BUILD.bazel, which is injected as a different repo's own root BUILD file and genuinely needs it. Read the same constraint directly in packages/rules/package_naming.bzl's product-name injection (ctx.target_platform_has_constraint), since the flavor value it used to read can no longer be "fips". Add a new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored in omnibus/lib/ostools.rb) that computes the right --platforms=...fips value for the current host, and call it wherever the retired --//packages/agent:flavor=fips used to be passed, including the omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the cws-instrumentation, installer, security-agent, secret-generic-connector, otel-agent and process-agent invoke tasks. Also fix four issues surfaced once CI ran on this PR (#56440). bazel:mod-tidy and bazel:run-buildifier-test (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528) failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries were single-line; buildifier wraps each sdks value and the experiments list, the same rule already applied to packages/agent/BUILD.bazel's linux_fips config_setting. Reformat to match. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172) failed with "No fips platform for win32/AMD64": platform.machine() returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only had lowercase keys. Lower-case the lookup. installer-fips-amd64-oci (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644) failed compiling msgo's own crypto/internal/backend/fips140/fips140.go with "undefined: systemFIPSMode" and "undefined: backendEnabled", right after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by setting GOEXPERIMENT=ms_nocgo_opensslcrypto." The failing action is go_tool_binary building msgo's own builder/pack/covdata tools, which has no C toolchain wired in. Set ms_nocgo_opensslcrypto alongside systemcrypto in deps/go.MODULE.bazel. go_tool_binary's missing GOEXPERIMENT forwarding was a rules_go bug, not something to patch locally: fixed upstream as bazel-contrib/rules_go#4717, now included by MODULE.bazel's rules_go pin, so no local patch is needed. bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64 and bazel:test:windows-amd64 (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446, https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261) failed resolving toolchains for test_fips_flavor_{product_name,multiword,single_word}_inner with "No matching toolchains found for types: @@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS tests transition --platforms, and package_name_variables's unconditional find_cc_toolchain() then needs a cross C++ toolchain none of those hosts register, for fields these tests never check. Add flavor_naming_subject to package_naming.bzl, a toolchain-free rule exposing just _inject_flavor()'s product_name, and build the three FIPS tests against it instead of package_name_variables. windows_msi_and_bosh_zip_x64-a7-fips (https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378) failed in build_object_files's bazel test --platforms=//bazel/platforms:windows_x86_64_fips //pkg/ebpf:verify_generated_files with "While resolving toolchains for target //pkg/windowsdriver/procmon:types_godefs_test: No matching toolchains found for types: @@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin test toolchain requires the execution platform to match every constraint of the target platform, and no auto-detected host platform carries the artificial :fips constraint value now baked into --platforms. Add a toolchain() (bazel/platforms:fips_test_toolchain) registered for just @bazel_tools//tools/test:default_test_toolchain_type, restricted via target_compatible_with to :fips and without use_target_platform_constraints, exactly the override the toolchain_type's own no_match_error suggests; this registers no new execution platform. ### Motivation rules_go's own toolchain selection is driven by --@rules_go//go/toolchain:sdk_name, matched via target_settings on its auto-generated toolchain() targets; deriving that flag from a custom one would need either patching go_transition (go_binary's rule() already claims the one incoming-transition slot Bazel allows) or hand-writing toolchain() registrations that duplicate rules_go's own exec/target platform matrix. platform_mappings avoids both: it is the native Bazel mechanism for mapping a --platforms value to other flag values, so this needs no patch and no duplicated toolchain logic. fips is orthogonal to flavor because omnibus's AgentFlavor enum, which packages/agent:flavor mirrored, conflates the two and makes a heroku or iot fips build unrepresentable; that conflation is legacy scaffolding being migrated away from, not a constraint worth carrying into new Bazel-only logic. Retiring "fips" as a flavor value is safe against a caller anyone forgets to update: every FIPS-tagged target's own gotags select() forces evaluation of //packages/agent:flavor, so passing the retired --//packages/agent:flavor=fips hard-errors at analysis time ("invalid value 'fips'") rather than silently building a mislabeled non-fips binary. ### Describe how you validated your changes --platforms=//bazel/platforms:linux_x86_64_fips resolves cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects requirefips/goexperiment.systemcrypto into its GoCompilePkg action, while a plain build with no flag resolves to @go_work_sdk and injects neither. The same tags/toolchain split holds for cmd/dogstatsd and cmd/installer, and packages/agent/linux:debian (the actual .deb packaging target) and @openssl//:openssl analyze successfully under both configurations with no ambiguous select() matches. bazel test //packages/rules:* (8 targets) and tasks/unit_tests/libs/build/bazel_tests.py (23 cases via pytest) both pass, cmd/installer resolves to @msgo with the fips tags present, datadog-heroku-agent/datadog-agent package names are unaffected, and bazel run //bazel/buildifier:test and bazel mod tidy --lockfile_mode=off are clean repo-wide with no diff. bazel build --platforms=//bazel/platforms:linux_x86_64_fips //cmd/agent:agent succeeds, with go version -m on the resulting binary showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the expected requirefips/goexperiment.systemcrypto tags. bazel test --platforms=//bazel/platforms:linux_x86_64_fips //pkg/ebpf:verify_generated_files and a plain (non-fips) bazel test //pkg/ebpf:verify_generated_files both pass locally, with no new execution platform registered. Co-Authored-By: Claude Sonnet 5 <[email protected]>
ac07444 to
8d6999c
Compare
### What does this PR do? Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in: - `bazel/prebuilt_buildtools.json`, - the corresponding `http_archive` in `MODULE.bazel` (invocation helpers). Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`. Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463). Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across matched files. ### Motivation Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]). At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**. The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it. ### Describe how you validated your changes `bazel run //bazel/buildifier` works on both Linux **and Windows**. ### Additional Notes `module-docstring` is suppressed in `.buildifier.json` for unrelated, pre-existing reasons predating this PR. [ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
### What does this PR do? Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in: - `bazel/prebuilt_buildtools.json`, - the corresponding `http_archive` in `MODULE.bazel` (invocation helpers). Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`. Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463). Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across matched files. ### Motivation Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]). At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**. The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it. ### Describe how you validated your changes `bazel run //bazel/buildifier` works on both Linux **and Windows**. ### Additional Notes `module-docstring` is suppressed in `.buildifier.json` for unrelated, pre-existing reasons predating this PR. [ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
### What does this PR do? Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in: - `bazel/prebuilt_buildtools.json`, - the corresponding `http_archive` in `MODULE.bazel` (invocation helpers). Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`. Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463). Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across matched files. ### Motivation Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]). At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**. The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it. ### Describe how you validated your changes `bazel run //bazel/buildifier` works on both Linux **and Windows**. ### Additional Notes `module-docstring` is suppressed in `.buildifier.json` for unrelated, pre-existing reasons predating this PR. [ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
…57078) ### What does this PR do? Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in: - `bazel/prebuilt_buildtools.json`, - the corresponding `http_archive` in `MODULE.bazel` (invocation helpers). Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`. Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463). ### Motivation Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]). At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**. The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it. ### Describe how you validated your changes `bazel run //bazel/buildifier` works on both Linux **and Windows**. ### Additional Notes This change was too large, leading to the extraction of following prerequisites: - #57087 - #57088 - #57090 [ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: regis.desgroppes <[email protected]>
8d6999c to
85feaca
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 lines. Bazel builds and tests were not run because the environment is read-only and network-restricted.
0311b31 to
d9157f1
Compare
d9157f1 to
95bddbb
Compare
4ed747b to
c466352
Compare
c466352 to
ee380eb
Compare
ee380eb to
b33124a
Compare
697e7a8 to
69bfbf8
Compare
### What does this PR do? Request FIPS builds with `--platforms=//bazel/platforms:<os>_<cpu>_fips`, whose `flags` select the `msgo` SDK, instead of the retired `fips` value of `//packages/agent:flavor`. Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names on the `//bazel/platforms:fips` constraint, and have the omnibus helpers pass the FIPS platform. Register a test toolchain so that `bazel test` works on FIPS platforms, and remove the unused macOS FIPS platforms. Have the installer's symbol test require `msgo`'s OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere. This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting #59511's guard against them, which depends on it. ### Motivation The FIPS platforms' constraint selected nothing, and the `fips` flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to block. Since #58511 made `msgo` a toolchain, the platform now carries both the constraint and the SDK choice. ### Describe how you validated your changes - `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS platforms, `requirefips` being Linux-only, and with the upstream SDK and no FIPS tags on the others, - the agent, installer, loader and packaging targets, and `@openssl`, analyze with no ambiguous `select()` on the Linux and Windows platforms, FIPS or not, - `bazel test` passes on a FIPS platform, - the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks. ### Additional Notes The retired flavor value now fails the analysis of packaging targets. `//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op, #58511's `msgo` SDK building its OpenSSL backend without cgo through `ms_nocgo_opensslcrypto`, the default of `msgo` 1.27 (https://devblogs.microsoft.com/go/go-1-27-0-1-microsoft-build-now-available/), leaving `dd_agent_go_binary`'s identical default. `//cmd/loader:trace_loader_all_files` only excludes Windows, like `:loader`, instead of listing Linux and macOS. Groundwork: - #56351 - #56865 - #57078 - #57223 - #58511 - #58530 - #59501 - #59511 - #59840 - #60181
69bfbf8 to
4b5adc0
Compare
What does this PR do?
Request FIPS builds with
--platforms=//bazel/platforms:<os>_<cpu>_fips, whoseflagsselect themsgoSDK, instead of the retiredfipsvalue of//packages/agent:flavor.Key the FIPS
config_settings,@openssl's and the FIPS package names on the//bazel/platforms:fipsconstraint, and have the omnibus helpers pass the FIPS platform.Register a test toolchain so that
bazel testworks on FIPS platforms, and remove the unused macOS FIPS platforms.Have the installer's symbol test require
msgo's OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere.💡 This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting #59511's guard against them, which will be addressed in:
--enable-bazelselect themsgotoolchain in FIPS mode #60204.Motivation
The FIPS platforms' constraint selected nothing, and the
fipsflavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to block.Since #58511 made
msgoa toolchain, the platform now carries both the constraint and the SDK choice.Describe how you validated your changes
//cmd/agentbuilds withmsgoand the FIPS tags on the FIPS platforms,requirefipsbeing Linux-only, and with the upstream SDK and no FIPS tags on the others,@openssl, analyze with no ambiguousselect()on the Linux and Windows platforms, FIPS or not,bazel testpasses on a FIPS platform,Additional Notes
The retired flavor value now fails the analysis of packaging targets.
//cmd/dogstatsddrops itscgoselect, whose FIPS branch was a no-op, #58511'smsgoSDK building its OpenSSL backend without cgo throughms_nocgo_opensslcrypto, the default ofmsgo1.27, leavingdd_agent_go_binary's identical default.//cmd/loader:trace_loader_all_filesonly excludes Windows, like:loader, instead of listing Linux and macOS.Groundwork:
rules_goto buildmsgoSDK withGOEXPERIMENT#56865buildtoolsforbuildozer'sset attr:exprcommands #57078rules_gofor more buildinfo &msgoSDK prereq #57223msgoSDK toolchain (FIPS prereq) #58511msgotoolchain #58530msgotelemetry by default in its Bazel SDK #59840linux_defaultwith the default Linux constraint #60181