Forward the lab 5 foundation while preserving lab 6 telemetry

Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.

Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
This commit is contained in:
Artyom
2026-11-06 12:29:35 +03:00
parent dc9256baf9
commit 12db77133f
161 changed files with 11160 additions and 1467 deletions
+12 -13
View File
@@ -4,23 +4,22 @@ secret() { tr -d '\r\n' < "/run/secrets/$1"; }
bucket="${S3_BUCKET:-messenger-attachments}"
endpoint="${S3_ENDPOINT:-http://s3:9000}"
policy="${S3_API_POLICY:-messenger-api}"
reconciler="${S3_RECONCILER_POLICY:-messenger-reconciler}"
RC_HOST_root="${endpoint%%://*}://$(secret s3_root_user):$(secret s3_root_password)@${endpoint#*://}"
export RC_HOST_root
api_key=$(secret s3_access_key_id)
grant() {
sed "s/messenger-attachments/$bucket/g" "/s3/$2" > "/tmp/$2"
rc admin policy create root "$1" "/tmp/$2" >/dev/null
rc admin user add root "$(secret "$3")" "$(secret "$4")" >/dev/null
rc admin policy attach root "$1" --user "$(secret "$3")" >/dev/null
rc admin user info root "$(secret "$3")" --json | grep -q "\"$1\""
}
rc ready root --timeout 10 >/dev/null
rc bucket create --ignore-existing "root/$bucket" >/dev/null
rc bucket anonymous set private "root/$bucket" >/dev/null
sed "s/messenger-attachments/$bucket/g" /s3/api-policy.json > /tmp/api-policy.json
rc admin policy create root "$policy" /tmp/api-policy.json >/dev/null
rc admin user add root "$api_key" "$(secret s3_secret_access_key)" >/dev/null
rc admin policy attach root "$policy" --user "$api_key" >/dev/null
worker_key=$(secret s3_worker_access_key_id)
sed "s/messenger-attachments/$bucket/g" /s3/worker-policy.json > /tmp/worker-policy.json
rc admin policy create root messenger-worker /tmp/worker-policy.json >/dev/null
rc admin user add root "$worker_key" "$(secret s3_worker_secret_access_key)" >/dev/null
rc admin policy attach root messenger-worker --user "$worker_key" >/dev/null
grant "$policy" api-policy.json s3_access_key_id s3_secret_access_key
grant "$reconciler" reconciler-policy.json s3_reconciler_access_key_id s3_reconciler_secret_access_key
grant messenger-worker worker-policy.json s3_worker_access_key_id s3_worker_secret_access_key
rc bucket lifecycle rule import "root/$bucket" /s3/lifecycle.json >/dev/null
rc bucket anonymous get "root/$bucket" --json | grep -q '"permission": *"private"'
rc admin user info root "$api_key" --json | grep -q "\"$policy\""
rc admin user info root "$worker_key" --json | grep -q '"messenger-worker"'
echo "s3-init: bucket=$bucket anonymous=private policy=$policy worker=messenger-worker lifecycle=abort-incomplete-uploads"
echo "s3-init: bucket=$bucket anonymous=private policies=$policy,$reconciler lifecycle=abort-incomplete-uploads"