diff --git a/.config/molecule/config.yml b/.config/molecule/config.yml index 4ea9b37..9bdea86 100644 --- a/.config/molecule/config.yml +++ b/.config/molecule/config.yml @@ -11,3 +11,9 @@ provisioner: defaults: # Gather each host's facts once per playbook run, not in every play. gathering: smart + # Per-task timings, to see what a scenario's time goes to; ansible.posix is in the ci image + # and in requirements.yml, so the controller always has these callbacks. + callbacks_enabled: ansible.posix.profile_tasks, ansible.posix.timer + callback_profile_tasks: + summary_only: true + task_output_limit: 20 diff --git a/.gitea/workflows/AGENTS.md b/.gitea/workflows/AGENTS.md index 885a27e..de5ac42 100644 --- a/.gitea/workflows/AGENTS.md +++ b/.gitea/workflows/AGENTS.md @@ -110,9 +110,14 @@ issue. concurrency group of its own.** Runs may overlap on the runner's Docker daemon: every container is named and labelled by its run (`KAMINO_RUN_ID`). The job first removes labelled containers older than its timeout, which a cancelled run left, and finally its own. The scenarios of one - run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time), so no two - scenarios may share a platform name. *Why:* a cancelled run is killed before it can remove its - instances, and a younger container may belong to a run still going. *Held:* review; control: + run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 4 unless a manual + dispatch sets its `lanes` input), so no two scenarios may share a platform name. They start + longest first by the script's list of last full-run times, an unlisted one first; the logs stay + in selection order. *Why:* a cancelled run is killed before it can remove its instances, a + younger container may belong to a run still going, and a long scenario started late sets the + end of the run. *Held:* review; control: the start order by + `test_the_longest_scenarios_start_first` and the input by `LanesInputTest`, both in + `tests/scripts/test_run_molecule_scenarios.py`; control: the names and labels by the test the `test_sequence` rule below names, and the sweep's age bound equal to the job timeout by `test_the_sweep_spares_containers_younger_than_the_job_timeout` in `tests/scripts/test_run_molecule_scenarios.py`. diff --git a/.gitea/workflows/molecule.yml b/.gitea/workflows/molecule.yml index 703a7b1..467f866 100644 --- a/.gitea/workflows/molecule.yml +++ b/.gitea/workflows/molecule.yml @@ -24,7 +24,13 @@ on: # yamllint disable-line rule:truthy # drift in the others (a package mirror) would otherwise go unseen. After Renovate's 03:17 run. schedule: - cron: "43 4 * * *" - workflow_dispatch: {} + workflow_dispatch: + inputs: + lanes: + description: Scenarios run at a time (empty for the default of run_molecule_scenarios.sh) + required: false + type: string + default: "" permissions: contents: read @@ -123,6 +129,8 @@ jobs: EVENT_NAME: ${{ github.event_name }} # The workflow only runs for pull requests to main; lint.yml uses the same constant. BASE_REF: origin/main + # Empty outside a dispatch, which the run script reads as its default. + MOLECULE_LANES: ${{ inputs.lanes }} run: | # The selector comes from the base branch, so a pull request cannot edit the rules it is # judged by (lint.yml does the same for check_bot_pr_diff.py); the first pull request that @@ -154,7 +162,7 @@ jobs: -v /var/run/docker.sock:/var/run/docker.sock -v "$docker_cli:/usr/local/bin/docker:ro" \ -v "$ac_root:$ac_root" -v "$ac_root/passwd:/etc/passwd:ro" -w "$PWD" \ -e "AC_ROOT=$ac_root" -e "HOME=$ac_root/home" -e "USER=$(id -un)" \ - -e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID \ + -e MOLECULE_IMAGE -e MOLECULE_IMAGE_2604 -e KAMINO_RUN_ID -e MOLECULE_LANES \ "$CI_IMAGE" scripts/run_molecule_in_ci_image.sh <<< "$selected" # A cancelled run can leave its containers running when the docker client is killed. diff --git a/scripts/run_molecule_scenarios.sh b/scripts/run_molecule_scenarios.sh index a3fac0a..3a1a33e 100755 --- a/scripts/run_molecule_scenarios.sh +++ b/scripts/run_molecule_scenarios.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # The Molecule workflow's "Run the scenarios" step: `molecule test` for each scenario directory on -# stdin, MOLECULE_LANES (default 4) at a time, each with its own log and ANSIBLE_HOME under -# // (no collection is installed there: .config/molecule/config.yml sets prerun false). +# stdin, MOLECULE_LANES (default 4, also when empty) at a time, longest first, each with its own +# log and ANSIBLE_HOME under // (no collection is installed there: +# .config/molecule/config.yml sets prerun false). # Exit 1 on a failure. # # scripts/run_molecule_scenarios.sh < scenario-dirs @@ -77,6 +78,37 @@ while IFS= read -r dir; do done mkdir -p "$work" +# Seconds each scenario took in the last full run, so the longest start first and none started +# late sets the end of the run. Keyed by scenario directory, not label: refresh from a full run's +# `finished