Repository navigation
Plan + code to shut down the dfc server (move Vault, Redash, state DB, DNS to dfc2), no-op until switched on - #28
atalyaalon wants to merge 3 commits into
Conversation
…ounted check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
ab3d5c7 to
580be61
Compare
…lip) - copy apps/vault, apps/redash, apps/cluster-admin to apps-dfc2, marked x-skip-deploy-all so deploy_all_apps never starts them with empty data - dfc2 traefik: oway.org.il redirect; dfc2 anyway: also answer airflow, airflow-data and reports .anyway.co.il - Terraform: per-service moved_to_dfc2 flags in modules.tf (all false, so no change) switching the Route53 records and adding Cloudflare CNAMEs for vault/redash on dfc2 - dev partial dumps reader can also read the dfc2 partial bucket - docs/DECOMMISSION_DFC.md: step-by-step runbook, checks, rollbacks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
- exact -target addresses for the DNS step (never -target=module.anyway, which would also apply unrelated pending changes) - copy files with plain ssh helpers and sha256sum checks: bin/apps*.py ssh uses -t and prints OK, which corrupts copied files - Redash: keep its Postgres running for the dump; data source via the internal docker network - restart traefik and check the certificate after each DNS switch - Phase 0: VAULT_ADDR secret, backend sslmode, wildcard names, Docker version, Terraform freeze; pg_stat_activity instead of ss - state DB: stop the old DB right after the dump, wait for pg_isready - Phase 2: move dfc's anyway cron files away; expect backup alerts - tar --numeric-owner, clean up dumps on both servers, typo Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
- bin/apps-dfc2.py: strip \r from server: secrets (read through ssh -t), which corrupted multi-line values like the Vault unseal keys - runbook: moving the shared VPC and security group out of module.dfc is required (confirmed same IDs), not conditional - flag that the shared security group exposes 9001/9002 to the internet - do #26/#29 before Phase 1 or after the move (dfc2 restarts would take down Terraform's own backend), don't restart traefik repeatedly - manual unseal fallback; re-run deploys that failed while Vault moved Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
…ounted check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV
580be61 to
1db5b24
Compare
|
@tkalir @ziv17, a question before this PR moves DNS and shuts down the dfc server: which hostnames, and which server, do we want to keep? It also decides which database the PostgreSQL 18 upgrade (data-for-change/anyway#2964) migrates, and how much space dfc2 needs before #29 shrinks Today, from
|
| Hostname | Served by |
|---|---|
anyway.co.il (apex), plus www.anyway.co.il → redirect to the apex (b144ce7, 6 Nov; #33 now serves API and login paths on www directly) |
dfc2 |
safety-data.anyway.co.il |
dfc2 |
airflow.anyway.co.il, airflow-data.anyway.co.il, reports.anyway.co.il, ws.anyway.co.il |
old dfc |
www.dfc2., airflow.dfc2., airflow-data.dfc2., reports.dfc2., safety-data.dfc2.anyway.co.il |
dfc2 |
Each server runs its own Airflow, ETL and DB. The public site reads dfc2's DB, while airflow.anyway.co.il still points at the old dfc server's Airflow, which writes to its own DB. This PR adds airflow, airflow-data and reports.anyway.co.il as extra names on dfc2.
Questions
- Long-term names: do we keep the original names (
anyway.co.il,airflow.anyway.co.il,reports.anyway.co.il…) and drop the*.dfc2.anyway.co.ilones? The other way round? Or both, as aliases? And is the apexanyway.co.ilthe canonical site address? Allow https://anyway.co.il in CORS and post-login redirects anyway#2966 assumes it is. - Which DB is authoritative now: is dfc2's DB the real production data? Does anything still use the old dfc server's DB or its Airflow: Redash, ETL alerts, people working in
airflow.anyway.co.il? - Old dfc DB: if it's no longer needed, the PG 18 migration would be done only on dfc2, and this PR would shut down the old server without migrating its DB. Does that sound right?
Suggested order, if you agree
- Wait for and check the 1 Dec monthly backup.
- Do the PG 18 migration on dfc2 (anyway#2964 runbook).
- Do Plan + code to shut down the dfc server (move Vault, Redash, state DB, DNS to dfc2), no-op until switched on #28 (this PR).
- Do dfc2: prepare moving /data to a smaller disk (500 GB → ~250 GB), no-op until the size is set #29 (smaller disk), then dfc2: move to a cheaper instance type (m6a.large → t3a.large), only once the measurements allow it #26 (instance type).
#29 should come after PG 18, because the migration needs room for the old and new data directories plus a dump at the same time. It should also come after this PR, because this PR adds Vault, Redash and the state DB data to dfc2's /data.
Same question on the PG 18 PR: data-for-change/anyway#2964 (comment)
Generated by Claude Code
Related PRs
main. Urgent.Stacked on #25 (base
claude/laughing-galileo-165xk1-monitoring), so this diff shows only this PR's changes.What's in it
1. Runbook:
docs/DECOMMISSION_DFC.md(start here)Rules for every step:
terraform apply; only the exact-targets givensshhelpers andsha256sumchecksPhase 0: checks only.
pg_stat_activity.VAULT_ADDRGitHub secret, the backendsslmode, the names on dfc's*wildcard, and the Docker version.Phase 1: move the services, one at a time, in this order:
After each DNS switch: restart traefik and check the certificate. Each step includes its checks and a rollback.
Phase 2: stop dfc's anyway stack and move its cron files away. Reversible.
Phase 3: code clean-up: workflows,
apps/, and the anyway repo's dump bucket.Phase 4: delete dfc with Terraform.⚠️ dfc2 may share the VPC and security group that
module.dfccreates, and the*wildcard goes away. Both must be handled first; the runbook has the exact checks.2. On/off switches:
modules.tfmoved_to_dfc2map with one switch per service, allfalse:redashandvault: Cloudflare CNAMEs that override dfc's*wildcardairflow,reports,wsandoway: the Route53 records inmodules/anyway/dns.tf-target.3. Apps copied to dfc2:
apps-dfc2/vault,apps-dfc2/redash,apps-dfc2/cluster-adminapps/…, markedx-skip-deploy-all: true.bin/apps-dfc2.py deploy_all_appsnow skips them, so they can never start by accident with an empty data folder. They're deployed only one by one, withdeploy_app, after their data is copied. I tested this:deploy_all_appswould deploy onlyanyway,seleniumandtraefik.4. dfc2 answers the remaining hostnames
apps-dfc2/anyway/compose.yaml: the airflow, airflow-data and reports routers also accept the*.anyway.co.ilnames.apps-dfc2/traefik: a newoway_redirects.yamlredirectsoway.org.ilandwww.oway.org.iltoanyway.co.il.5. Developer dump access
partial_db_dumps_readercan also readdfc2-anyway-partial-db-dumps. That's needed when developers switch to dfc2's dumps in Phase 3.Before any terraform apply
The read-only
terraform planshows manual AWS changes that an apply would undo. This isn't caused by this PR: the same happens when applying #24, #25 or #26.dfc2-anyway-db-dumps-readergot read access to thedfc-anyway-cbsbucket, plus a tag "Ziv keys to create local db volume", by hand. An apply removes both.*._domainkey.anyway.co.il): an apply rewrites them with a trailing dot and TTL 1800 → 300. Probably harmless.modules/anyway/aws_db_dumps_users.tf.Review
Reviewed by a separate agent, read-only. Code: ready. The production impact claims: accurate (wording corrected above).
Runbook findings, all fixed:
-target=module.anyway, which would also have applied Reduce DB backup costs: monthly dumps + expire dumps older than 1 year #24's dump deletion and Free uptime + DB backup monitoring, remove paid Route53 health checks #25's health check removal, and undone Ziv's access. It now targets the exact records.bin/apps*.py sshrunsssh -tand printsOK, which corrupts copied files (dumps, Vault data, unseal keys). The runbook now uses plainsshhelpers andsha256sumchecks.VAULT_ADDRsecret, the backendsslmode, the wildcard names and the Docker version; the Terraform freeze andpg_isready;pg_stat_activityinstead ofss; moving dfc's cron files away in Phase 2;tar --numeric-owner; dump clean-up on both servers.Conditions to merge
Testing
terraform plan(CI, read-only) on this branch:deploy_all_apps: tested with a stubbeddeploy_app. It skips the 3 copied apps.🤖 Generated with Claude Code
https://claude.ai/code/session_01XtN7GhfRRihvBTHsWxGZoV