Skip to content

test(telemetry): Stop the SIGTERM export test from hanging to 600 s - #6073

Merged
dan-petty merged 2 commits into
mainfrom
test/6048-sigterm-export-test-race
Nov 17, 2026
Merged

dan-petty merged 2 commits into
mainfrom
test/6048-sigterm-export-test-race

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The child of the SIGTERM export test waited for SIGTERM in signal.pause(). A SIGTERM that came after the last check for signals and before the pause system call set only the flag of the C handler, and the pause then waited for a second signal. The test hung to the 600 s bound of pytest-timeout in Service Image Tests and held the certifi security update of pull request #6028. The child now waits on the read end of its signal.set_wakeup_fd pipe, which the C handler writes, so a signal that comes before the read ends the wait too. The test waits for the line of the child with wait_while_running, sends SIGTERM after any line, and kills and reaps the child on each path. The product handler does not change.

Closes #6048

Change: openspec/changes/archive/2026-11-16-6048-sigterm-export-test-race/

Co-Authored-By: Claude [email protected]

@dan-petty dan-petty added type/test Type test: a new or changed test scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger labels Nov 16, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Evidence for the diagnosis and the fix (#6048).

The hang in CI. In the last 50 runs of Service Image Tests (all attempts), the test ran past the 600 s bound in 4 shard jobs: 133095388623 (schedule on main, 2026-11-16 04:39Z), 133581940030 (#6028), 133637219622 and 133648554544 (#6047). The test came in with #5926 on 2026-11-16 03:01Z, so it hung in 4 of the 8 completed run attempts since then. Each stack shows the test in child.wait() after it sent SIGTERM.

Reproduction (devcontainer, 16 CPUs, 24 children at a time). A script ran the child of the test, read ready, sent SIGTERM and waited 20 s:

Child Runs Hung
Old child, signal.pause() 600 41
Old child, a loop of time.sleep(0.05) in place of the pause (control) 800 0
New child, os.read on the signal.set_wakeup_fd pipe 1,200 0

Each hung child was in the kernel function __do_sys_pause, with SigCgt holding SIGTERM (bit 0x4000) and SigPnd, ShdPnd, SigBlk and SigIgn without it. So the kernel had delivered SIGTERM and the C handler had run, but the Python handler had not: no hung child had recorded an export. The pause had started after the signal.

The fixed test in the image. A manual run of Service Image Tests on this branch passed all 6 shards: run 43981764792. (The workflow does not run on a pull request that changes only tests.)

Locally. uv run devops ci test tests/telemetry/test_sigterm_export.py: 4 passed in 0.92 s.

@dan-petty
dan-petty marked this pull request as ready for review November 16, 2026 23:53
@dan-petty
dan-petty merged commit 04e1a8b into main Nov 17, 2026
29 checks passed
@dan-petty
dan-petty deleted the test/6048-sigterm-export-test-race branch November 17, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(telemetry): End the SIGTERM export test in seconds, not 600 s

1 participant