Skip to content

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

Closed

Description

@dan-petty

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

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.wait or Thread.join call 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 exactly ready (:155-156), so a child that prints another line first is never signalled and stays alive in signal.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-410 does. Wait for the readiness line in that file with wait_while_running(condition, child) from tests/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 with child.wait(), also with no bound of its own. A finally block 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]
  • 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

  1. added
    type/bug
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. 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.
    • Related: fix(ci): give the test row and the index build own timeouts #4683, which asks for a different change. 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.
  3. added
    scope/telemetry
    source/agent
    status/new
    effort/medium
    value/high
    priority/p1-high
    on Nov 16, 2026
  4. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Owner question: How often does the test fail in the last 50 runs of Service Image Tests? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  5. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor

    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:

    • The stack at the timeout shows the test in child.wait() (line 158), so the child did not end after SIGTERM.
    • The same test on the same branch passes 6 of 6 times in the devcontainer (-m live, about 17 s each).
    • So the hang occurs only in the service image test environment.
  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Owner question: How often does the test fail in the last 50 runs of Service Image Tests? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. added
    status/in-review
    and removed
    status/new
    on Nov 16, 2026
  8. removed
    status/in-review
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/telemetrysource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions