ci(molecule): isolate Molecule runs per run and stop running Molecule on push to main #166

Closed
opened 2026-11-15 14:29:04 +00:00 by Claude · 9 comments
Owner

Spec: Molecule and Renovate on the shared runner: isolation, capacity and cost, resolution items 1, 3, 6 and 7. This replaces the earlier spec from CI image pipeline section 7. A shared concurrency group cancels a waiting run and stalls its pull request's required check, so it is not used. Scope was added from What Molecule proves before a merge, and who acts on the nightly run. This issue is blocked by ci(molecule): run Molecule with the toolchain baked into the ci image instead of the runner's venv, which changes the job's shape first, and it waits on the contributor-doc split (#189) and on docs(agents): replace CLAUDE.md with a root AGENTS.md: put the text edits below in the root or nested AGENTS.md, not in CLAUDE.md or CONTRIBUTING.md where those are replaced.

What

  • Name and label containers per run: every platform name of every scenario takes a per-run prefix (for example ${KAMINO_RUN_ID:-local}-ufw-instance), the second and third platforms included (those that the platforms issue and the Debian 13 molecule image issue add, if they landed first), and a label carrying the run id. The workflow sets KAMINO_RUN_ID (for example from github.run_id and the attempt, passed through env:) and passes it into the docker run container that holds Molecule. A local run without it gets the local- prefix. The docker run container gets the per-run name and label too.
  • Clean up only your own run: an always() step removes this run's labelled containers, the docker run container included. The pre-run sweep removes only labelled containers older than the job timeout (30 min), never the containers of a run beside it, and never anything unlabelled.
  • Keep the per-pull-request cancel groups; there is no shared Molecule group. Rewrite the concurrency: comment in molecule.yml: two runs can now overlap safely.
  • Remove the push: trigger on main from molecule.yml, paths: filter included. Nightly and workflow_dispatch keep running every scenario. Update the agent-instructions text that says every push to main runs every scenario.
  • Fix the selector docstring at scripts/select_molecule_scenarios.py:32-33 ("The scenarios the selection skips are not skipped on main: the push run after the merge runs them all"). The skipped scenarios now run in the nightly and in manual dispatch.
  • Lint and Build lose their push trigger on main. Remove push: branches: [main] from .gitea/workflows/lint.yml and .gitea/workflows/build.yml. Build keeps push: tags: ['v*'] and workflow_dispatch; Lint keeps workflow_dispatch.
    • Reason: the publish job's checks run inside release.yml.
    • Reason: "Block on outdated branch" means main only ever receives a tree its pull request already tested.
    • Simplify the two concurrency.group expressions to match.

Then (maintainer)

The runner capacity is raised in a separate issue, outside this repository: chore: raise the CI runner's capacity to 2 and record the memory headroom. The memory headroom is measured by the maintainer on the host; the job log does not print host sizing.

Acceptance

  • Two Molecule runs started together (for example two dispatches) both finish green on capacity 1 one after the other, with no shared container names.
  • A cancelled run's containers are removed by the next run's sweep only after the timeout, or by its own always() step.
  • Cancel a run mid-scenario and check that docker ps shows no container of that run after the cleanup step (not tested yet: whether a cancelled step leaves the docker run container running).
  • A push to main starts no Molecule, Lint or Build run; nightly and dispatch run every scenario.

Notes

ci(molecule): open an issue when the nightly full run fails and close it on the next green one is blocked by this issue, because both edit molecule.yml.

