strawberry/deploy/salt/test/build_tarball.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

37 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build the noble release tarball from THIS tree inside a throwaway ubuntu:24.04
# container (capped), into /var/tmp/sb-fleet/dist. Reuses a cached tarball for the same HEAD.
# The build runs on a scratch clone, so build-release.sh's `rm -rf builddir` never touches
# the real checkout.
set -euo pipefail
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
repo=$(cd "$here/../../.." && pwd)
work=${SB_FLEET_DIR:-/var/tmp/sb-fleet}
dist=$work/dist
logs=$work/logs
export TMPDIR=/var/tmp
mkdir -p "$dist" "$logs"
head_full=$(git -C "$repo" rev-parse HEAD)
head12=${head_full:0:12}
cached=$(ls -t "$dist"/strawberry-*+g"${head12}"-noble-amd64.tgz 2>/dev/null | head -1 || true)
if [ -n "$cached" ]; then
echo "cached: $cached"
exit 0
fi
src=$work/src-$head12
if [ ! -d "$src/.git" ]; then
git clone -q --no-hardlinks "$repo" "$src"
fi
git -C "$src" checkout -q --detach "$head_full"
name=sbfleet-build
docker rm -f "$name" >/dev/null 2>&1 || true
nice -n 19 docker run --rm --name "$name" \
--cpus=2 --memory=4g \
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0=/src -e CI=true -e JOBS=2 -e DEBIAN_FRONTEND=noninteractive \
-v "$src":/src -v "$dist":/out -w /src \
ubuntu:24.04 packaging/ci/build-release.sh noble /out \
2>&1 | tee "$logs/01-build-tarball.log"
ls -l "$dist"