ops: teardown.sh fails on prevent_destroy and sweeps protected snapshots #610

Stängd
öppnade 2026-10-08 21:12:22 +00:00 av supernaut · 0 kommentarer
Ägare

What

scripts/teardown.sh runs tofu destroy, then sweeps leftover OpenStack objects, then runs openstack-cost.py audit --expect-empty. The root, backup, data and LFS volumes and the monitoring root volume have prevent_destroy = true (opentofu/compute.tofu:28,52,74,93, monitoring.tofu:126).

Why

The script and its docs still claim destroy removes the volumes (script header, compute.tofu:7-10, docs/runbook.md:2981). Under set -e step 1 aborts, so the sweep and the audit never run.

Failing case

  • scripts/teardown.sh --yes fails at plan time with "Instance cannot be destroyed" and exits 1. Only --skip-tofu goes on. That path deletes volumes behind tofu's back and leaves state pointing at deleted IDs.
  • Only sweep_volumes consults PROTECTED_VOLUME_NAMES. The snapshot, volume-backup and private-image sweeps (:146-148) delete everything. docs/runbook.md makes predrill-<volume>-<date> snapshots of the data, backup and LFS volumes as the rollback for a resize. A later teardown.sh --yes deletes them.
  • The protected name list is a literal copy of the names in the tofu files.

Fix

Pick one model and apply it. Skip snapshots and backups whose volume maps to a protected name, using the lookup sweep_volumes uses. Correct the three stale statements.

Done when

  • teardown.sh --yes on a staging copy runs to the end and the audit passes.
  • Protected volumes' snapshots and backups survive --yes.
  • Header, compute.tofu comment and runbook match the behaviour.
  • A self-test covers the prevent_destroy path.

Plan outline

  1. Choose the model: a temp copy of the tofu dir without prevent_destroy under --include-data-volumes, or a non-fatal destroy that stops with a manual data-volume step.
  2. Skip protected volumes' snapshots and backups in the sweeps, deriving the protected names from tofu output instead of a literal.
  3. Fix the stale statements in the script header, compute.tofu:7-10 and docs/runbook.md:2981.
  4. Add a self-test that fails when prevent_destroy blocks the run (like tofu-apply.sh --self-test).
  5. Run it on the staging root only before touching prod.
## What `scripts/teardown.sh` runs `tofu destroy`, then sweeps leftover OpenStack objects, then runs `openstack-cost.py audit --expect-empty`. The root, backup, data and LFS volumes and the monitoring root volume have `prevent_destroy = true` (`opentofu/compute.tofu:28,52,74,93`, `monitoring.tofu:126`). ## Why The script and its docs still claim destroy removes the volumes (script header, `compute.tofu:7-10`, `docs/runbook.md:2981`). Under `set -e` step 1 aborts, so the sweep and the audit never run. ## Failing case - `scripts/teardown.sh --yes` fails at plan time with "Instance cannot be destroyed" and exits 1. Only `--skip-tofu` goes on. That path deletes volumes behind tofu's back and leaves state pointing at deleted IDs. - Only `sweep_volumes` consults `PROTECTED_VOLUME_NAMES`. The snapshot, volume-backup and private-image sweeps (`:146-148`) delete everything. `docs/runbook.md` makes `predrill-<volume>-<date>` snapshots of the data, backup and LFS volumes as the rollback for a resize. A later `teardown.sh --yes` deletes them. - The protected name list is a literal copy of the names in the tofu files. ## Fix Pick one model and apply it. Skip snapshots and backups whose volume maps to a protected name, using the lookup `sweep_volumes` uses. Correct the three stale statements. ## Done when - [ ] `teardown.sh --yes` on a staging copy runs to the end and the audit passes. - [ ] Protected volumes' snapshots and backups survive `--yes`. - [ ] Header, `compute.tofu` comment and runbook match the behaviour. - [ ] A self-test covers the prevent_destroy path. ## Plan outline 1. Choose the model: a temp copy of the tofu dir without `prevent_destroy` under `--include-data-volumes`, or a non-fatal destroy that stops with a manual data-volume step. 2. Skip protected volumes' snapshots and backups in the sweeps, deriving the protected names from tofu output instead of a literal. 3. Fix the stale statements in the script header, `compute.tofu:7-10` and `docs/runbook.md:2981`. 4. Add a self-test that fails when `prevent_destroy` blocks the run (like `tofu-apply.sh --self-test`). 5. Run it on the staging root only before touching prod.
supernaut 2026-10-19 19:13:34 +00:00
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#610
Ingen beskrivning angiven.