Repository navigation
Description
Problem
tests/telemetry/test_sigterm_export.py::test_a_process_with_the_default_action_exports_then_ends_by_sigterm ran past the pytest-timeout of 600 s in Service Image Tests (shard 3 of 6) on the Renovate pull request #6028 (job 133581940030, run 43947275198, 2026-11-16 20:27Z). The pull request only updates certifi, so the test hangs or waits with no relation to the change.
Renovate merges a security fix only when every check of its branch passes (#6031), not only the required checks of the ruleset, so this one shard keeps the certifi security fix (#6028) from merging. A test that can wait 600 s is also a P0 case of the project rule on long checks.
Expected behavior
- Find why the test can wait 600 s: the child process does not end on SIGTERM, the exporter waits on an endpoint that the image test has not got, or the export timeout is longer than the test allows.
- The test ends in a few seconds or fails at once with the cause; its own timeouts nest inside the pytest timeout.
- Measure how often the test fails in the last 50 runs of
Service Image Tests.
Related
- fix(deps): update certifi to v2026.10.23 #6028, feat(deps): Merge each Renovate security fix after its checks #6031, fix(telemetry): a Job pod exports its metrics while it runs #5926 (Job pod periodic metric export).
Proposed design
Problem statement
The SIGTERM export test reads the child's readiness line from the child's pipe (tests/telemetry/test_sigterm_export.py:154), so it can wait for the pytest-timeout of 600 s. It sends SIGTERM only when that first line is exactly ready (:155-156). A child that prints another line first is never signalled, and the test then blocks in child.wait() (:158). The test has hung twice in Service Image Tests: run 43947275198 (2026-11-16 20:27Z) and run 43963262097 (2026-11-16 22:05Z). It kept the certifi security fix of pull request #6028 from merging, because Renovate merges a security fix only when every check of its branch passes (#6031). The change makes the test observe the readiness as an event, fail at once when the child ends early, and kill and reap the child on every path.
Acceptance criteria
Requirement: The readiness wait ends with the child's readiness event
The SIGTERM export test MUST observe the child's readiness as an event with wait_while_running from tests/support/waits.py, never with a blocking read of the child's pipe.
Scenario: A child that is slow to write its readiness line
- WHEN the child process stays alive and writes its readiness line later than
THREAD_HANDOFF_BOUND_SECONDS - THEN the test waits for the readiness event and carries no timeout of its own
Requirement: A child that ends before readiness fails at once
The SIGTERM export test MUST fail at once, naming the child's exit status and its recorded output, when the child ends before it writes its readiness line.
Scenario: A child that exits with an error before it is ready
- WHEN the child process ends before it writes its readiness line
- THEN the test fails without sending a signal, and the failure names the child's exit status and its recorded output
Requirement: The test kills and reaps its child
The SIGTERM export test MUST kill and reap the child process in a finally block on every path.
Scenario: A failing test leaves no child behind
- WHEN an assertion fails while the child process still runs
- THEN the child is killed and reaped before the test returns, and no
Popen.waitorThread.joincall in the test carries a numeric timeout
Requirement: The normal path keeps its assertions
The SIGTERM export test MUST assert the readiness line, the SIGTERM exit status and the exported metric signal on the normal path.
Scenario: A child that exports on SIGTERM
- WHEN the child writes its readiness line and the test sends SIGTERM
- THEN the test passes with the tuple
("ready", -signal.SIGTERM, [OtlpSignal.METRICS.value])
Existing Tool Considered
No alternatives check has run on this item. The need is a wait on a child's readiness that ends when the child becomes ready or exits. The project's own tests/support/waits.py covers the need: wait_while_running (tests/support/waits.py:52) has no bound of its own, so a slow start on a loaded host does not fail the test (tests/support/waits.py:18). It lacks a bound: a child that neither becomes ready nor exits still waits to the pytest-timeout of 600 s, which pytest-timeout==2.4.0 (pyproject.toml:115) gives. That tool names no wait and kills no child, so it stays the last-resort hang bound. The change builds no new code and adds no dependency, so its cost is zero tokens and zero elapsed time.
Key questions
- Why can the test wait 600 s?: Both waits of the test have no bound.
child.stdout.readline()(tests/telemetry/test_sigterm_export.py:154) blocks while the child is alive and has printed no line.child.wait()(:158) blocks while the child has not ended. The test sends SIGTERM only when the first stdout line is exactlyready(:155-156), so a child that prints another line first is never signalled and stays alive insignal.pause()(:60). The child's own SIGTERM path cannot be the cause: the handler exports on a thread and joins it for at most_EXPORT_SECONDS = 5.0(src/devops_cli/telemetry/sigterm_export.py:36,59), then sets the default action and re-raises SIGTERM (:63). The pytest-timeout of 600 s (pyproject.toml:235) is the only bound that ends the hang. [sources: tests/telemetry/test_sigterm_export.py:60, tests/telemetry/test_sigterm_export.py:154, tests/telemetry/test_sigterm_export.py:155, tests/telemetry/test_sigterm_export.py:158, src/devops_cli/telemetry/sigterm_export.py:36, src/devops_cli/telemetry/sigterm_export.py:59, src/devops_cli/telemetry/sigterm_export.py:63, pyproject.toml:235] - How does the test wait for the child's readiness and its exit, so that it ends in seconds and not 600 s?: Give the child a file for its stdout, as
tests/github/test_github_session.py:397-410does. Wait for the readiness line in that file withwait_while_running(condition, child)fromtests/support/waits.py:52. That wait has no bound of its own: it ends as soon as the line comes or the child exits. A loaded host that stretches the child's start no longer fails the test (tests/support/waits.py:18). A child that ends before the line makes the wait return False, so the test fails at once with the child's exit status and its recorded output. After the readiness line the test sends SIGTERM and waits for the exit withchild.wait(), also with no bound of its own. Afinallyblock kills and reaps the child on every path. The test adds no deadline of its own: a longer window is one that a loaded host can still exceed, and fix(tests): four tests that wait for a time window fail under host load #2092 rejected a longer bound as the fix. (best practice) [sources: tests/support/waits.py:18, tests/support/waits.py:52, tests/github/test_github_session.py:397, tests/commands/test_ci.py:2686, docs/TESTING.md:159, docs/TESTING.md:160, openspec/changes/archive/2026-10-31-2138-test-waits-events-process-exit/design.md:9]- Chosen: Read the readiness from a file the child writes, with
wait_while_running, and wait for the exit withchild.wait()and no bound.tests/support/waits.py:18gives a wait for an event of a process the test started no bound of its own, and the pattern already exists in this repository (tests/github/test_github_session.py:397-410,tests/commands/test_ci.py:2686-2696). - Rejected: An explicit few-second
Popen.wait(timeout=...)andThread.join(timeout)on each wait.docs/TESTING.md:159forbids a deadline of its own, and fix(tests): the remaining test waits end on an event or a process exit, not on a deadline of their own #2138 replaced literal 5 s and 10 s deadlines withTHREAD_HANDOFF_BOUND_SECONDS. A 1-2 s deadline failed correct code while a loaded host kept a ready thread waiting for a CPU (test(cli): tests wait for a background thread with one generous bound, not a 1-second deadline, so they pass under load #1664). - Rejected: Read the readiness line on a thread joined with
THREAD_HANDOFF_BOUND_SECONDS(30 s). It is still a fixed window on the start of a process the test started. fix(tests): four tests that wait for a time window fail under host load #2092 records a loaded host that stretched such a start pastTHREAD_HANDOFF_BOUND_SECONDS, and its design rejects a longer bound as the fix. - Rejected: A
@pytest.mark.timeout(N)mark on the test alone. pytest-timeout fails the test at the mark but names no wait and leaves the child to the test's own cleanup. A shorter mark still waits N seconds with no diagnostic.
- Chosen: Read the readiness from a file the child writes, with
- How often does the test fail in the last 50 runs of
Service Image Tests?: The owner answered this question. The test has now hung twice: run 43947275198 (job 133581940030, 2026-11-16 20:27Z, shard 3 of 6) and run 43963262097 (job 133637219622, 2026-11-16 22:05Z, shard 5 of 6). Both runs are on Renovate pull requests that touch no telemetry code, and the owner ran the second job again. The count does not change this change: it confirms a flake in the test's own waits, and the fix removes the unbounded wait. (a person decides)
Open questions
- How often does the test fail in the last 50 runs of
Service Image Tests? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 16, 2026
The test hangs for 600 s in CI and blocks the certifi security fix from merging.The failed run 43947275198 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.Both address test timeout behaviour in CI, but #4683 fixes the CI timeout configuration while this candidate fixes one test that hangs because its child process does not end on SIGTERM.devops-cli-service commentedon Nov 16, 2026
Owner question: How often does the test fail in the last 50 runs of
Service Image Tests? (a person decides)Options
Recommendation: Decide the question: only a person can answer it.
Evidence
dan-petty commentedon Nov 16, 2026
Second occurrence: the same test ran past the 600 s timeout in
Service Image Tests (shard 5 of 6)on the Renovate PR #6047, two times: job 133637219622 (22:05Z) and its re-run, job 133648554544 (22:21Z). That PR updates Python patch versions and renames two ty rules. The child uses a stub exporter with no HTTP library, so the change cannot cause the hang.Facts from the re-run:
child.wait()(line 158), so the child did not end after SIGTERM.-m live, about 17 s each).devops-cli-service commentedon Nov 16, 2026
Owner question: How often does the test fail in the last 50 runs of
Service Image Tests? (a person decides)Options
Recommendation: Decide the question: only a person can answer it.
Evidence