Skip to content

fix(ci-visibility): harden Go retry edge cases#4731

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits into
mainfrom
feat/ci-visibility-bug-fixes
May 6, 2026
Merged

fix(ci-visibility): harden Go retry edge cases#4731
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits into
mainfrom
feat/ci-visibility-bug-fixes

Conversation

@tonyredondo

Copy link
Copy Markdown
Member

What does this PR do?

Fixes several Go CI Visibility edge cases found while reviewing retry, cleanup, coverage, and Git metadata handling after #4717 and #4722.

This PR updates Go test retry orchestration so cleanup failures behave like normal test failures. A cleanup panic is recorded on the failing attempt, cleanup Fatal / FailNow no longer escapes the retry loop through runtime.Goexit, and cleanups now run after Datadog-managed parallel subtests have completed so parent cleanup order remains consistent with Go's testing lifecycle.

It also fixes Orchestrion subtest panic handling when a Datadog retry wrapper owns the execution. In that case, subtest panics are recorded as failed attempts and returned to the retry owner, instead of immediately repanicking before retries can run.

Other fixes included here:

  • stop automatic flaky retries when the global retry budget reaches zero
  • protect benchmark instrumentation map writes with the write lock
  • synchronize coverage writer payload rotation between add and flush
  • report test.code_coverage.enabled=false when ITR is enabled but coverage is not actually active
  • avoid an index panic when Git reports a pack hash but the expected .pack file is missing

Motivation

The previous CI Visibility retry fixes addressed known lifecycle bugs, but a follow-up review found more cases where retry attempts could be misclassified, skipped, or allowed to race with shared state.

The highest-risk issues were in Go cleanup and Orchestrion subtest panic flows. Both are part of the real test result, so they need to pass through the same retry owner that handles failures in the test body. Without that, a cleanup failure could be hidden or abort retry orchestration, and a retryable subtest panic could fail the process before Datadog could schedule the next attempt.

The smaller fixes remove incorrect state reporting and race-prone code paths found during the same review.

Testing

  • go test ./internal/civisibility/integrations/gotesting/failnow -count=1
  • go test ./internal/civisibility/integrations/gotesting -count=1
  • go test ./internal/civisibility/integrations/gotesting/subtests -count=1
  • go test ./internal/civisibility/utils -run 'TestCreatePackFiles|TestGit|TestPackFiles' -count=1
  • go test -race ./internal/civisibility/integrations/gotesting/coverage -count=1
  • Bypass=true go test -race ./internal/civisibility/integrations/gotesting -run TestGetFieldPointerFrom -count=1
  • PATH="$(go env GOPATH)/bin:$PATH" GOFLAGS="-timeout=30m -tags=githubci,buildtag" go run github.com/DataDog/orchestrion go test -count=1 ./parallel_testing_retries
  • git diff --check main..HEAD

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

@codecov

codecov Bot commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.36735% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.04%. Comparing base (3e8a286) to head (f600ace).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...sibility/integrations/gotesting/instrumentation.go 75.43% 10 Missing and 4 partials ⚠️
...egrations/gotesting/instrumentation_orchestrion.go 8.33% 11 Missing ⚠️
...integrations/gotesting/coverage/coverage_writer.go 82.35% 2 Missing and 1 partial ⚠️
...nal/civisibility/integrations/gotesting/testing.go 57.14% 1 Missing and 2 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...ivisibility/integrations/gotesting/final_status.go 81.66% <100.00%> (-3.34%) ⬇️
...al/civisibility/integrations/gotesting/testingB.go 7.14% <100.00%> (+7.14%) ⬆️
internal/civisibility/utils/git.go 56.66% <100.00%> (-11.30%) ⬇️
...integrations/gotesting/coverage/coverage_writer.go 83.01% <82.35%> (-4.49%) ⬇️
...nal/civisibility/integrations/gotesting/testing.go 58.15% <57.14%> (-4.56%) ⬇️
...egrations/gotesting/instrumentation_orchestrion.go 28.19% <8.33%> (-5.34%) ⬇️
...sibility/integrations/gotesting/instrumentation.go 76.86% <75.43%> (-4.86%) ⬇️

... and 274 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official

datadog-official Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 65.93%
Overall Coverage: 61.38% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f600ace | Docs | Datadog PR Page | Give us feedback!

@tonyredondo
tonyredondo force-pushed the feat/ci-visibility-bug-fixes branch 2 times, most recently from 021fd12 to 1f3a7d5 Compare May 5, 2026 21:26
@pr-commenter

pr-commenter Bot commented May 5, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-05-06 10:04:32

Comparing candidate commit f600ace in PR branch feat/ci-visibility-bug-fixes with baseline commit 3e8a286 in branch main.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 268 metrics, 9 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:BenchmarkConfig/scenario_none-25

  • 🟩 execution_time [-16.286ns; -4.874ns] or [-6.703%; -2.006%]

@tonyredondo
tonyredondo marked this pull request as ready for review May 6, 2026 03:34
@tonyredondo
tonyredondo requested review from a team as code owners May 6, 2026 03:34

@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: 1f3a7d5160

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/civisibility/integrations/gotesting/instrumentation.go
@tonyredondo
tonyredondo force-pushed the feat/ci-visibility-bug-fixes branch from 1f3a7d5 to 5bdcd7e Compare May 6, 2026 05:07
@tonyredondo

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants