From bf604a1af2f0c2e5adbb2391a01bb5aac4e8b9c0 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Fri, 27 Nov 2026 13:38:09 +0000 Subject: [PATCH] docs(adr): run Molecule in its own controller image Record ADR 0003: Molecule runs in a molecule-controller image that bakes only Molecule's tools, from a requirements file and hash-pinned lock of its own, so a ci pin pull request no longer moves molecule.yml and runs no scenario. The ADR lists the files the implementation updates and the alternatives not taken. Assisted-by: Claude Code:claude-opus-5-5 --- docs/adr/0003-molecule-controller-image.md | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 docs/adr/0003-molecule-controller-image.md diff --git a/docs/adr/0003-molecule-controller-image.md b/docs/adr/0003-molecule-controller-image.md new file mode 100644 index 0000000..47c451b --- /dev/null +++ b/docs/adr/0003-molecule-controller-image.md @@ -0,0 +1,59 @@ +# 0003. Molecule runs in its own controller image, not the `ci` image + +Status: accepted + +## Context + +[ADR 0002](0002-self-built-ci-and-molecule-images.md) built one `ci` image that bakes every CI +tool, and Lint, Build and Molecule all pin it. A change to a tool only Lint uses (apm-cli, +antsibull-changelog, a pre-commit hook environment) publishes a new `ci` version, and its pin +pull request moves `CI_IMAGE` in `molecule.yml`. The scenario selector cannot tell what changed +inside an image, so it runs every scenario. About half of the `ci` pin pull requests were +Lint-only. Images are built only on push to `main`, so a bump and its pin never share a pull +request. + +## Decision + +- **Molecule runs in a `molecule-controller` image**, separate from `ci`. It bakes only what + Molecule needs: ansible-core, molecule, molecule-plugins, the Python packages of the Docker + connection, and the collections of `requirements.yml` and + `extensions/molecule/requirements.yml`. +- **Its Python packages come from a requirements file and hash-pinned lock of its own.** +- **`molecule.yml` pins it instead of `ci`**; Lint and Build keep `ci`. +- **It follows ADR 0002 otherwise:** built by `image.yml`, versioned by CI, pinned by + `@sha256:`, moved by Renovate. This adds to ADR 0002's set of images; the + rest of ADR 0002 stands. + +## Reason + +A `ci` pin pull request then touches only paths the selector ignores and runs no scenario. A +`molecule-controller` pin pull request still runs every scenario, which is right: it changes +Molecule's tools. + +The cost: one more image and lock to maintain, its layers to estimate against the 100 MB limit, +a hand-made first pin, and ansible-core pinned in two locks that must stay equal. A collection +bump is an input of both images, so it publishes two versions and two pin pull requests. + +The controller's requirements file and lock must not be on the selector's IGNORED list, so a +bump of ansible-core or molecule there runs every scenario before it merges. Today +`requirements-dev.txt` and `requirements-dev.lock` are on IGNORED, so such a bump selects no +scenario unless it edits `meta/runtime.yml`; this decision does not change that list. + +The implementation updates: `image.yml` (matrix), `molecule.yml`, +`scripts/run_molecule_in_ci_image.sh` (its pin comparison reads the `ci` image's checksums), +`scripts/check_image_versions.py`, `scripts/check_bot_pr_diff.py` and +`scripts/lock-requirements.sh` (they know only `requirements-dev.lock`), their tests, the +`pip-compile` patterns in `renovate.json`, `images/AGENTS.md` (the consumer list, and "each +molecule image is one Ubuntu release"), the Molecule rules in `.gitea/workflows/AGENTS.md`, +`docs/images/` (a new page, and `ci.md`, which names Molecule as a consumer), the `ci` +Dockerfile's description label, `docs/contributing/setup.md` if the clone's tools change, and the +[Accepted risks](../../SECURITY.md#accepted-risks) entry "Pin bumps first behaviour-tested after +they merge", which counts on the `ci` pin pull request running every scenario. + +## Not done + +- **The selector classifies the packages a lock change moves, to decide whether a `CI_IMAGE` + bump matters:** a heuristic package list inside a script that judges pull requests. +- **Status quo:** every Lint-only tool change keeps costing a full Molecule run. +- **Grouping pin pull requests only:** adopted separately; it lowers the number of full runs + but not the cause.