ci(molecule): remove each scenario's containers in the workflow instead of molecule's destroy
molecule's trailing destroy runs the Docker driver's destroy playbook, whose "Wait for instance(s) deletion to complete" task alone costs about 5.6 s per scenario, about 84 s over the 15 scenarios of a full run. The whole destroy phase measured about 103 s per full run (the median across full runs, among them 4764, 4714, 4698 and 4578). The workflow already removes stale containers before the run, so it can remove each scenario's containers itself with `docker rm -f` as soon as the scenario ends, pass or fail, and skip the playbook. The names come from each scenario's molecule.yml (platforms[].name) via the molecule venv's Python and PyYAML, so no list is kept in the workflow. A failed removal fails the step. The test_sequence rule in the workflow guidance now says both destroys are left out and that platform names are literal. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
00c6cbeba4
commit
f77586dc60
17 files changed
+67
-82
No files matched your search
@@ -92,10 +92,11 @@ issue.
|
|||||||
raises the ansible-core floor must be behaviour-tested on the new core before it automerges.
|
raises the ansible-core floor must be behaviour-tested on the new core before it automerges.
|
||||||
*Held:* aspirational until #225 runs Molecule from the `ci` image with the pin comparison
|
*Held:* aspirational until #225 runs Molecule from the `ci` image with the pin comparison
|
||||||
against `/opt/ci-pins.sha256`; today it runs from the runner's own venv.
|
against `/opt/ci-pins.sha256`; today it runs from the runner's own venv.
|
||||||
- **Every scenario sets `scenario.test_sequence` to molecule's default minus the leading
|
- **Every scenario sets `scenario.test_sequence` to molecule's default minus both `destroy`
|
||||||
`destroy`;** copy it into a new scenario. *Why:* the workflow clears stale containers first,
|
steps, and names its platforms literally in its `molecule.yml`;** copy it into a new scenario.
|
||||||
and the molecule state lives in the job's own `ANSIBLE_HOME`, so a killed run leaves none
|
*Why:* the workflow clears stale containers first and removes each scenario's containers by
|
||||||
behind. *Held:* review.
|
those names as soon as it ends, which skips the driver's destroy wait, and the molecule state
|
||||||
|
lives in the job's own `ANSIBLE_HOME`, so a killed run leaves none behind. *Held:* review.
|
||||||
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
|
- **Scenarios live in `roles/*/molecule/*/` and `extensions/molecule/*/`.** A role scenario that
|
||||||
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
|
must pass on Ubuntu 24.04 and 26.04 takes `image: ${MOLECULE_IMAGE}` or
|
||||||
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
|
`${MOLECULE_IMAGE_2604}` per platform; the image-smoke scenarios are described in
|
||||||
|
|||||||
@@ -128,9 +128,11 @@ jobs:
|
|||||||
|
|
||||||
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
|
# A pull request runs only the scenarios of the roles it changes (scripts/select_molecule_scenarios.py
|
||||||
# explains the rules); a push to main and a manual dispatch run all of them.
|
# explains the rules); a push to main and a manual dispatch run all of them.
|
||||||
# molecule test destroys its instance on success and on failure; a cancelled run is killed
|
# The scenarios leave out molecule's destroy (see their test_sequence): the step removes each
|
||||||
# before it can, so the step first removes what such a run left, since the next run may not
|
# scenario's containers itself, by the platform names in its molecule.yml, as soon as it ends.
|
||||||
# select the same scenarios.
|
# That skips the driver's destroy playbook: its deletion wait is about 5.6 s per scenario (about
|
||||||
|
# 84 s over 15), and the whole destroy phase measured about 103 s a full run. A cancelled run
|
||||||
|
# is killed before it can, so the step first removes what one left.
|
||||||
- name: Run the scenarios
|
- name: Run the scenarios
|
||||||
working-directory: ac/ansible_collections/mortis/kamino
|
working-directory: ac/ansible_collections/mortis/kamino
|
||||||
env:
|
env:
|
||||||
@@ -169,6 +171,17 @@ jobs:
|
|||||||
echo "::notice::no base copy of $sel; running this checkout's copy"
|
echo "::notice::no base copy of $sel; running this checkout's copy"
|
||||||
fi
|
fi
|
||||||
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
|
selected="$(python3 -I "$sel" "$BASE_REF")" || exit 1
|
||||||
|
# Removes the containers of the scenario in directory $1 by its platform names (literal in
|
||||||
|
# molecule.yml), whether or not they exist; a failure fails the step.
|
||||||
|
remove_instances() {
|
||||||
|
local names ids
|
||||||
|
local py='import sys, yaml; print(*(p["name"] for p in yaml.safe_load(open(sys.argv[1]))["platforms"]))'
|
||||||
|
names="$("$MOLECULE_VENV/bin/python3" -I -c "$py" "$1/molecule.yml")" && [ -n "$names" ] || return 1
|
||||||
|
# shellcheck disable=SC2046,SC2086 # names and ids are one word each
|
||||||
|
ids="$(docker ps -aq $(printf -- '--filter name=^/%s$ ' $names))" || return 1
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
[ -z "$ids" ] || docker rm -f $ids >/dev/null
|
||||||
|
}
|
||||||
failed=""
|
failed=""
|
||||||
ran=0
|
ran=0
|
||||||
while IFS= read -r dir; do
|
while IFS= read -r dir; do
|
||||||
@@ -188,6 +201,7 @@ jobs:
|
|||||||
(cd "roles/$role" && molecule test -s "$name" </dev/null) || failed="$failed $label"
|
(cd "roles/$role" && molecule test -s "$name" </dev/null) || failed="$failed $label"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
remove_instances "$dir" || failed="$failed $label(removal)"
|
||||||
ran=$((ran + 1))
|
ran=$((ran + 1))
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
done <<< "$selected"
|
done <<< "$selected"
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -41,4 +40,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -26,10 +26,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -41,4 +40,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -26,10 +26,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -40,4 +39,3 @@ scenario:
|
|||||||
- check
|
- check
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -26,10 +26,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -41,4 +40,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -27,10 +27,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -42,4 +41,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -25,10 +25,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -40,4 +39,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -36,10 +36,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -51,4 +50,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -44,10 +44,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -59,4 +58,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -25,10 +25,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -40,4 +39,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -26,10 +26,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -41,4 +40,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -32,10 +32,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -47,4 +46,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -25,10 +25,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -40,4 +39,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -46,10 +46,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -61,4 +60,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -25,10 +25,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -40,4 +39,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
@@ -33,10 +33,9 @@ provisioner:
|
|||||||
verifier:
|
verifier:
|
||||||
name: ansible
|
name: ansible
|
||||||
scenario:
|
scenario:
|
||||||
# molecule's default sequence minus its first destroy: the workflow removes what a killed run
|
# molecule's default sequence minus both destroys: the workflow removes the container before the
|
||||||
# left before any scenario starts, so that destroy only waits out the
|
# run and as soon as this scenario ends; molecule's destroy only adds the driver's poll wait.
|
||||||
# driver's 5 s poll on a container that is not there. After an aborted local run, run
|
# After a local run, run `molecule destroy` yourself.
|
||||||
# `molecule destroy` yourself.
|
|
||||||
test_sequence:
|
test_sequence:
|
||||||
- dependency
|
- dependency
|
||||||
- cleanup
|
- cleanup
|
||||||
@@ -48,4 +47,3 @@ scenario:
|
|||||||
- side_effect
|
- side_effect
|
||||||
- verify
|
- verify
|
||||||
- cleanup
|
- cleanup
|
||||||
- destroy
|
|
||||||
Reference in new issue
Block a user