strawberry/deploy/salt/test/fleet_common.sh
trvon 39ffa02ae6
Salt: dockerized multi-node fleet test (master/central + 3 sensors) + state fixes
deploy/salt/test/: builds a release tarball from HEAD in ubuntu:24.04 (CI path),
boots systemd containers (rootless, no --privileged), master==central + 3
sensors with the host's Salt onedir mounted read-only, applies the real states,
runs a workload with planted YARA detections, then two orchestrated cycles.
43 checks (install/config/idempotence, real daemons + telemetry, R2 cache
miss/hit, cp.push collect, 3-seed cycle, canary hold then fleet rollout, no
promoted model anywhere, fleet bits in round 2, --since cursor, dedup).

State fixes found by running them for real:
- init.sls no longer includes strawberry.distribute: a plain state.apply on
  sensors shipped models fleet-wide and bypassed the canary; only the
  orchestration distributes now.
- install.sls: CI tarballs carry a +g<sha> suffix that 'strawberry version'
  does not print, so install.sh re-ran on every apply; record the installed
  release and compare base version + marker.
- orch collect: mv -f (re-collected bundles must not be skipped).
- central cycle: builds the overlay first; a training refusal for too few
  teacher labels (normal on a young fleet) publishes the overlay only and
  keeps the sensors' shadow, any other error still fails.
- distribute.sls: serves only what the cycle published (cp.hash_file; the
  cp.list_master file-list cache can miss a just-published file).
Render check gains overlay-only and full publish cases (20 checks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:16:31 -07:00

22 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Shared names/helpers for the dockerized fleet test (sourced, not run).
# shellcheck disable=SC2034
set -euo pipefail
FLEET_HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
FLEET_REPO=$(cd "$FLEET_HERE/../../.." && pwd)
FLEET_DIR=${SB_FLEET_DIR:-/var/tmp/sb-fleet}
FLEET_LOGS=$FLEET_DIR/logs
FLEET_GEN=$FLEET_DIR/gen
FLEET_NET=sbfleet-net
FLEET_IMAGE=sbfleet-node:latest
# container name -> salt minion id
FLEET_CENTRAL=sbfleet-central # minion id: strawberry-central (also the salt-master)
FLEET_SENSORS=(sbfleet-sensor-1 sbfleet-sensor-2 sbfleet-sensor-3) # minion ids sensor-1..3
FLEET_ALL=("$FLEET_CENTRAL" "${FLEET_SENSORS[@]}")
CG_ROOT=/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service
export TMPDIR=/var/tmp
mkdir -p "$FLEET_LOGS" "$FLEET_GEN"
dx() { local c=$1; shift; docker exec "$c" "$@"; }
dxb() { local c=$1; shift; docker exec "$c" bash -c "set -euo pipefail; $*"; }
minion_id() { case "$1" in "$FLEET_CENTRAL") echo strawberry-central ;; sbfleet-sensor-*) echo "sensor-${1##*-}" ;; esac; }