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:
+250
-14
@@ -1,5 +1,5 @@
|
||||
x-app: &app
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
|
||||
networks: [backend]
|
||||
|
||||
x-s3-env: &s3-env
|
||||
@@ -19,7 +19,7 @@ x-s3-env: &s3-env
|
||||
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
|
||||
|
||||
x-pipeline: &pipeline
|
||||
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
||||
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
|
||||
pull_policy: never
|
||||
restart: unless-stopped
|
||||
init: true
|
||||
@@ -44,8 +44,33 @@ x-pipeline: &pipeline
|
||||
broker:
|
||||
condition: service_healthy
|
||||
|
||||
x-otel-env: &otel-env
|
||||
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
|
||||
OTEL_EXPORTER_OTLP_TIMEOUT: ${OTEL_EXPORTER_OTLP_TIMEOUT:-2}
|
||||
OTEL_RESOURCE_ATTRIBUTES: ${OTEL_RESOURCE_ATTRIBUTES:-deployment.environment.name=lab}
|
||||
OTEL_SEMCONV_STABILITY_OPT_IN: http
|
||||
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-10000}
|
||||
OTEL_BSP_MAX_QUEUE_SIZE: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048}
|
||||
OTEL_BLRP_MAX_QUEUE_SIZE: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048}
|
||||
TELEMETRY_SHUTDOWN_SECONDS: ${TELEMETRY_SHUTDOWN_SECONDS:-2}
|
||||
|
||||
x-obs-logging: &obs-logging
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 10m
|
||||
max-file: "3"
|
||||
|
||||
x-obs-hardening: &obs-hardening
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 10s
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
logging: *obs-logging
|
||||
|
||||
x-pipeline-env: &pipeline-env
|
||||
<<: *s3-env
|
||||
<<: [*s3-env, *otel-env]
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
DB_POOL_MAX_SIZE: ${PIPELINE_DB_POOL_MAX_SIZE:-4}
|
||||
@@ -64,10 +89,17 @@ x-s3-client: &s3-client
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
RC_CONFIG_DIR: /tmp/rc
|
||||
user: "65534:65534"
|
||||
volumes: ["./infra/s3:/s3:ro"]
|
||||
secrets:
|
||||
[s3_root_user, s3_root_password, s3_access_key_id, s3_secret_access_key,
|
||||
s3_worker_access_key_id, s3_worker_secret_access_key]
|
||||
- s3_root_user
|
||||
- s3_root_password
|
||||
- s3_access_key_id
|
||||
- s3_secret_access_key
|
||||
- s3_reconciler_access_key_id
|
||||
- s3_reconciler_secret_access_key
|
||||
- s3_worker_access_key_id
|
||||
- s3_worker_secret_access_key
|
||||
cap_drop: [ALL]
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
restart: "no"
|
||||
@@ -83,15 +115,16 @@ services:
|
||||
API_SERVER_MAXCONN: ${API_SERVER_MAXCONN:-64}
|
||||
volumes: [./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro]
|
||||
ports:
|
||||
- "127.0.0.1:${LB_HTTP_PORT:-8080}:8080"
|
||||
- "127.0.0.1:${LB_STATS_PORT:-8404}:8404"
|
||||
- "127.0.0.1:${LB_HTTP_PORT:-18086}:8080"
|
||||
- "127.0.0.1:${LB_STATS_PORT:-26085}:8404"
|
||||
networks: [edge, backend]
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8404/healthz"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
start_period: 60s
|
||||
start_interval: 1s
|
||||
sysctls:
|
||||
net.ipv4.ip_local_port_range: "10240 65535"
|
||||
net.ipv4.tcp_tw_reuse: "1"
|
||||
@@ -108,7 +141,8 @@ services:
|
||||
<<: *app
|
||||
build: .
|
||||
environment:
|
||||
<<: *s3-env
|
||||
<<: [*s3-env, *otel-env]
|
||||
OTEL_SERVICE_NAME: ${OTEL_SERVICE_NAME:-messenger-api}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
CURSOR_SECRET_FILE: /run/secrets/cursor_secret
|
||||
@@ -117,10 +151,11 @@ services:
|
||||
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
|
||||
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-8}
|
||||
REQUEST_TIMEOUT_SECONDS: ${REQUEST_TIMEOUT_SECONDS:-8}
|
||||
MIN_TRANSFER_RATE_BYTES: ${MIN_TRANSFER_RATE_BYTES:-131072}
|
||||
DB_ACQUIRE_TIMEOUT_SECONDS: ${DB_ACQUIRE_TIMEOUT_SECONDS:-1}
|
||||
DB_COMMAND_TIMEOUT_SECONDS: ${DB_COMMAND_TIMEOUT_SECONDS:-2}
|
||||
DRAIN_SECONDS: ${DRAIN_SECONDS:-2}
|
||||
SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-5}
|
||||
SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-6}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
MALLOC_MMAP_THRESHOLD_: ${MALLOC_MMAP_THRESHOLD_:-131072}
|
||||
secrets: [database_url, cache_url, cursor_secret, s3_access_key_id, s3_secret_access_key]
|
||||
@@ -130,7 +165,7 @@ services:
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
start_interval: 1s
|
||||
start_interval: 200ms
|
||||
stop_grace_period: 8s
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
@@ -153,7 +188,8 @@ services:
|
||||
migrate:
|
||||
<<: *app
|
||||
pull_policy: never
|
||||
command: ["python", "-m", "messenger.migrate"]
|
||||
init: true
|
||||
command: ["alembic", "upgrade", "head"]
|
||||
environment:
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
@@ -192,12 +228,14 @@ services:
|
||||
secrets: [postgres_password]
|
||||
volumes: [pgdata:/var/lib/postgresql/data]
|
||||
shm_size: 256m
|
||||
cpuset: ${PG_CPUSET:-}
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "messenger", "-d", "messenger"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 30
|
||||
start_period: 10s
|
||||
start_interval: 200ms
|
||||
stop_grace_period: 10s
|
||||
restart: unless-stopped
|
||||
networks: [backend]
|
||||
@@ -245,6 +283,7 @@ services:
|
||||
RUSTFS_OBS_LOGGER_LEVEL: ${S3_LOG_LEVEL:-warn}
|
||||
secrets: [s3_root_user, s3_root_password]
|
||||
volumes: [s3data:/data]
|
||||
cpuset: ${S3_CPUSET:-}
|
||||
read_only: true
|
||||
tmpfs: ["/tmp:size=64m"]
|
||||
cap_drop: [ALL]
|
||||
@@ -260,7 +299,36 @@ services:
|
||||
networks: [backend]
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "1", memory: "${S3_MEMORY:-512m}"}
|
||||
limits: {cpus: "${S3_CPUS:-1}", memory: "${S3_MEMORY:-512m}"}
|
||||
|
||||
reconciler:
|
||||
<<: *app
|
||||
pull_policy: never
|
||||
profiles: [reconcile]
|
||||
init: true
|
||||
entrypoint: ["python", "-m", "messenger.attachments.entrypoints.reconcile"]
|
||||
command: ["--dry-run"]
|
||||
environment:
|
||||
<<: *s3-env
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_reconciler_access_key_id
|
||||
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_reconciler_secret_access_key
|
||||
S3_READ_TIMEOUT_SECONDS: ${RECONCILE_S3_READ_TIMEOUT_SECONDS:-10}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
secrets: [database_url, s3_reconciler_access_key_id, s3_reconciler_secret_access_key]
|
||||
healthcheck:
|
||||
disable: true
|
||||
restart: "no"
|
||||
read_only: true
|
||||
cpuset: ${RECONCILE_CPUSET:-}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
s3:
|
||||
condition: service_healthy
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "${RECONCILE_CPUS:-1}", memory: "${RECONCILE_MEMORY:-256m}"}
|
||||
|
||||
s3-init:
|
||||
<<: *s3-client
|
||||
@@ -284,7 +352,7 @@ services:
|
||||
security_opt: ["no-new-privileges:true"]
|
||||
cap_drop: [ALL]
|
||||
ports:
|
||||
- "127.0.0.1:${BROKER_MANAGEMENT_PORT:-15672}:15672"
|
||||
- "127.0.0.1:${BROKER_MANAGEMENT_PORT:-26086}:15672"
|
||||
networks: [backend, edge]
|
||||
volumes:
|
||||
- broker-data:/var/lib/rabbitmq
|
||||
@@ -312,6 +380,7 @@ services:
|
||||
command: ["python", "-m", "messenger.relay"]
|
||||
environment:
|
||||
<<: *pipeline-env
|
||||
OTEL_SERVICE_NAME: messenger-relay
|
||||
OUTBOX_POLL_SECONDS: ${OUTBOX_POLL_SECONDS:-1}
|
||||
SWEEP_INTERVAL_SECONDS: ${SWEEP_INTERVAL_SECONDS:-5}
|
||||
secrets:
|
||||
@@ -329,6 +398,7 @@ services:
|
||||
command: ["python", "-m", "messenger.worker"]
|
||||
environment:
|
||||
<<: *pipeline-env
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
|
||||
RENDER_TIMEOUT_SECONDS: ${RENDER_TIMEOUT_SECONDS:-30}
|
||||
RENDER_MEMORY_MB: ${RENDER_MEMORY_MB:-448}
|
||||
@@ -356,6 +426,161 @@ services:
|
||||
resources:
|
||||
limits: {cpus: "${K6_CPUS:-2}", memory: "${K6_MEMORY:-512m}"}
|
||||
|
||||
healthtools:
|
||||
image: busybox:1.37.0-musl@sha256:5cec3fc171c87218698e85a52af7087de727372aae264a787b8112901a5b0092
|
||||
command: ["cp", "/bin/busybox", "/hc/busybox"]
|
||||
restart: "no"
|
||||
network_mode: none
|
||||
volumes:
|
||||
- healthtools:/hc
|
||||
logging: *obs-logging
|
||||
|
||||
otel-collector:
|
||||
<<: *obs-hardening
|
||||
image: otel/opentelemetry-collector-contrib:0.163.2@sha256:7f22d2a6748110ffb6a59bc0df448bccbf501cdb667d610ede4c61d3863d5849
|
||||
command: ["--config=/etc/otelcol/collector.yaml"]
|
||||
networks: [backend, edge]
|
||||
environment:
|
||||
GOMEMLIMIT: 200MiB
|
||||
volumes:
|
||||
- ./infra/otel:/etc/otelcol:ro
|
||||
- healthtools:/hc:ro
|
||||
depends_on:
|
||||
healthtools:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "/hc/busybox", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:13133/"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 6
|
||||
start_period: 10s
|
||||
start_interval: 2s
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.50", memory: 256M}
|
||||
|
||||
prometheus:
|
||||
<<: *obs-hardening
|
||||
image: prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-7d}
|
||||
- --storage.tsdb.retention.size=1GB
|
||||
- --web.enable-otlp-receiver
|
||||
- --enable-feature=exemplar-storage
|
||||
networks: [backend, edge]
|
||||
volumes:
|
||||
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- ./infra/prometheus/rules:/etc/prometheus/rules:ro
|
||||
- prometheus-data:/prometheus
|
||||
ports:
|
||||
- "127.0.0.1:${PROMETHEUS_PORT:-26090}:9090"
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:9090/-/ready"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 6
|
||||
start_period: 15s
|
||||
start_interval: 2s
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.50", memory: 512M}
|
||||
|
||||
loki:
|
||||
<<: *obs-hardening
|
||||
image: grafana/loki:3.7.9@sha256:0db216b630ae1f348a1584c67f3cead8b4c1fc839169a39501db664744158e28
|
||||
command: ["-config.file=/etc/loki/loki.yaml"]
|
||||
networks: [edge]
|
||||
environment:
|
||||
GOMEMLIMIT: 300MiB
|
||||
volumes:
|
||||
- ./infra/loki/loki.yaml:/etc/loki/loki.yaml:ro
|
||||
- loki-data:/loki
|
||||
- healthtools:/hc:ro
|
||||
depends_on:
|
||||
healthtools:
|
||||
condition: service_completed_successfully
|
||||
ports:
|
||||
- "127.0.0.1:${LOKI_PORT:-26310}:3100"
|
||||
healthcheck:
|
||||
test: ["CMD", "/hc/busybox", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:3100/ready"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
start_interval: 2s
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.50", memory: 384M}
|
||||
|
||||
tempo:
|
||||
<<: *obs-hardening
|
||||
image: grafana/tempo:2.10.10@sha256:12b0820f13ffa10ce956b6e9acc3b03f3cffded99109be6cc09d106fe56e5d38
|
||||
command: ["-config.file=/etc/tempo/tempo.yaml"]
|
||||
networks: [edge]
|
||||
environment:
|
||||
GOMEMLIMIT: 300MiB
|
||||
volumes:
|
||||
- ./infra/tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro
|
||||
- tempo-data:/var/tempo
|
||||
- healthtools:/hc:ro
|
||||
depends_on:
|
||||
healthtools:
|
||||
condition: service_completed_successfully
|
||||
ports:
|
||||
- "127.0.0.1:${TEMPO_PORT:-26320}:3200"
|
||||
healthcheck:
|
||||
test: ["CMD", "/hc/busybox", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:3200/ready"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
start_interval: 2s
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.50", memory: 384M}
|
||||
|
||||
grafana:
|
||||
<<: *obs-hardening
|
||||
image: grafana/grafana:12.4.14@sha256:ae509d9ae8c1021ca32ec370a9ca975d40165eda9fccd1e1102d317ff8787cd7
|
||||
networks: [edge]
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: admin
|
||||
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
|
||||
GF_NEWS_NEWS_FEED_ENABLED: "false"
|
||||
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
||||
GF_LOG_LEVEL: warn
|
||||
secrets: [grafana_admin_password]
|
||||
volumes:
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/grafana/dashboards:/etc/grafana/dashboards:ro
|
||||
- grafana-data:/var/lib/grafana
|
||||
depends_on:
|
||||
prometheus:
|
||||
condition: service_started
|
||||
loki:
|
||||
condition: service_started
|
||||
tempo:
|
||||
condition: service_started
|
||||
ports:
|
||||
- "127.0.0.1:${GRAFANA_PORT:-26300}:3000"
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://127.0.0.1:3000/api/health"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 30s
|
||||
start_interval: 2s
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.50", memory: 384M}
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password
|
||||
@@ -387,12 +612,23 @@ secrets:
|
||||
file: ./secrets/broker_url_api
|
||||
broker_url_worker:
|
||||
file: ./secrets/broker_url_worker
|
||||
grafana_admin_password:
|
||||
file: ./secrets/grafana_admin_password
|
||||
s3_reconciler_access_key_id:
|
||||
file: ./secrets/s3_reconciler_access_key_id
|
||||
s3_reconciler_secret_access_key:
|
||||
file: ./secrets/s3_reconciler_secret_access_key
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
valkeydata:
|
||||
s3data:
|
||||
broker-data:
|
||||
healthtools:
|
||||
prometheus-data:
|
||||
loki-data:
|
||||
tempo-data:
|
||||
grafana-data:
|
||||
|
||||
networks:
|
||||
edge:
|
||||
|
||||
Reference in New Issue
Block a user