Sitelet https://github.com/DataDog/datadog-agent/pull/55347
Skip to content

Allow dd_agent_go_test's default target to take extra gotags - #55347

Closed
chouquette wants to merge 1 commit into
mainfrom
chouquette/bazel/test_extra_build_tags
Closed

Allow dd_agent_go_test's default target to take extra gotags#55347
chouquette wants to merge 1 commit into
mainfrom
chouquette/bazel/test_extra_build_tags

Conversation

@chouquette

Copy link
Copy Markdown
Contributor

What does this PR do?

Allow test targets to take an additional extra_gotags that gets added to all generated test targets.

Motivation

This allows us to get finer grain control over the test dependencies build tags. See #54846 for an existing use case

Describe how you validated your changes

The PR linked just above successfully builds by passing the kustomize_disable_go_plugin_support build tag when building sigs.k8s.io/kustomize/api

Additional Notes

extra_gotags gets added to all test targets, but isn't reflected in the
geerated per-tags tests naming.
@chouquette chouquette added changelog/no-changelog No changelog entry needed qa/no-code-change No code change in Agent code requiring validation labels Aug 25, 2026
@dd-octo-sts dd-octo-sts Bot added internal Identify a non-fork PR team/agent-build labels Aug 25, 2026
@github-actions github-actions Bot added the short review PR is simple enough to be reviewed quickly label Aug 25, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 37d0bed6:

Results for datadog-agent_7.84.0~devel.git.421.ee5f097.pipeline.132973537-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.84.0~devel.git.421.ee5f097.pipeline.132973537-1_amd64.deb:

No change detected

@dd-octo-sts

dd-octo-sts Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 37d0bed
📊 Static Quality Gates Dashboard
🔗 SQG Job

33 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_deb_amd64 760.911 MiB
agent_deb_amd64_fips 713.693 MiB
agent_heroku_amd64 312.817 MiB
agent_msi 647.700 MiB
agent_rpm_amd64 760.895 MiB
agent_rpm_amd64_fips 713.677 MiB
agent_rpm_arm64 736.808 MiB
agent_rpm_arm64_fips 692.908 MiB
agent_suse_amd64 760.895 MiB
agent_suse_amd64_fips 713.677 MiB
agent_suse_arm64 736.808 MiB
agent_suse_arm64_fips 692.908 MiB
docker_agent_amd64 819.514 MiB
docker_agent_arm64 820.478 MiB
docker_agent_jmx_amd64 1010.412 MiB
docker_agent_jmx_arm64 1000.028 MiB
docker_cluster_agent_amd64 211.376 MiB
docker_cluster_agent_arm64 224.458 MiB
docker_cws_instrumentation_amd64 7.443 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.483 MiB
docker_dogstatsd_arm64 37.623 MiB
docker_host_profiler_amd64 306.802 MiB
docker_host_profiler_arm64 318.045 MiB
dogstatsd_deb_amd64 30.224 MiB
dogstatsd_deb_arm64 28.255 MiB
dogstatsd_rpm_amd64 30.224 MiB
dogstatsd_suse_amd64 30.224 MiB
iot_agent_deb_amd64 46.503 MiB
iot_agent_deb_arm64 43.159 MiB
iot_agent_deb_armhf 43.953 MiB
iot_agent_rpm_amd64 46.503 MiB
iot_agent_suse_amd64 46.502 MiB

@chouquette
chouquette marked this pull request as ready for review August 25, 2026 07:52
@chouquette
chouquette requested a review from a team as a code owner August 25, 2026 07:52
@github-actions github-actions Bot deleted a comment from chatgpt-codex-connector Bot Aug 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee5f097caf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


