ci(molecule): stop a scenario that runs past its own time limit #475

Open
Claude wants to merge 2 commits from ci/474-scenario-timeout into main
pull from: ci/474-scenario-timeout
Owner

What and why

Closes #474

A Molecule scenario that hung held its lane until the job's 90-minute timeout. The cancel then lost every scenario's log, because the script prints the log groups only after all lanes finish.

Now each molecule test runs under timeout --foreground --kill-after=30, with a per-scenario limit of 1800 s that MOLECULE_SCENARIO_TIMEOUT overrides for local runs and tests. A hung scenario fails on its own while the job is still alive. Its log, with a timed out after N s line, prints in its group, and the lane goes on to the next scenario.

  • Why --foreground: it keeps timeout and molecule in the script's process group, so a cancel that kills the group still reaches them. Without it, test_a_killed_process_group_takes_its_lanes fails.
  • The cost: on expiry only molecule is signalled. Its ansible-playbook and workers keep running until the run container ends, and any container they recreate late is removed by the "Remove this run's containers" step. The script comment says so.
  • Why 1800 s: the longest scenario takes about 8.5 min, and at the default 2 lanes two hung scenarios plus the rest still end inside 90 min.
  • Rule update: the scenario-overlap rule in .gitea/workflows/AGENTS.md now covers the limit, with its Why and the two tests that hold it.

Verified

  • python3 -m unittest discover -s tests/scripts passes: 301 tests, run with the repo venv, which has molecule. The new tests are:
    • test_a_scenario_past_its_time_limit_fails_alone: on one lane, a stalled scenario is stopped after 2 s. It is reported failed with its partial log and the timed-out line, its container is removed, and the next scenario still runs, which shows the lane is freed.
    • test_the_default_time_limit_is_inside_the_job_timeout
    • test_the_time_limit_must_be_a_positive_integer
  • pre-commit run --all-files passes, and ansible-test sanity passed on push.
  • A clean-context review found nothing blocking. Its non-blocking points went into the second commit.

Not verified

  • A real hang in CI. The full Molecule run on this PR shows only that the wrapper does not break a passing run.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code

## What and why Closes #474 A Molecule scenario that hung held its lane until the job's 90-minute timeout. The cancel then lost every scenario's log, because the script prints the log groups only after all lanes finish. Now each `molecule test` runs under `timeout --foreground --kill-after=30`, with a per-scenario limit of 1800 s that `MOLECULE_SCENARIO_TIMEOUT` overrides for local runs and tests. A hung scenario fails on its own while the job is still alive. Its log, with a `timed out after N s` line, prints in its group, and the lane goes on to the next scenario. - **Why `--foreground`:** it keeps `timeout` and molecule in the script's process group, so a cancel that kills the group still reaches them. Without it, `test_a_killed_process_group_takes_its_lanes` fails. - **The cost:** on expiry only molecule is signalled. Its `ansible-playbook` and workers keep running until the run container ends, and any container they recreate late is removed by the "Remove this run's containers" step. The script comment says so. - **Why 1800 s:** the longest scenario takes about 8.5 min, and at the default 2 lanes two hung scenarios plus the rest still end inside 90 min. - **Rule update:** the scenario-overlap rule in `.gitea/workflows/AGENTS.md` now covers the limit, with its *Why* and the two tests that hold it. ## Verified - `python3 -m unittest discover -s tests/scripts` passes: 301 tests, run with the repo venv, which has molecule. The new tests are: - `test_a_scenario_past_its_time_limit_fails_alone`: on one lane, a stalled scenario is stopped after 2 s. It is reported failed with its partial log and the timed-out line, its container is removed, and the next scenario still runs, which shows the lane is freed. - `test_the_default_time_limit_is_inside_the_job_timeout` - `test_the_time_limit_must_be_a_positive_integer` - `pre-commit run --all-files` passes, and `ansible-test sanity` passed on push. - A clean-context review found nothing blocking. Its non-blocking points went into the second commit. ## Not verified - A real hang in CI. The full Molecule run on this PR shows only that the wrapper does not break a passing run. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code
Claude added this to the CI velocity (emergency) milestone 2026-11-29 11:58:49 +00:00
Claude added 2 commits 2026-11-29 11:58:50 +00:00
A hung scenario held its lane until the job's 90-minute timeout, and the
cancel then lost every scenario's log, since the groups print only after
the final wait. Each molecule test now runs under coreutils timeout with
MOLECULE_SCENARIO_TIMEOUT seconds (default 1800), so the hang fails by
itself, its log says it timed out, and the other lanes finish.

timeout runs with --foreground so it and molecule stay in the script's
process group: without it timeout leads a group of its own, which a
cancel that kills the step's group no longer reaches (the killed-group
test fails). On expiry molecule alone is signalled; anything it leaves
ends with the run container (docker run --init).

Closes #474

Assisted-by: Claude Code
ci(molecule): say what a scenario time limit leaves running
Build / build (pull_request) Successful in 31s
Molecule / molecule (pull_request) In progress
Lint / lint (pull_request) Successful in 3m27s
258cbaf516
A reader of the time limit needs to know its limits: on expiry only
molecule is signalled, so its ansible-playbook and workers run until the
run container ends, and the run-label cleanup step removes anything they
recreate. The default's reasoning holds at the default 2 lanes, and the
variable is for local runs and tests only.

The timeout test now runs on one lane, so beta running proves the stalled
lane was freed. The workflows rule gives the limit its reason and names
the two tests that hold it.

Refs #474

Assisted-by: Claude Code
CODEOWNERS rules requested review from Defame1297 2026-11-29 11:58:50 +00:00
Some checks are pending
Build / build (pull_request) Successful in 31s
Required
Details
Molecule / molecule (pull_request) In progress
Required
Details
Lint / lint (pull_request) Successful in 3m27s
Required
Details
Some required checks are missing.
This pull request has official review requests.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin ci/474-scenario-timeout:ci/474-scenario-timeout
git checkout ci/474-scenario-timeout
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#475