Skip to content

Harness: dump and stop a run that hangs anywhere, and upload the dump when CI times out - #129

Merged
HalRiveria merged 1 commit into
mainfrom
ci/harness-hang-dumps
Dec 3, 2026
Merged

HalRiveria merged 1 commit into
mainfrom
ci/harness-hang-dumps

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Independent of #127 and #128; merge it first, so their next CI runs have it.

What was wrong

#127's 5.1 Harness job hung in section AH's own checks of its case runner, which run in the harness's own process, not in a case. Only the cases have a time limit and a dump, so nothing caught it. The job ran into its 15-minute limit and ended cancelled, and the upload step (if: failure()) was skipped. There was no dump, and no way to tell where it hung.

Just before the hang, AH's check "a case that can't be stopped is cut off at its time limit" failed because the fresh powershell.exe ended at once with no output, and the message didn't say how it ended.

What changed

  • A watchdog for the harness itself. With PK_HARNESS_WATCHDOG_MINUTES set (both workflows set 2), the harness starts a watchdog process on its console. Every assertion and skip records that the run is still making progress. If no assertion has come for that long, the watchdog:

    • prints [FAIL] watchdog: ... with the last assertion;
    • writes a full dump of the harness into the dump folder;
    • lists the programs the harness had running;
    • kills the harness and its tree by PID, so the step fails.

    The longest gap between assertions in a CI log is about 19 s. Unset, nothing changes.

  • Per-step time limits. 14 minutes for each full harness step, 8 for the module sections, 16 for module.yml's; the harness jobs' limit is now 25 minutes.

  • Upload on cancellation too. The dump upload runs on failure() || cancelled().

  • Case runner fixes. Its Get-CimInstance has a 30 s limit. The "cut off at its time limit" check now gives the exit code and stderr of a case that ended by itself.

  • Code layout. Write-HarnessDump moved to the top of the harness, since the watchdog uses it too.

  • README. The Testing section mentions PK_HARNESS_WATCHDOG_MINUTES.

How it was tested

  • The watchdog firing. Forced with a short limit on section AP, it fired on Windows PowerShell 5.1 and PowerShell 7 alike: it printed the last assertion, wrote a full dump (about 360 MB), killed the harness, and the run exited 1.
  • Normal runs with PK_HARNESS_WATCHDOG_MINUTES=2, as on CI. The full harness passes on 5.1 and 7 (797 assertions each), and -AsModule -Section MODULE passes on both (309). The watchdog never fired and left no files behind.
  • The process listing. The watchdog's Get-CimInstance call (with -OperationTimeoutSec) was checked on its own on both runtimes.
  • Not verified: whether a step that hits its own timeout-minutes counts as failed or cancelled on GitHub. The upload condition covers both. Seeing it work on CI needs a real hang.

… when CI times out

A hang in the harness's own process, outside a section AH case, ran into the job's time limit with nothing to show: no time limit or dump covered it, and the job ended cancelled, which the upload step (failure only) skipped. A watchdog process now dumps the harness, lists its programs and kills it when no assertion has come for PK_HARNESS_WATCHDOG_MINUTES (2 on CI). Each harness step has its own time limit, the upload runs on cancellation too, the case runner's process listing has a time limit, and its self-check says how a case that ended by itself ended.
@HalRiveria
HalRiveria merged commit 441459b into main Dec 3, 2026
6 checks passed
@HalRiveria
HalRiveria deleted the ci/harness-hang-dumps branch December 3, 2026 15:45
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.

2 participants