parametric: bump library client SIGTERM grace to drain gRPC/OTLP threads#7009
Open
mabdinur wants to merge 1 commit into
Open
parametric: bump library client SIGTERM grace to drain gRPC/OTLP threads#7009mabdinur wants to merge 1 commit into
mabdinur wants to merge 1 commit into
Conversation
Contributor
|
|
The previous ``container.stop(timeout=1)`` SIGKILLed parametric library clients after 1s. Under healthy conditions clients exit in well under that, but the rare ~1/1000 OTel logs/metrics flake (manifesting as the next test's container starting then exiting ~0.6s later) was consistent with mid-shutdown SIGKILLs leaving ddtrace/OTLP/gRPC background threads holding host ports, which then collide when the next test on the same xdist worker reuses the port allocation. This change parameterises ``docker_run`` with a ``stop_timeout`` argument (defaulting to 1s) and bumps it to 5s only for the parametric library client. The test agent fixture is unaffected and keeps the 1s cap, so the targeted ``test_otel_logs.py::Test_FR11_Telemetry::test_telemetry_exporter_configurations`` stays at the baseline ~6.2s per run locally; the larger cap only bites in the rare path where the client actually fails to drain on SIGTERM. Co-authored-by: Cursor <cursoragent@cursor.com>
d37757d to
812c6b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Rare (~1/1000) parametric flake where a test client container (e.g.
python-test-client-*) starts successfully then exits ~0.6s later. The failure surfaces asTimeout of 60 seconds exceeded waiting for HTTP server to startbecause the framework's poll loop treatsstatus == exitedthe same as "not ready yet" and keeps retrying. The flake is most often observed in OTel logs/metrics tests, which is whereddtrace'sgrpcintegration patch and the OTLP exporter background threads are most active.Example: dd-trace-py run 26044048099, job 76563345401.
Cause
docker_runwas callingcontainer.stop(timeout=1)for every container. 1s is enough for the test agent (no state to drain) but not for parametric library clients:ddtrace+ OTLP exporter + gRPC patch hold background threads that bind host ports. SIGKILLing them mid-shutdown leaves those host ports inTIME_WAIT, which collides with the next test on the same xdist worker (which reuses the port allocation4500 + worker_id).Fix
Parameterise
docker_runwith astop_timeoutargument (default 1s — keeps existing behaviour for the test agent and any other zero-state fixtures) and passstop_timeout=5from the parametric library client only.Test plan
passed in 6.21s / 6.19s / 6.22s / 6.39s / 6.28s— within the prior baseline of ~6.5s. The new 5s cap only activates when the client actually fails to drain on SIGTERM.tests.log: healthypython-test-client-*stop took ~454ms;ddapm-test-agent-*stop took ~1.5s. No regression on the happy path../format.shclean (mypy, ruff, yamllint, shellcheck).