Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b2e2c4021 | ||
|
|
dbcbf3b02d | ||
|
|
40d5c49e33 |
No files matched your search
@@ -110,7 +110,7 @@ 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, 4 unless a manual
|
||||
run overlap (`scripts/run_molecule_scenarios.sh`, `MOLECULE_LANES` at a time, 2 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
|
||||
|
||||
@@ -297,7 +297,48 @@
|
||||
changed_when: false
|
||||
failed_when: docker_verify_start_run.rc != 2
|
||||
|
||||
# Converge's daemon.json, read before the role runs below change it.
|
||||
# Switching an input back to false removes that unit and script and leaves the other alone.
|
||||
- name: Verify that a unit is removed when its input is false
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: false
|
||||
docker_stop_at_shutdown: true
|
||||
docker_stop_at_shutdown_timeout: 20
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
path: /srv/docker-stub-repo/docker.asc
|
||||
checksum_algorithm: sha256
|
||||
register: docker_stub_key
|
||||
|
||||
- name: Apply the role with the boot unit off
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
|
||||
- name: Stat the boot unit's files and the shutdown unit's script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop:
|
||||
- /usr/local/sbin/docker-start-missed
|
||||
- /etc/systemd/system/docker-start-missed.service
|
||||
- /usr/local/sbin/docker-stop-at-shutdown
|
||||
register: docker_verify_off
|
||||
|
||||
- name: The boot unit is gone and the shutdown unit is still there
|
||||
ansible.builtin.assert:
|
||||
that: docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
|
||||
quiet: true
|
||||
|
||||
- name: Apply the role again with both inputs on
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: true
|
||||
|
||||
- name: Verify the daemon settings
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -328,26 +369,22 @@
|
||||
- docker_verify_daemon_stat.stat.pw_name == 'root'
|
||||
quiet: true
|
||||
|
||||
# The stand-in docker.service runs for real, so a restart shows in its start time. The first run turns the boot unit off and changes
|
||||
# daemon.json with docker_daemon_restart false: the unit goes, the other stays and dockerd keeps running. The second turns everything
|
||||
# back on with docker_daemon_restart true: the boot unit returns and dockerd restarts.
|
||||
- name: Verify the unit inputs and that dockerd restarts only when asked
|
||||
# The stand-in docker.service runs for real, so a restart shows in its start time: a changed file with docker_daemon_restart false leaves
|
||||
# it alone, and with true restarts it.
|
||||
- name: Verify that dockerd restarts only when asked
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: true
|
||||
docker_stop_at_shutdown: true
|
||||
docker_stop_at_shutdown_timeout: 20
|
||||
docker_log_driver: local
|
||||
docker_log_max_size: 10m
|
||||
docker_log_max_file: "3"
|
||||
docker_live_restore: true
|
||||
docker_verify_unit_paths:
|
||||
- /usr/local/sbin/docker-start-missed
|
||||
- /etc/systemd/system/docker-start-missed.service
|
||||
- /usr/local/sbin/docker-stop-at-shutdown
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
@@ -360,11 +397,10 @@
|
||||
register: docker_verify_before
|
||||
changed_when: false
|
||||
|
||||
- name: Apply the boot unit off and a changed setting with docker_daemon_restart false
|
||||
- name: Apply a changed setting with docker_daemon_restart false
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: false
|
||||
docker_daemon_options: {max-concurrent-downloads: 5}
|
||||
docker_daemon_restart: false
|
||||
|
||||
@@ -373,30 +409,10 @@
|
||||
register: docker_verify_kept
|
||||
changed_when: false
|
||||
|
||||
- name: Stat the boot unit's files and the shutdown unit's script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop: "{{ docker_verify_unit_paths }}"
|
||||
register: docker_verify_off
|
||||
|
||||
- name: Read daemon.json
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/docker/daemon.json
|
||||
register: docker_verify_daemon_kept
|
||||
|
||||
- name: The boot unit is gone, the shutdown unit is still there, and the changed file left dockerd running
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
|
||||
- (docker_verify_daemon_kept.content | b64decode | from_json)['max-concurrent-downloads'] == 5
|
||||
- docker_verify_kept.stdout == docker_verify_before.stdout
|
||||
quiet: true
|
||||
|
||||
- name: Apply both units on and another change with docker_daemon_restart true
|
||||
- name: Apply another change with docker_daemon_restart true
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: true
|
||||
docker_daemon_options: {max-concurrent-downloads: 6}
|
||||
docker_daemon_restart: true
|
||||
|
||||
@@ -405,23 +421,17 @@
|
||||
register: docker_verify_restarted
|
||||
changed_when: false
|
||||
|
||||
- name: Stat the unit files again
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop: "{{ docker_verify_unit_paths }}"
|
||||
register: docker_verify_on
|
||||
|
||||
- name: Read daemon.json again
|
||||
- name: Read daemon.json
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/docker/daemon.json
|
||||
register: docker_verify_daemon_after
|
||||
|
||||
- name: Both units are back and the second change restarted dockerd
|
||||
- name: The first change left dockerd alone and the second restarted it
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- docker_verify_on.results | map(attribute='stat.exists') | unique | list == [true]
|
||||
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
|
||||
- docker_verify_kept.stdout == docker_verify_before.stdout
|
||||
- docker_verify_restarted.stdout != docker_verify_kept.stdout
|
||||
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
|
||||
quiet: true
|
||||
|
||||
# A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so
|
||||
|
||||
@@ -359,26 +359,23 @@
|
||||
loop_var: gitea_runner_test_path
|
||||
|
||||
# 6.0.2 has a wrong checksum file (prepare.yml): the download must fail before anything is
|
||||
# stopped, so the runner keeps running 6.0.1. The same run sets the disk threshold to 0: prune
|
||||
# runs before update, so the pressure units are already removed when the download fails.
|
||||
- name: Verify a failed download leaves the runner running, and turning the pressure prune off
|
||||
# stopped, so the runner keeps running 6.0.1.
|
||||
- name: Verify a failed download leaves the runner running
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Update to a release whose checksum does not match
|
||||
block:
|
||||
- name: Include the role with gitea_runner_version 6.0.2 and the disk threshold at 0
|
||||
- name: Include the role with gitea_runner_version 6.0.2
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.gitea_runner
|
||||
vars:
|
||||
gitea_runner_version: 6.0.2
|
||||
gitea_runner_docker_prune_disk_threshold_percent: 0
|
||||
|
||||
- name: Fail because the include returned
|
||||
ansible.builtin.fail:
|
||||
msg: The role accepted a binary with a wrong checksum
|
||||
rescue:
|
||||
# The message comes only from the staging rescue, so a prune error fails this assert.
|
||||
- name: The staging failed, and nothing else failed first
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
@@ -410,31 +407,6 @@
|
||||
- not gitea_runner_test_staged.stat.exists
|
||||
quiet: true
|
||||
|
||||
- name: Stat the pressure units and script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ gitea_runner_test_path }}"
|
||||
loop:
|
||||
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service
|
||||
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
|
||||
- /usr/local/sbin/gitea-runner-docker-prune-disk-check
|
||||
loop_control:
|
||||
loop_var: gitea_runner_test_path
|
||||
register: gitea_runner_test_pressure_off
|
||||
|
||||
- name: Ask systemd about the pressure timer after turning it off
|
||||
ansible.builtin.systemd:
|
||||
name: gitea-runner-docker-prune-pressure.timer
|
||||
register: gitea_runner_test_pressure_timer_off
|
||||
# The module errors for a unit that no longer exists, which is also a pass.
|
||||
failed_when: false
|
||||
|
||||
- name: The pressure units are gone and the timer is not active
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- gitea_runner_test_pressure_off.results | map(attribute='stat') | map(attribute='exists') | select | list | length == 0
|
||||
- gitea_runner_test_pressure_timer_off.status.ActiveState | default('inactive') != 'active'
|
||||
quiet: true
|
||||
|
||||
# Each input assert, through the main entry point. Every one runs in validate.yml, before any
|
||||
# change.
|
||||
- name: Verify the input asserts
|
||||
@@ -476,9 +448,8 @@
|
||||
label: "{{ gitea_runner_test_refused.name }}"
|
||||
|
||||
# The CI guard and the mint-before-drop order of a forced re-registration, through a child
|
||||
# ansible-playbook against one instance (see force_register.yml). Neither case may touch the
|
||||
# registration or stop the runner. The children run once: what they check is controller state
|
||||
# and group_vars, the same for every host, and run_once gives every host their results.
|
||||
# ansible-playbook against this instance (see force_register.yml). Neither case may touch the
|
||||
# registration or stop the runner.
|
||||
- name: Verify the forced re-registration guards
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -494,7 +465,6 @@
|
||||
|
||||
- name: Force a re-registration under each CI variable, as a child process with only that one set
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ansible-playbook
|
||||
@@ -527,7 +497,6 @@
|
||||
|
||||
- name: Force a re-registration outside CI with no token host, as a child process
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- ansible-playbook
|
||||
@@ -581,12 +550,43 @@
|
||||
- gitea_runner_test_unit.status.ActiveState == 'active'
|
||||
quiet: true
|
||||
|
||||
# The failed-download run above removed the pressure units; this run, with the scenario's inputs,
|
||||
# A threshold of 0 removes the pressure units; the run after it, with the scenario's inputs,
|
||||
# puts them back, so the remove path below still has them to remove.
|
||||
- name: Verify turning the pressure prune on again
|
||||
- name: Verify turning the pressure prune off
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Run the role with the disk threshold at 0
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.gitea_runner
|
||||
vars:
|
||||
gitea_runner_docker_prune_disk_threshold_percent: 0
|
||||
|
||||
- name: Stat the pressure units and script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ gitea_runner_test_path }}"
|
||||
loop:
|
||||
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service
|
||||
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
|
||||
- /usr/local/sbin/gitea-runner-docker-prune-disk-check
|
||||
loop_control:
|
||||
loop_var: gitea_runner_test_path
|
||||
register: gitea_runner_test_pressure_off
|
||||
|
||||
- name: Ask systemd about the pressure timer after turning it off
|
||||
ansible.builtin.systemd:
|
||||
name: gitea-runner-docker-prune-pressure.timer
|
||||
register: gitea_runner_test_pressure_timer_off
|
||||
# The module errors for a unit that no longer exists, which is also a pass.
|
||||
failed_when: false
|
||||
|
||||
- name: The pressure units are gone and the timer is not active
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- gitea_runner_test_pressure_off.results | map(attribute='stat') | map(attribute='exists') | select | list | length == 0
|
||||
- gitea_runner_test_pressure_timer_off.status.ActiveState | default('inactive') != 'active'
|
||||
quiet: true
|
||||
|
||||
- name: Run the role again with the scenario's inputs
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.gitea_runner
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# The Molecule workflow's "Run the scenarios" step: `molecule test` for each scenario directory on
|
||||
# stdin, MOLECULE_LANES (default 4, also when empty) at a time, longest first, each with its own
|
||||
# stdin, MOLECULE_LANES (default 2, also when empty) at a time, longest first, each with its own
|
||||
# log and ANSIBLE_HOME under <work-dir>/<n>/ (no collection is installed there:
|
||||
# .config/molecule/config.yml sets prerun false).
|
||||
# Exit 1 on a failure.
|
||||
@@ -8,7 +8,8 @@
|
||||
# scripts/run_molecule_scenarios.sh <work-dir> < scenario-dirs
|
||||
set -euo pipefail
|
||||
|
||||
lanes="${MOLECULE_LANES:-4}"
|
||||
# 2: a full run took 34 min at 2 lanes and 35 at 4, so more lanes only slow each scenario.
|
||||
lanes="${MOLECULE_LANES:-2}"
|
||||
if ! [[ "$lanes" =~ ^[1-9][0-9]*$ ]]; then
|
||||
echo "MOLECULE_LANES must be a positive integer, not '$lanes'" >&2
|
||||
exit 2
|
||||
@@ -78,30 +79,31 @@ 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 <label>: exit 0 after S s` lines, each label mapped back to its directory. A scenario
|
||||
# missing here is assumed long and starts first.
|
||||
# Seconds each scenario took in the last full run at the default lane count, 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 <label>: exit 0 after S s` lines, each label mapped back to
|
||||
# its directory. A scenario missing here is assumed long and starts first.
|
||||
declare -A last_seconds=(
|
||||
[roles/system_baseline/molecule/default]=1127
|
||||
[roles/ufw/molecule/default]=907
|
||||
[roles/traefik/molecule/default]=886
|
||||
[roles/gitea_runner/molecule/default]=762
|
||||
[roles/cloudflared/molecule/default]=673
|
||||
[roles/docker/molecule/default]=612
|
||||
[roles/tailscale/molecule/default]=509
|
||||
[roles/fail2ban/molecule/default]=337
|
||||
[roles/systemd_hardening/molecule/default]=335
|
||||
[roles/gitea/molecule/default]=301
|
||||
[roles/user_management/molecule/default]=270
|
||||
[roles/_binary_update/molecule/default]=248
|
||||
[roles/pihole/molecule/default]=228
|
||||
[roles/sshd/molecule/default]=163
|
||||
[roles/pve_lxc/molecule/default]=157
|
||||
[roles/network_interfaces/molecule/default]=129
|
||||
[roles/_binary_update/molecule/check_mode]=81
|
||||
[extensions/molecule/image-smoke]=47
|
||||
[extensions/molecule/image-smoke-2604]=46
|
||||
[roles/system_baseline/molecule/default]=568
|
||||
[roles/ufw/molecule/default]=525
|
||||
[roles/traefik/molecule/default]=484
|
||||
[roles/gitea_runner/molecule/default]=398
|
||||
[roles/docker/molecule/default]=352
|
||||
[roles/cloudflared/molecule/default]=305
|
||||
[roles/tailscale/molecule/default]=220
|
||||
[roles/fail2ban/molecule/default]=161
|
||||
[roles/gitea/molecule/default]=137
|
||||
[roles/systemd_hardening/molecule/default]=134
|
||||
[roles/_binary_update/molecule/default]=132
|
||||
[roles/nfs_client/molecule/default]=126
|
||||
[roles/user_management/molecule/default]=115
|
||||
[roles/pihole/molecule/default]=112
|
||||
[roles/sshd/molecule/default]=65
|
||||
[roles/pve_lxc/molecule/default]=44
|
||||
[roles/_binary_update/molecule/check_mode]=42
|
||||
[roles/network_interfaces/molecule/default]=36
|
||||
[extensions/molecule/image-smoke]=25
|
||||
[extensions/molecule/image-smoke-2604]=21
|
||||
)
|
||||
# The indices of dirs in start order; ties keep the selection order (a stable sort).
|
||||
mapfile -t start_order < <(
|
||||
|
||||
Reference in new issue
Block a user