def dd_agent_go_test(
name,
extra_gotags = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove extra_gotags when reverting to go_test

When a package using extra_gotags is placed under # gazelle:dd_agent_go_test off, revertDdAgentGoTests in bazel/rules/go/_gazelle_extension.go:278-289 converts the call to a plain go_test but only removes include_default and gotags_sets. The new macro-only attribute therefore remains on the generated go_test, which does not accept extra_gotags, leaving the BUILD file unable to analyze; delete this attribute during the reversion and cover the transition in the Gazelle extension tests.

Useful? React with 👍 / 👎.

Comment on lines 101 to 104
def dd_agent_go_test(
name,
extra_gotags = None,
gotags_sets = None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record the mandatory buildifier validation

The commit modifies a .bzl file, but its validation section only records a downstream build and provides no evidence that bazel run //bazel/buildifier was run. Run the repository formatter and record that validation before merging. bazel/codereview_guideline.mdL9-L13

Useful? React with 👍 / 👎.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 7af6a957-22a4-4d4a-a47c-5818c0fc8d70

Baseline: 37d0bed
Comparison: ee5f097
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_private_action_runner memory utilization +0.84 [+0.72, +0.96] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization +0.16 [-0.08, +0.40] 1 Logs
quality_gate_security_idle memory utilization +0.12 [+0.07, +0.16] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization +0.05 [+0.01, +0.08] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization -0.01 [-0.05, +0.03] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization -0.09 [-0.13, -0.05] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization -0.15 [-0.35, +0.05] 1 Logs
quality_gate_logs % cpu utilization -0.18 [-1.06, +0.71] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.25 [-0.33, -0.16] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization -0.95 [-1.18, -0.72] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 172.76MiB ≤ 178MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 747.89KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 521.30MiB ≤ 538MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.14MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 19 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 217.83MiB ≤ 229MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 263.41MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 352.65 ≤ 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 401.62MiB ≤ 453MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 73.24MiB ≤ 76MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 25.68 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 324.86MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 60.36 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 305.67MiB ≤ 314MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 21.23 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 311.49MiB ≤ 343MiB 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:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. 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.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates 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.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_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_logs, bounds check intake_connections: 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_mean_fs_load, bounds check cpu_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_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check 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, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.

Comment on lines +56 to +57
if extra_gotags:
tags = tags | set(extra_gotags)

@rdesgroppes rdesgroppes Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra_gotags (and gotags generally) is implemented in rules_go via a Starlark configuration transition, which forks the Bazel configuration for the entire transitive closure of the target's deps/embed, not just the target itself.
That means every helm_test call site that sets extra_gotags =["kustomize_disable_go_plugin_support"] builds sigs.k8s.io/kustomize/api (and everything under it) in a configuration that's isolated from whatever configuration any other target in the repo uses to build the same packages, so there is no action-cache sharing between them.

Since extra_gotags merges into every gotags_sets variant as well as the default target, that fork multiplies across all variants of a given dd_agent_go_test call, all under the same target name. gotags_sets at least makes its fan-out visible via a separate name_<suffix> target.

We're separately chasing Bazel analysis-cache thrashing (#53850, #54963, #55097), so I'd rather this PR avoid adding a new source of configuration forking if we can help it.

There is an alternative that avoids the fork entirely: patch sigs.k8s.io/kustomize/api at the source via go_deps.module_override in deps/go.MODULE.bazel, the same mechanism already used for msgp, godror, coreos/go-systemd, and favadi/protoc-go-inject-tag.
Since internal/plugins/loader/load_go_plugin.go is guarded by //go:build !kustomize_disable_go_plugin_support, with load_go_plugin_disabled.go as the stub fallback, a small patch flipping that constraint (or deleting the plugin-enabled file and dropping the constraint on the stub) makes the disabled behavior unconditional for every consumer, in every configuration, with no gotags/extra_gotags involved and no configuration fork: every target that transitively depends on kustomize/api shares one compiled artifact.

Worth noting: nothing in the repo imports sigs.k8s.io/kustomize/api directly today (go.mod/go.sum show it only as an indirect dependency of test/e2e-framework and test/new-e2e), so nobody exercises its native Go-plugin loading, so patching it unconditionally off should be very low risk.
The only trade-off is that the patch might fail on kustomize version bumps, but that applies to all existing patches in deps/go.MODULE.bazel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the review and the (very) detailed comment.

I didn't consider patching the package at all, but I agree, it works equally well for our purpose with less side effects, I'll get to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we may not need a patch in the sense of file. Let me check...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I meant patching as in "modifying the package" not necessarily a .patch file or similar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we won't need to change the dd_agent_go_test rule, this PR is moot and I'll close it. I'll push the patch approach directly into #54846

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That matches what I had locally (except that instead of removing the file from srcs I gated it with an ignore build tag) but I'm waiting on the target PR to reappear before pushing

@github-actions github-actions Bot added medium review PR review might take time and removed short review PR is simple enough to be reviewed quickly labels Aug 25, 2026
@chouquette chouquette closed this Aug 25, 2026
@chouquette
chouquette deleted the chouquette/bazel/test_extra_build_tags branch August 25, 2026 12:27
chouquette pushed a commit that referenced this pull request Aug 25, 2026
### What does this PR do?
Patch `sigs.k8s.io/kustomize/api` to always select its Go-plugin
disabled loader stub, instead of adding a per-target `extra_gotags`
escape hatch to `dd_agent_go_test` (#55347).

### Motivation
`kustomize/api`'s plugin loader forces `-Wl,-z,nocopyreloc` on the
linker, breaking `github.com/DataDog/zstd`'s copy-relocation-dependent
cgo (#54846).

#55347 fixes this per test target via `extra_gotags`, but it also flags
that the fix is scoped to one target and the same conflict could recur
for any future target combining `kustomize/api` with another
copy-relocation-sensitive cgo dependency.

Patching `kustomize/api` once, at the dependency level, closes that gap
instead of requiring every future consumer to rediscover and reapply the
same workaround.

### Describe how you validated your changes
Built and ran a throwaway target embedding both `kustomize/api`'s
`krusty` package and `zstd` with `bazel test`, with no `gotags`
override, reproducing and then confirming the fix for the original
link failure.
The patch applies without exposing `io_k8s_sigs_kustomize_api` via
`use_repo`, matching how #54846's `helm_test` actually reaches it:
transitively, through `sh_helm_helm_v3`.

### Additional Notes
Alas, a `gazelle:build_tags` and `gazelle:exclude` combination **does
not work**, since `rules_go`'s compile-time constraint filter
re-evaluates `//go:build` tags against each consumer's real `gotags`,
independent of what `gazelle` wrote into `srcs`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time qa/no-code-change No code change in Agent code requiring validation team/agent-build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants