Fix attachment contract and reconcile storage safely across API replicas

This commit is contained in:
2026-11-06 17:41:30 +03:00
parent 057143dd91
commit cc0ef713ed
82 changed files with 1828 additions and 1054 deletions
+12
View File
@@ -0,0 +1,12 @@
$ErrorActionPreference = 'Stop'
New-Item -ItemType Directory -Force secrets | Out-Null
$values = @{postgres_db='messenger'; postgres_user='messenger'; postgres_password=''; minio_root_user='labadmin'; minio_root_password=''; s3_access_key_id='labapi'; s3_secret_access_key=''}
foreach ($name in $values.Keys) {
$path = Join-Path secrets ($name + '.txt')
if (!(Test-Path -LiteralPath $path)) {
$value = $values[$name]
if (!$value) { $value = [Convert]::ToBase64String([System.Security.Cryptography.RandomNumberGenerator]::GetBytes(32)) }
[System.IO.File]::WriteAllText((Join-Path (Get-Location) $path), $value)
}
}
if (!(Test-Path .env)) { Copy-Item .env.example .env }
+1
View File
@@ -0,0 +1 @@
@powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0restart.ps1"
+9
View File
@@ -0,0 +1,9 @@
$ErrorActionPreference = 'Stop'
$ids = docker compose ps -q
$before = docker inspect --format '{{.Name}} {{.State.StartedAt}}' $ids
$before | Set-Content evidence/restart-before.txt
docker compose restart db redis minio api lb
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$ids = docker compose ps -q
$after = docker inspect --format '{{.Name}} {{.State.StartedAt}}' $ids
$after | Set-Content evidence/restart-after.txt
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
set -eu
docker compose restart db redis minio api lb
+1
View File
@@ -0,0 +1 @@
@powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0stop-one.ps1"
+13
View File
@@ -0,0 +1,13 @@
$ErrorActionPreference = 'Stop'
$replicas = docker compose ps -q api
foreach ($replica in $replicas) {
$alias = docker inspect --format '{{.Config.Hostname}}' $replica
if ($alias -eq $env:TARGET_INSTANCE_ID) {
docker inspect --format "{{.Name}} {{.Config.Hostname}} {{.State.Status}}" $replica | Set-Content evidence/stop-one-before.txt
docker stop --time 2 $replica
$result = $LASTEXITCODE
docker inspect --format "{{.Name}} {{.Config.Hostname}} {{.State.Status}}" $replica | Set-Content evidence/stop-one-after.txt
exit $result
}
}
exit 1
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu
for id in $(docker compose ps -q api); do
if [ "$(docker inspect --format '{{.Config.Hostname}}' "$id")" = "$TARGET_INSTANCE_ID" ]; then
docker stop -t 2 "$id"
exit 0
fi
done
exit 1