Spec: [Molecule and Renovate on the shared runner: isolation, capacity and cost](https://git.rkdr.net/Mortis/Kamino/issues/212), resolution items 1, 3, 6 and 7. This replaces the earlier spec from [CI image pipeline](https://git.rkdr.net/Mortis/Kamino/issues/96) section 7. A shared concurrency group cancels a waiting run and stalls its pull request's required check, so it is not used. Scope was added from [What Molecule proves before a merge, and who acts on the nightly run](https://git.rkdr.net/Mortis/Kamino/issues/256). This issue is blocked by [ci(molecule): run Molecule with the toolchain baked into the ci image instead of the runner's venv](https://git.rkdr.net/Mortis/Kamino/issues/225), which changes the job's shape first, and it waits on the contributor-doc split (#189) and on [docs(agents): replace CLAUDE.md with a root AGENTS.md](https://git.rkdr.net/Mortis/Kamino/issues/185): put the text edits below in the root or nested `AGENTS.md`, not in `CLAUDE.md` or `CONTRIBUTING.md` where those are replaced. ## What - **Name and label containers per run:** every platform name of every scenario takes a per-run prefix (for example `${KAMINO_RUN_ID:-local}-ufw-instance`), the second and third platforms included (those that [the platforms issue](https://git.rkdr.net/Mortis/Kamino/issues/133) and [the Debian 13 molecule image issue](https://git.rkdr.net/Mortis/Kamino/issues/226) add, if they landed first), and a label carrying the run id. The workflow sets `KAMINO_RUN_ID` (for example from `github.run_id` and the attempt, passed through `env:`) and passes it into the `docker run` container that holds Molecule. A local run without it gets the `local-` prefix. The `docker run` container gets the per-run name and label too. - **Clean up only your own run:** an `always()` step removes this run's labelled containers, the `docker run` container included. The pre-run sweep removes only labelled containers older than the job timeout (30 min), never the containers of a run beside it, and never anything unlabelled. - **Keep the per-pull-request cancel groups;** there is no shared Molecule group. Rewrite the `concurrency:` comment in `molecule.yml`: two runs can now overlap safely. - **Remove the `push:` trigger on `main`** from `molecule.yml`, `paths:` filter included. Nightly and `workflow_dispatch` keep running every scenario. Update the agent-instructions text that says every push to `main` runs every scenario. - **Fix the selector docstring** at `scripts/select_molecule_scenarios.py:32-33` ("The scenarios the selection skips are not skipped on `main`: the push run after the merge runs them all"). The skipped scenarios now run in the nightly and in manual dispatch. - **Lint and Build lose their push trigger on `main`.** Remove `push: branches: [main]` from `.gitea/workflows/lint.yml` and `.gitea/workflows/build.yml`. Build keeps `push: tags: ['v*']` and `workflow_dispatch`; Lint keeps `workflow_dispatch`. - Reason: the publish job's checks run inside `release.yml`. - Reason: "Block on outdated branch" means `main` only ever receives a tree its pull request already tested. - Simplify the two `concurrency.group` expressions to match. ## Then (maintainer) The runner capacity is raised in a separate issue, outside this repository: [chore: raise the CI runner's capacity to 2 and record the memory headroom](https://git.rkdr.net/Mortis/Kamino/issues/243). The memory headroom is measured by the maintainer on the host; the job log does not print host sizing. ## Acceptance - Two Molecule runs started together (for example two dispatches) both finish green on capacity 1 one after the other, with no shared container names. - A cancelled run's containers are removed by the next run's sweep only after the timeout, or by its own `always()` step. - Cancel a run mid-scenario and check that `docker ps` shows no container of that run after the cleanup step (not tested yet: whether a cancelled step leaves the `docker run` container running). - A push to `main` starts no Molecule, Lint or Build run; nightly and dispatch run every scenario. ## Notes [ci(molecule): open an issue when the nightly full run fails and close it on the next green one](https://git.rkdr.net/Mortis/Kamino/issues/270) is blocked by this issue, because both edit `molecule.yml`.
Claude added the
Status
Ready for Agent
label 2026-11-15 14:29:04 +00:00
Claude added a new dependency 2026-11-15 22:20:53 +00:00
Claude added this to the Continuous delivery milestone 2026-11-15 22:21:20 +00:00
Author
Owner

Order: this now waits on the contributor-doc split (#189) where it edits CONTRIBUTING.md, and on docs(agents): replace CLAUDE.md with a root AGENTS.md (#185): put the CLAUDE.md edits in the root or nested AGENTS.md instead. (From Order of the implementation backlog, #198.)

Order: this now waits on the contributor-doc split (#189) where it edits `CONTRIBUTING.md`, and on docs(agents): replace CLAUDE.md with a root AGENTS.md (#185): put the `CLAUDE.md` edits in the root or nested `AGENTS.md` instead. (From Order of the implementation backlog, #198.)
Claude changed title from ci(molecule): run Molecule two-wide safely and select scenarios on push to main to ci(molecule): isolate Molecule runs per run and stop running Molecule on push to main 2026-11-17 10:15:57 +00:00
Author
Owner

Rewritten from Molecule and Renovate on the shared runner: isolation, capacity and cost: isolation per run instead of one shared group, and no Molecule on push to main (so no diff selection on main). Blocked by ci(molecule): run Molecule with the toolchain baked into the ci image instead of the runner's venv, which changes the job's shape first: pass KAMINO_RUN_ID into the docker run container. The maintainer's capacity raise is chore: raise the CI runner's capacity to 2 and record the memory headroom.

Rewritten from [Molecule and Renovate on the shared runner: isolation, capacity and cost](https://git.rkdr.net/Mortis/Kamino/issues/212): isolation per run instead of one shared group, and no Molecule on push to `main` (so no diff selection on `main`). Blocked by [ci(molecule): run Molecule with the toolchain baked into the ci image instead of the runner's venv](https://git.rkdr.net/Mortis/Kamino/issues/225), which changes the job's shape first: pass `KAMINO_RUN_ID` into the `docker run` container. The maintainer's capacity raise is [chore: raise the CI runner's capacity to 2 and record the memory headroom](https://git.rkdr.net/Mortis/Kamino/issues/243).
Author
Owner

Review of the map (2026-11-17).

  • Also rewrite scripts/select_molecule_scenarios.py:26-27, which says "the push run after the merge runs them all". After this issue the nightly and a manual dispatch are the only runs of the scenarios a pull request did not select.
  • The docker run container that holds Molecule gets the per-run name and label too, and the always() step and the sweep remove it. Not tested: whether a cancelled step leaves that container running. Acceptance addition: cancel a run mid-scenario and check that docker ps shows no container of that run after the cleanup step.
  • The step that prints free -m and nproc puts host sizing into a job log. Whether that is wanted is open in Does the stand-alone rule cover issue text and job logs.
  • Who acts on a red nightly is open in What Molecule proves before a merge, and who acts on the nightly run.
Review of the map (2026-11-17). - Also rewrite `scripts/select_molecule_scenarios.py:26-27`, which says "the push run after the merge runs them all". After this issue the nightly and a manual dispatch are the only runs of the scenarios a pull request did not select. - The `docker run` container that holds Molecule gets the per-run name and label too, and the `always()` step and the sweep remove it. Not tested: whether a cancelled step leaves that container running. Acceptance addition: cancel a run mid-scenario and check that `docker ps` shows no container of that run after the cleanup step. - The step that prints `free -m` and `nproc` puts host sizing into a job log. Whether that is wanted is open in [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253). - Who acts on a red nightly is open in [What Molecule proves before a merge, and who acts on the nightly run](https://git.rkdr.net/Mortis/Kamino/issues/256).
Author
Owner

Correction from Does the stand-alone rule cover issue text and job logs (2026-11-20): drop the step that prints free -m and nproc. Job output is public, and host sizing stays out of it. The memory headroom is measured by the maintainer on the host (#243).

Correction from [Does the stand-alone rule cover issue text and job logs](https://git.rkdr.net/Mortis/Kamino/issues/253) (2026-11-20): drop the step that prints `free -m` and `nproc`. Job output is public, and host sizing stays out of it. The memory headroom is measured by the maintainer on the host (#243).
Author
Owner

Scope added from What Molecule proves before a merge, and who acts on the nightly run (2026-11-20)

  • Lint and Build lose their push trigger on main. Remove push: branches: [main] from .gitea/workflows/lint.yml and .gitea/workflows/build.yml. Build keeps push: tags: ['v*'] and workflow_dispatch; Lint keeps workflow_dispatch.
    • Reason: the publish job's checks run inside release.yml.
    • Reason: "Block on outdated branch" means main only ever receives a tree its pull request already tested.
    • Simplify the two concurrency.group expressions to match.
  • Fix the selector docstring at scripts/select_molecule_scenarios.py:32-33 ("The scenarios the selection skips are not skipped on main: the push run after the merge runs them all"). The skipped scenarios now run in the nightly and in manual dispatch.
  • ci(molecule): open an issue when the nightly full run fails and close it on the next green one is blocked by this issue, because both edit molecule.yml.
## Scope added from [What Molecule proves before a merge, and who acts on the nightly run](https://git.rkdr.net/Mortis/Kamino/issues/256) (2026-11-20) - **Lint and Build lose their push trigger on `main`.** Remove `push: branches: [main]` from `.gitea/workflows/lint.yml` and `.gitea/workflows/build.yml`. Build keeps `push: tags: ['v*']` and `workflow_dispatch`; Lint keeps `workflow_dispatch`. - Reason: the publish job's checks run inside `release.yml`. - Reason: "Block on outdated branch" means `main` only ever receives a tree its pull request already tested. - Simplify the two `concurrency.group` expressions to match. - **Fix the selector docstring** at `scripts/select_molecule_scenarios.py:32-33` ("The scenarios the selection skips are not skipped on `main`: the push run after the merge runs them all"). The skipped scenarios now run in the nightly and in manual dispatch. - [ci(molecule): open an issue when the nightly full run fails and close it on the next green one](https://git.rkdr.net/Mortis/Kamino/issues/270) is blocked by this issue, because both edit `molecule.yml`.
Author
Owner

Body rewritten on 2026-11-20 to the final state of the comments above (final validation round of the map, #87 (comment)). The body is the spec; the earlier comments are history.

  • No decision of that round changes this issue; the rewrite was needed because the comments had superseded the body. It removes the "print memory" step (free -m, nproc) and its acceptance line (the comment from #253), moves the CLAUDE.md edits to AGENTS.md, and folds in the docker run container naming, the cancelled-run acceptance, the selector docstring fix and the Lint/Build push-trigger removal.
Body rewritten on 2026-11-20 to the final state of the comments above (final validation round of the map, https://git.rkdr.net/Mortis/Kamino/issues/87#issuecomment-12281). The body is the spec; the earlier comments are history. - No decision of that round changes this issue; the rewrite was needed because the comments had superseded the body. It removes the "print memory" step (`free -m`, `nproc`) and its acceptance line (the comment from #253), moves the `CLAUDE.md` edits to `AGENTS.md`, and folds in the `docker run` container naming, the cancelled-run acceptance, the selector docstring fix and the Lint/Build push-trigger removal.
Author
Owner

Final validation round, second pass (2026-11-20): body edited.

  • The per-run prefix now covers every platform name of every scenario, including the second and third platforms that the platforms issue (#133) and the Debian 13 image issue (#226) add if they land first.
  • Dropped the second selector docstring fix at lines 26-27: the sentence "the push run after the merge runs them all" exists only once, at lines 32-33 of scripts/select_molecule_scenarios.py (verified by grep).
Final validation round, second pass (2026-11-20): body edited. - The per-run prefix now covers every platform name of every scenario, including the second and third platforms that the platforms issue (#133) and the Debian 13 image issue (#226) add if they land first. - Dropped the second selector docstring fix at lines 26-27: the sentence "the push run after the merge runs them all" exists only once, at lines 32-33 of `scripts/select_molecule_scenarios.py` (verified by grep).
Claude modified the milestone from Continuous delivery to CI velocity (emergency) 2026-11-23 20:55:58 +00:00
Author
Owner

Unblocked: #225 is merged (#345, #348). The Molecule job now has this shape; build on it.

  • The run: the host job runs docker run --rm -i --init on the pinned ci image. Inside, scripts/run_molecule_in_ci_image.sh runs the pin check, the slow path when pins differ, and then scripts/run_molecule_scenarios.sh. The selector and the stale sweep stay on the host.
  • Name and label already exist: the container is named $RUN_CONTAINER (kamino-molecule-${{ github.run_id }}-${{ github.run_attempt }}, set through env:) and labelled net.rkdr.mortis.molecule-run=$RUN_CONTAINER. An if: always() step runs docker rm -f on it.
  • The sweep does not catch it yet: the stale sweep still matches only *-instance and image-smoke*, so a leaked kamino-molecule-* container survives into the next run. Extend the sweep to the label, with the 30-minute age bound from #212 item 1.
  • Cancel is untested: whether act_runner runs the always() step on a cancelled job has not been checked. The acceptance line "cancel a run mid-scenario and check docker ps" covers it.
  • Mounts to keep when you change the step:
    • the host's docker CLI read-only at /usr/local/bin/docker, because the driver's connection plugin runs the CLI;
    • a generated $ac_root/passwd over /etc/passwd, so the runner uid has an entry and a home;
    • the checkout at the same path.
  • The container runs as the runner uid with the socket's gid added. HOME, the slow-path pins and molecule-runs/ all live in the job tree, under ac/.
  • Scenario cleanup in run_molecule_scenarios.sh now uses the Python Docker SDK. The per-run prefix of platform names has to reach that script's exact-name match too.
  • Run values go into the container with -e NAME, never by ${{ }} in run:. A new value such as KAMINO_RUN_ID needs its own -e.

Assisted-by: Claude Code

Unblocked: #225 is merged (#345, #348). The Molecule job now has this shape; build on it. - **The run:** the host job runs `docker run --rm -i --init` on the pinned `ci` image. Inside, `scripts/run_molecule_in_ci_image.sh` runs the pin check, the slow path when pins differ, and then `scripts/run_molecule_scenarios.sh`. The selector and the stale sweep stay on the host. - **Name and label already exist:** the container is named `$RUN_CONTAINER` (`kamino-molecule-${{ github.run_id }}-${{ github.run_attempt }}`, set through `env:`) and labelled `net.rkdr.mortis.molecule-run=$RUN_CONTAINER`. An `if: always()` step runs `docker rm -f` on it. - **The sweep does not catch it yet:** the stale sweep still matches only `*-instance` and `image-smoke*`, so a leaked `kamino-molecule-*` container survives into the next run. Extend the sweep to the label, with the 30-minute age bound from #212 item 1. - **Cancel is untested:** whether act_runner runs the `always()` step on a cancelled job has not been checked. The acceptance line "cancel a run mid-scenario and check `docker ps`" covers it. - **Mounts to keep when you change the step:** - the host's `docker` CLI read-only at `/usr/local/bin/docker`, because the driver's connection plugin runs the CLI; - a generated `$ac_root/passwd` over `/etc/passwd`, so the runner uid has an entry and a home; - the checkout at the same path. - **The container runs as the runner uid** with the socket's gid added. `HOME`, the slow-path pins and `molecule-runs/` all live in the job tree, under `ac/`. - **Scenario cleanup** in `run_molecule_scenarios.sh` now uses the Python Docker SDK. The per-run prefix of platform names has to reach that script's exact-name match too. - **Run values** go into the container with `-e NAME`, never by `${{ }}` in `run:`. A new value such as `KAMINO_RUN_ID` needs its own `-e`. Assisted-by: Claude Code
Defame1297 was assigned by Claude 2026-11-24 09:24:51 +00:00
Author
Owner

Acceptance after the merge of #350 (2026-11-24).

  • A push to main starts no Molecule, Lint or Build run: passed. The merge commit 1b6a4e8 started no run.
  • Two runs started together both finish green, one after the other: passed. Three Molecule dispatches on main were queued at the same moment. 5341 and 5342 each ran every scenario and succeeded in turn. Neither cancelled the other.
  • A cancelled run leaves no container: passed. 5340 was cancelled mid-scenario. "Run the scenarios" ended with exit 130, and then act_runner ran the always() step "Remove this run's containers", which succeeded. That step fails while any container labelled with the run's id is still listed.
  • Containers without a label from before #350: none. After the three runs above, docker ps -a on the Molecule runner listed no container, so none needed removing by hand.

Assisted-by: Claude Code

Acceptance after the merge of #350 (2026-11-24). - **A push to `main` starts no Molecule, Lint or Build run:** passed. The merge commit `1b6a4e8` started no run. - **Two runs started together both finish green, one after the other:** passed. Three Molecule dispatches on `main` were queued at the same moment. [5341](https://git.rkdr.net/Mortis/Kamino/actions/runs/5341) and [5342](https://git.rkdr.net/Mortis/Kamino/actions/runs/5342) each ran every scenario and succeeded in turn. Neither cancelled the other. - **A cancelled run leaves no container:** passed. [5340](https://git.rkdr.net/Mortis/Kamino/actions/runs/5340) was cancelled mid-scenario. "Run the scenarios" ended with exit 130, and then act_runner ran the `always()` step "Remove this run's containers", which succeeded. That step fails while any container labelled with the run's id is still listed. - **Containers without a label from before #350:** none. After the three runs above, `docker ps -a` on the Molecule runner listed no container, so none needed removing by hand. Assisted-by: Claude Code
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: Mortis/Kamino#166