forked from mtusi2026/mtusi2026lab4
feat(storage): add RustFS attachments and presigned uploads
Add two API replicas, safe object reconciliation, upload validation, regression tests and documented load experiments.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
setlocal
|
||||
if defined GIT_BASH goto run
|
||||
set "GIT_BASH=%ProgramFiles%\Git\bin\bash.exe"
|
||||
if exist "%GIT_BASH%" goto run
|
||||
echo Git Bash was not found. Set GIT_BASH to the full path to bash.exe. 1>&2
|
||||
exit /b 2
|
||||
:run
|
||||
"%GIT_BASH%" "%~dp0restart.sh"
|
||||
exit /b %ERRORLEVEL%
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$project_dir"
|
||||
|
||||
for service in api nginx reconciler postgres redis s3; do
|
||||
if [ -z "$(docker compose ps --all --quiet "$service")" ]; then
|
||||
printf '%s\n' "Missing container for $service; start the Compose stack first." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
replicas=$(docker compose ps --all --quiet api | wc -l | tr -d ' ')
|
||||
if [ "$replicas" -lt 1 ]; then
|
||||
printf 'No API replicas found.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker compose stop --timeout 30 nginx reconciler api postgres redis s3
|
||||
docker compose up --detach --no-recreate --no-build --no-deps --wait --wait-timeout 45 postgres redis s3
|
||||
docker compose up --detach --no-recreate --no-build --no-deps --scale "api=$replicas" --wait --wait-timeout 45 api
|
||||
docker compose up --detach --no-recreate --no-build --no-deps --wait --wait-timeout 30 nginx reconciler
|
||||
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
cd /d "%~dp0.."
|
||||
if not defined TARGET_INSTANCE_ID (
|
||||
echo TARGET_INSTANCE_ID is required 1>&2
|
||||
exit /b 2
|
||||
)
|
||||
set "containers="
|
||||
for /f "delims=" %%C in ('docker compose ps --all --quiet api') do (
|
||||
set "containers=!containers! %%C"
|
||||
set "candidate=%%C"
|
||||
rem This Compose uses Docker's default hostname: the first 12 container-ID characters.
|
||||
if "!candidate:~0,12!"=="%TARGET_INSTANCE_ID%" (
|
||||
docker stop --time 0 %%C >nul
|
||||
if errorlevel 1 exit /b 1
|
||||
exit /b 0
|
||||
)
|
||||
)
|
||||
if not defined containers (
|
||||
echo No API containers found 1>&2
|
||||
exit /b 2
|
||||
)
|
||||
rem Fallback for explicitly configured hostnames, still scoped to this project's API containers.
|
||||
for /f "tokens=1,2 delims=:" %%H in ('docker inspect --format "{{.Config.Hostname}}:{{.Id}}" !containers!') do (
|
||||
if "%%H"=="%TARGET_INSTANCE_ID%" (
|
||||
rem Failure injection: stop immediately, leaving time for recovery within the 10-second test budget.
|
||||
docker stop --time 0 %%I >nul
|
||||
if errorlevel 1 exit /b 1
|
||||
exit /b 0
|
||||
)
|
||||
)
|
||||
echo No API container matches X-Instance-Id 1>&2
|
||||
exit /b 2
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
project_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$project_dir"
|
||||
|
||||
target=${TARGET_INSTANCE_ID:?test provides target API instance ID}
|
||||
|
||||
containers=$(docker compose ps --all --quiet api)
|
||||
if [ -z "$containers" ]; then
|
||||
printf 'No API containers found\n' >&2
|
||||
exit 2
|
||||
fi
|
||||
for entry in $(docker inspect --format '{{.Config.Hostname}}:{{.Id}}' $containers); do
|
||||
instance=${entry%%:*}
|
||||
container=${entry#*:}
|
||||
if [ "$instance" = "$target" ]; then
|
||||
docker stop --time 8 "$container" >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
printf 'No API container matches X-Instance-Id\n' >&2
|
||||
exit 2
|
||||
Reference in New Issue
Block a user