caelum0x 56d7ae631f fix(terraform): ledger-core/audit-log's rolling-deployment config let two tasks with disjoint disks run concurrently
infra/terraform/modules/service hardcoded deployment_minimum_healthy_percent=100
and deployment_maximum_percent=200 for every service, including ledger-core and
audit-log — both explicitly documented in their own env-file comments as
"single-writer, not horizontally scaled" and backed by a local WAL/hash-chain on
Fargate ephemeral storage with no replication between tasks. That rolling config
let ECS run the old task and a brand-new, empty-disk task concurrently for the
length of every deploy's health-check window, both reachable under the same
Cloud Map service-discovery name.

Reproduced live: started two real ledger-core processes (one seeded with a real
tenant+balance simulating the pre-deploy task, one against a fresh empty data
dir simulating the new Fargate task on fresh ephemeral storage) and called
GetBalance for the identical tenant_id against both — the "old" task returned
the real balance, the "new" task returned NotFound, with no way for a caller to
tell "tenant genuinely doesn't exist" apart from "this task's disk never saw it
because it's a brand new task from this exact deploy." Any write ECS routes to
the old task in that overlap window is lost the moment the old task is stopped.

Fix: added deployment_minimum_healthy_percent/deployment_maximum_percent as
module variables (default 100/200, preserving today's rolling behavior for
stateless services), and overrode them to 0/100 ("recreate" semantics — old task
fully stopped before the new one starts) for module.ledger_core and
module.audit_log in all three envs (dev/staging/prod).

Verified: terraform validate clean for the module and all three envs;
terraform plan reaches the expected provider-auth wall (this repo's own
documented verification ceiling — no AWS credentials available) with no
configuration errors before that point; terraform fmt -check -recursive clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-29 20:03:00 +03:00
..