Files
computer-playbook/scripts/tests/deploy/utils/filesystem/resolve.sh
T
kevinveenbirkenbachandClaude Opus 5 d3b8ec4fc0 feat(ci): pick the data-root filesystem for the host that actually carries it
The per-matrix selection never picked anything but ext4. candidates()
intersected what every distribution in the entry supports, and with the list the
orchestrator passes - arch debian ubuntu fedora centos - that leaves ext4 alone:
centos stream has no btrfs, zfs is debian/ubuntu only. btrfs was reachable only
by stating it in the manual input.

The intersection is right for swarm and wrong for the other two. distros.sh
runs 00_one.sh per distribution and each round builds its own lab, so a swarm
pick must hold in every round's nodes. compose and host carve the data root on
the runner itself, whose OS is fixed; there DISTROS names the application images
and has nothing to do with the filesystem underneath docker.

A fourth argument says which, rather than parsing it out of the label, and
guards with `:?` so a forgotten call site fails loudly. The runner pool omits
zfs: the runner-image build installs neither the zfs userland nor
linux-modules-extra, where the Ubuntu azure kernel keeps zfs.ko, so a drawn zfs
would decline on every run. A stated one still overrides the pool and is marked
required, so `filesystem: zfs` fails loudly instead of quietly falling back.

The test executes the resolver rather than reading it, and pins the relation
that breaks silently: the keys it writes to GITHUB_ENV are the keys the three
workflows read. A typo on either side hands docker_dataroot.sh an empty string,
which reports "no filesystem stated" and exits 0 - the feature switched off
under a green run. Pool contents are policy and are not asserted; the per-distro
expectation is derived from the resolver's own answers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 02:13:26 +02:00

77 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Resolve which filesystem one matrix entry runs its docker data root on and
# record the decision for the steps that follow.
#
# A random pick draws only from what the target can deliver; a stated one is
# honoured even where it is unsupported, and the applying step then fails. The
# choice goes to the step summary, since reproducing a red run means re-stating
# it verbatim.
#
# Arguments:
# $1 STATED ext4 | btrfs | zfs, or empty for a random pick
# $2 LABEL matrix entry the pick belongs to, e.g. compose/web-app-gitea
# $3 DISTROS space-separated distributions the entry deploys on
# $4 SCOPE node the pick must satisfy every entry in DISTROS
# runner DISTROS is ignored; the runner's own pool applies
set -euo pipefail
STATED="${1:-}"
LABEL="${2:?usage: resolve.sh STATED LABEL DISTROS SCOPE}"
DISTROS="${3:-}"
SCOPE="${4:?usage: resolve.sh STATED LABEL DISTROS SCOPE}"
NODE_POOL="ext4 btrfs zfs"
RUNNER_POOL="ext4 btrfs"
supported_by() {
case "$1" in
centos) echo "ext4" ;;
arch | fedora) echo "ext4 btrfs" ;;
*) echo "ext4 btrfs zfs" ;;
esac
}
candidates() {
local pool="${NODE_POOL}" distro kept fs
[ "${SCOPE}" = node ] || {
echo "${RUNNER_POOL}"
return 0
}
for distro in ${DISTROS}; do
kept=""
for fs in ${pool}; do
case " $(supported_by "${distro}") " in
*" ${fs} "*) kept="${kept} ${fs}" ;;
esac
done
pool="${kept# }"
done
echo "${pool:-ext4}"
}
if [ -n "${STATED}" ]; then
PICKED="${STATED}"
ORIGIN="stated"
REQUIRED=true
else
POOL="$(candidates)"
read -ra POOL_ENTRIES <<<"${POOL}"
PICKED="$(printf '%s\n' "${POOL_ENTRIES[@]}" | shuf -n1)"
ORIGIN="random out of '${POOL}' on the ${SCOPE}; re-state it to reproduce this run"
REQUIRED=false
fi
echo "filesystem for ${LABEL}: ${PICKED} (${ORIGIN})"
if [ -n "${GITHUB_ENV:-}" ]; then
{
echo "INFINITO_DOCKER_FILESYSTEM=${PICKED}"
echo "INFINITO_DOCKER_FILESYSTEM_REQUIRED=${REQUIRED}"
} >>"${GITHUB_ENV}"
fi
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
echo "- \`${LABEL}\` runs its docker data root on \`${PICKED}\` (${ORIGIN})" \
>>"${GITHUB_STEP_SUMMARY}"
fi