mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-04 05:46:14 +00:00
A CI worker may preempt an in-flight ci-local.sh run (SIGTERM, then SIGKILL after a grace period) to restart on a newer commit. For that kill to be safe, the script must clean up after itself and never let a dying run collide with its restart. It previously had no signal handling, shared the default compose project name across runs, and tore down each suite only at the suite end. - Derive a per-run id (honoring FIPS_CI_RUN_ID, else short-sha+random) and namespace every docker resource to it: a fipsci_<run>_<suite> compose project per suite and per parallel chaos child, and per-run image tags (fips-test:<run>, fips-test-app:<run>) retagged to :latest only after both builds succeed so :latest never points at a half-built image. - Install a bounded, idempotent teardown trap on SIGTERM/SIGINT (+ EXIT): reap parallel chaos children, then force-remove this run's docker resources via the new ci-cleanup.sh, wrapped in timeout so a stuck down cannot wedge it. - Exit 143 (SIGTERM) / 130 (SIGINT), distinct from 0 (pass) / 1 (failed), so a preempting worker tells a cancelled run from a real failure. - Add ci-cleanup.sh (also ci-local.sh --reap): force-removes leftover CI resources by the com.corganlabs.fips-ci=1 label and the fipsci_ project prefix, robust to however a prior run died. - Label every per-suite docker resource so the label sweep reaps it after a SIGKILL regardless of network name: direct docker run/network resources, the sidecar compose services, and every per-suite compose network (acl-allowlist, boringtun, firewall, nat, static, both tor suites, and the chaos generator template). Parametrize the static/sidecar compose image refs so the per-run tags are honored. - Give each parallel chaos child a unique /24 from 10.30.x (a new --subnet override on the sim CLI, assigned per-child in ci-local.sh) so parallel children never collide on a shared docker subnet, and a chaos net can never span a fixed-subnet suite (sidecar/static in 172.20.x). 10.30.x sits outside docker's default-address-pool range, so an auto-assigned net cannot land on it either; node IPs derive from the subnet, so no scenario config changes.
52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
networks:
|
|
fips-net:
|
|
name: ${FIPS_NETWORK:-fips-sidecar-net}
|
|
driver: bridge
|
|
# Reap label: this harness uses fixed -p sidecar-{a,b,c} project names
|
|
# (the test execs containers by those derived names), so its resources are
|
|
# NOT covered by ci-local's fipsci_ project prefix. Label them directly so
|
|
# ci-cleanup.sh can still reap them after a preemption/SIGKILL.
|
|
labels:
|
|
- "com.corganlabs.fips-ci=1"
|
|
ipam:
|
|
config:
|
|
- subnet: ${FIPS_SUBNET:-172.20.1.0/24}
|
|
|
|
services:
|
|
fips:
|
|
image: fips-test:latest
|
|
hostname: fips-sidecar
|
|
labels:
|
|
- "com.corganlabs.fips-ci=1"
|
|
cap_add:
|
|
- NET_ADMIN
|
|
devices:
|
|
- /dev/net/tun:/dev/net/tun
|
|
sysctls:
|
|
- net.ipv6.conf.all.disable_ipv6=0
|
|
restart: "no"
|
|
environment:
|
|
- RUST_LOG=${RUST_LOG:-info}
|
|
- FIPS_TEST_MODE=sidecar
|
|
- FIPS_NSEC=${FIPS_NSEC}
|
|
- FIPS_PEER_NPUB=${FIPS_PEER_NPUB:-}
|
|
- FIPS_PEER_ADDR=${FIPS_PEER_ADDR:-}
|
|
- FIPS_PEER_ALIAS=${FIPS_PEER_ALIAS:-peer}
|
|
- FIPS_UDP_BIND=${FIPS_UDP_BIND:-0.0.0.0:2121}
|
|
- FIPS_TUN_MTU=${FIPS_TUN_MTU:-1280}
|
|
- FIPS_PEER_TRANSPORT=${FIPS_PEER_TRANSPORT:-udp}
|
|
networks:
|
|
fips-net:
|
|
ipv4_address: ${FIPS_IPV4:-172.20.1.20}
|
|
|
|
app:
|
|
image: fips-test-app:latest
|
|
labels:
|
|
- "com.corganlabs.fips-ci=1"
|
|
network_mode: "service:fips"
|
|
depends_on:
|
|
- fips
|
|
volumes:
|
|
- ../docker/resolv.conf:/etc/resolv.conf:ro
|
|
command: ["sleep", "infinity"]
|