Skip to content

Wait for the agent to resolve container tags in origin detection tests - #7609

Open
ddmatan wants to merge 4 commits into
mainfrom
matan.perry/rerun-flaky-backend-checks
Open

Wait for the agent to resolve container tags in origin detection tests#7609
ddmatan wants to merge 4 commits into
mainfrom
matan.perry/rerun-flaky-backend-checks

Conversation

@ddmatan

@ddmatan ddmatan commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Origin detection tests fail intermittently with the trace present, on time, fully enriched — and only _dd.tags.container missing. The container is running fine, so it looks like a backend problem. It isn't.

That tag is attached by the agent, not the backend. The tracer sends only a container id (Datadog-Container-ID); the agent resolves it into tags through its tagger, which discovers containers asynchronously. It holds the payload up to 12s waiting for that, then sends the trace untagged and moves on. Nothing errors.

Where that comes from:

  • containers-tagging RFC in architecture — tracer sends the id, agent calls the tagger and attaches _dd.tags.container; the backend's only job is rewriting it into ddtags
  • datadog-agent/pkg/trace/agent/agent.gotagContainersTags, written from conf.ContainerTags(containerID)
  • datadog-agent/pkg/trace/containertags/buffer.gomaxBufferDuration = 12s, then shipped untagged
  • dd-go / dd-source only ever read the tag, never create it

So the test measures too early: we wait for the weblog port, but never for the agent. This waits for datadog-agent tagger-list to know the weblog containers before sending the request we measure.

Gotchas:

  • Best effort. If the tagger never catches up we send the request anyway and the assertion fails as it does today — this doesn't hide a regression, and it can't turn a test failure into a job timeout.
  • Only for origin_detection=True, and only on the SSH path (krunvm is untouched).
  • No containers running, or no docker on the VM → no wait, unchanged behavior.
  • Branch name is stale. This replaces the earlier pytest-rerunfailures approach; the net diff is the last commit only (34 lines, no new dependency).

@cbeauchesne this drops the retry logic entirely. On the mocked backend — I don't think it would have caught this particular failure, since the tag never reaches the backend in the first place. Happy to talk it through.

🤖 Written with Claude Code

A single onboarding test that fails on a backend verification currently
fails its CI job for good, and that job is a hard gate on the SSI release
pipeline. Re-running the job by hand fixes it, which is the signal that
these failures are not test results at all.

Re-run the failed test in place instead, on the VM that is already
provisioned, so a rerun costs seconds rather than a full re-provision.
Each rerun issues a new weblog request and therefore verifies a brand new
trace, which is what actually clears these flakes: re-reading the same
trace id never will, that trace is already complete.

`--only-rerun` keeps this narrow. A genuine injection regression still
fails on the first attempt. Backend timeouts are excluded too, since they
only fail after a 5 minute poll and re-running them would risk turning a
clean test failure into a job timeout.

To keep reruns honest, upload the onboarding JUnit report to Test
Optimization. The report was already being generated and archived, only
the upload was missing. Tests are tagged with the number of reruns they
needed, so a test that only passed because it was re-run stays visible
instead of disappearing behind a green job.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

docs/understand/scenarios/onboarding.md                                 @DataDog/system-tests-core
tests/auto_inject/utils.py                                              @DataDog/injection-platform

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 27, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 6 Pipeline jobs failed

DataDog/system-tests | Amazon_Linux_2023_amd64.INS: [test-app-dotnet-container] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/system-tests | Ubuntu_20_amd64.CHA: [test-app-dotnet] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/system-tests | Ubuntu_20_amd64.HOS: [test-app-dotnet] — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

View all 6 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f2cd3ad | Docs | View more details | Give us feedback!

The ci-runner tag is the sha256 of system-tests.Dockerfile + requirements.txt,
so adding pytest-rerunfailures changed it and build_ci_image failed the
CI_IMAGE-vs-computed-tag check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ddmatan
ddmatan marked this pull request as ready for review August 27, 2026 20:07
@ddmatan
ddmatan requested a review from a team as a code owner August 27, 2026 20:07

@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: 38e03eed0e

ℹ️ 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 .gitlab/ssi_gitlab-ci.yml Outdated
# scenario name, so a detached `--reruns 2` would be parsed as the scenario "2".
RERUN_ARGS=(--reruns=2 --reruns-delay=15
--only-rerun="failed to validate trace_id"
--only-rerun="Could not find runtime-id")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Match the actual missing-runtime-id failure

When a current backend trace omits the runtime-id tag entirely, utils/onboarding/backend_interface.py:85 raises KeyError: 'runtime-id' while indexing root_span["meta"]["runtime-id"]; execution never reaches the later Could not find runtime-id assertion. Consequently this filter does not rerun the common missing-tag case, so that backend flake can still block the SSI release. Either normalize the lookup to produce the intended assertion or include the actual exception in the rerun filter.

Useful? React with 👍 / 👎.

@natitsechanski natitsechanski left a comment

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.

shipit

@cbeauchesne cbeauchesne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for working on improving the reliability of these tests. However, I don’t think adding retry logic is the right direction here.

The underlying issue is that these scenarios depend on a real backend whose availability and performance we do not control. Retries may reduce the visible failure rate, but they do not address that design flaw. They would also add significant complexity to the framework and could hide genuine failures or make them slower to diagnose.

The known solution is to use a mocked backend that we control. I think our effort should go toward implementing that solution rather than building increasingly complex retry mechanisms around the current behavior (see https://datadoghq.atlassian.net/browse/APMSP-2478). We already have many bits in place, as we use a mocked backend for other scenarios. The biggest part will be the piping between SSI components, and this mock.

For those reasons, I don’t think we should move forward with this approach.

Origin detection asserts on `_dd.tags.container`, which the agent attaches
from its tagger, not the backend: the tracer sends only a container id.
The tagger discovers containers asynchronously, and the agent holds a
payload for at most 12s waiting for it before sending the trace untagged.
So a tagger that is slow to see the weblog container produces a trace with
nothing to assert on, and the test fails with the container running fine.

Wait for `datadog-agent tagger-list` to know the weblog containers before
sending the request we measure. Best effort: if it never catches up we send
the request anyway, so a real regression fails exactly as it does today.

Replaces the earlier pytest-rerunfailures approach, which waited for the
same thing by accident and needed a new dependency to do it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ddmatan
ddmatan requested a review from a team as a code owner August 28, 2026 14:50
@ddmatan ddmatan changed the title Rerun flaky backend verifications instead of failing the release Wait for the agent to resolve container tags in origin detection tests Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants