forked from mtusi2026/mtusi2026lab4
Run the reconciler as a one-off service of the stand
The reconciler service under the reconcile profile runs the API image with the reconciler module as entrypoint and --dry-run as the default command, so docker compose run --rm --no-deps reconciler takes only flags. It gets the database URL and the limited API key of S3, which already allows listing, reading and deleting objects, a read-only root, 1 CPU and 256 MiB, and a longer S3 read timeout for listing pages. S3, PostgreSQL and the reconciler accept an optional cpuset from the environment so measurements can pin them; the default is no pinning. make reconcile ARGS=... runs a pass, make reconcile-demo and make reconcile-cost drive the track experiments, and the limits policy now covers the new service. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
91731fd317
commit
51fa19a8ee
@@ -50,3 +50,11 @@ UPLOAD_SWEEP_INTERVAL_SECONDS=30
|
||||
UPLOAD_SWEEP_BATCH=100
|
||||
# Fixed glibc mmap threshold for the API: buffers above 128 KiB are returned to the system on free.
|
||||
MALLOC_MMAP_THRESHOLD_=131072
|
||||
# Solution-specific for lab4 track 2: limits of the one-off reconciler (profile reconcile), its S3
|
||||
# read timeout for listing pages, and optional CPU pinning of the measured services (empty = no pinning).
|
||||
RECONCILE_CPUS=1
|
||||
RECONCILE_MEMORY=256m
|
||||
RECONCILE_S3_READ_TIMEOUT_SECONDS=10
|
||||
RECONCILE_CPUSET=
|
||||
S3_CPUSET=
|
||||
PG_CPUSET=
|
||||
|
||||
@@ -11,7 +11,7 @@ RATE ?= 100
|
||||
API_IMAGE ?= mtusi-messenger:lab4
|
||||
FROM_REV ?=
|
||||
SCRIPTS_PY = scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py \
|
||||
scripts/upload_memory.py
|
||||
scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py
|
||||
SCENARIO ?= failover-upload
|
||||
PSQL = $(COMPOSE) exec -T postgres psql -U messenger -d messenger -X -q
|
||||
|
||||
@@ -20,7 +20,8 @@ PSQL = $(COMPOSE) exec -T postgres psql -U messenger -d messenger -X -q
|
||||
secrets up down reset-data migrate ps logs restore lb-check failover-evidence stack-evidence \
|
||||
persistence-evidence storage-evidence cache-evidence test-faults seed explain \
|
||||
limits detection failover-each rolling-update level4 \
|
||||
scenario s3-check attachments-evidence upload-faults upload-memory
|
||||
scenario s3-check attachments-evidence upload-faults upload-memory \
|
||||
reconcile reconcile-demo reconcile-cost
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@@ -139,6 +140,15 @@ upload-faults:
|
||||
upload-memory:
|
||||
$(PYTHON) scripts/upload_memory.py --base-url "$(BASE_URL)"
|
||||
|
||||
reconcile:
|
||||
$(COMPOSE) run --rm --no-deps reconciler $(ARGS)
|
||||
|
||||
reconcile-demo:
|
||||
$(PYTHON) scripts/reconcile_track.py demo --base-url "$(BASE_URL)"
|
||||
|
||||
reconcile-cost:
|
||||
$(PYTHON) scripts/reconcile_track.py cost $(ARGS)
|
||||
|
||||
failover-evidence:
|
||||
sh scripts/failover-evidence.sh "$(BASE_URL)"
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ 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
|
||||
@@ -205,6 +206,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]
|
||||
@@ -222,6 +224,32 @@ services:
|
||||
resources:
|
||||
limits: {cpus: "1", memory: "${S3_MEMORY:-512m}"}
|
||||
|
||||
reconciler:
|
||||
<<: *app
|
||||
pull_policy: never
|
||||
profiles: [reconcile]
|
||||
entrypoint: ["python", "-m", "messenger.attachments.entrypoints.reconcile"]
|
||||
command: ["--dry-run"]
|
||||
environment:
|
||||
<<: *s3-env
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
S3_READ_TIMEOUT_SECONDS: ${RECONCILE_S3_READ_TIMEOUT_SECONDS:-10}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||
secrets: [database_url, s3_access_key_id, s3_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
|
||||
entrypoint: ["/bin/sh", "/s3/init.sh"]
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
## 4. Стенд
|
||||
|
||||
- [ ] 4.1 `compose.yaml`: сервис `reconciler` (профиль `reconcile`), `cpuset` из переменных у `s3`, `postgres`, `reconciler`; `.env.example`
|
||||
- [ ] 4.2 Цели `make reconcile ARGS=…`, `make reconcile-demo`, `make reconcile-cost`
|
||||
- [ ] 4.3 Проверка группы: `docker compose config --quiet`, `make up`, `make reconcile`
|
||||
- [x] 4.1 `compose.yaml`: сервис `reconciler` (профиль `reconcile`), `cpuset` из переменных у `s3`, `postgres`, `reconciler`; `.env.example`
|
||||
- [x] 4.2 Цели `make reconcile ARGS=…`, `make reconcile-demo`, `make reconcile-cost`
|
||||
- [x] 4.3 Проверка группы: `docker compose config --quiet`, `make up`, `make reconcile`
|
||||
|
||||
## 5. Обвязка трека
|
||||
|
||||
|
||||
+9
-1
@@ -22,6 +22,11 @@ POLICY = {
|
||||
"networks": ["backend"],
|
||||
},
|
||||
"migrate": {"secrets": ["database_url"], "volumes": [], "networks": ["backend"]},
|
||||
"reconciler": {
|
||||
"secrets": ["database_url", "s3_access_key_id", "s3_secret_access_key"],
|
||||
"volumes": [],
|
||||
"networks": ["backend"],
|
||||
},
|
||||
"postgres": {"secrets": ["postgres_password"], "volumes": ["pgdata"], "networks": ["backend"]},
|
||||
"valkey": {"secrets": ["valkey.conf"], "volumes": ["valkeydata"], "networks": ["backend"]},
|
||||
"k6": {"secrets": [], "volumes": [], "networks": ["edge"]},
|
||||
@@ -120,6 +125,8 @@ def main():
|
||||
"bench",
|
||||
"--profile",
|
||||
"tools",
|
||||
"--profile",
|
||||
"reconcile",
|
||||
"config",
|
||||
"--format",
|
||||
"json",
|
||||
@@ -134,7 +141,8 @@ def main():
|
||||
problems.append("no running api replicas to inspect")
|
||||
lines = [
|
||||
f"date: {time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())}",
|
||||
"$ docker compose --profile bench --profile tools config --format json (declared)",
|
||||
"$ docker compose --profile bench --profile tools --profile reconcile config --format json"
|
||||
" (declared)",
|
||||
*table(["service", "cpus/mem", "ports", "secrets", "volumes", "networks", "ro"], services),
|
||||
"",
|
||||
"$ docker inspect (running containers: hostname = X-Instance-Id, applied limits)",
|
||||
|
||||
Reference in New Issue
Block a user