mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-30 19:46:15 +00:00
Give each chaos scenario its own container names and config directory
Chaos scenarios run four at a time under local CI, but every one of them claimed the container names fips-node-nNN and wrote its generated configs and compose file to the same generated-configs/sim directory. Container names are global in Docker and are not scoped by the compose project, so concurrent scenarios collided on both, and a scenario could start containers from a compose file another had overwritten. Thread the existing FIPS_CI_NAME_SUFFIX into the simulation. run_chaos narrows the run-wide suffix to the scenario, and the sim reads it once when the topology is built, applying it to the container names and to the config directory basename. The compose template renders the name through the topology accessor instead of duplicating the literal, so one expression produces every chaos container name. The suffix is empty when the variable is unset, so a bare chaos.sh run and the hosted CI jobs render byte-identical names and paths. Verified by rendering every scenario's compose file before and after with the variable unset and diffing.
This commit is contained in:
+10
-3
@@ -516,9 +516,16 @@ run_chaos() {
|
||||
local name="$1"
|
||||
shift
|
||||
local rc=0
|
||||
# Distinct project per scenario (chaos children run in parallel). When
|
||||
# invoked from a background subshell this export is local to that child.
|
||||
export COMPOSE_PROJECT_NAME="$(ci_project "chaos-$name")"
|
||||
# Distinct project per scenario (chaos children run in parallel). Scoped to
|
||||
# this function so the --only path cannot leak it into a later suite.
|
||||
local -x COMPOSE_PROJECT_NAME="$(ci_project "chaos-$name")"
|
||||
|
||||
# Container names and the generated-config directory are GLOBAL and are not
|
||||
# scoped by the compose project, so narrow the run-wide suffix to this
|
||||
# scenario. Parallel children then cannot claim each other's names or
|
||||
# overwrite each other's compose file.
|
||||
local suffix="-${name}${FIPS_CI_NAME_SUFFIX:-}"
|
||||
local -x FIPS_CI_NAME_SUFFIX="$suffix"
|
||||
|
||||
info "[chaos/$name] Running simulation"
|
||||
if bash testing/chaos/scripts/chaos.sh "$@" 2>&1; then
|
||||
|
||||
Reference in New Issue
Block a user