RouterOS: in-graph arm + on-box self-judging rollback timer #74

Closed
opened 2026-11-14 01:41:48 +00:00 by ginjiruu · 1 comment
Owner

Part of #43

Refs: #45, #46, #63 (CHR sim), #65 (controller objects), #66 (import)

Revised 2026-11-13 for air-gapped use with no outside orchestration. Replaces the first draft's cluster-side confirmer.

Constraints

  • tofu-controller (api/v1alpha2, main) has no pre- or post-apply hooks. healthChecks are post-apply TCP/HTTP probes that only mark the object not Ready. runnerPodTemplate.initContainers runs on every reconcile, including no-op plans. Neither can arm or roll back.
  • No chained Kustomizations or Jobs: those count as orchestration.
  • RouterOS Safe Mode is tied to a terminal session and isn't available over REST. RouterOS has no rollback menu.

Design: hooks inside the Terraform graph, decision on the router

  1. Arm. terraform_data.arm, triggers_replace = hash of the rendered device config, so it runs only when the config changes. local-exec through REST: save a backup pre-<hash>, then create a script and a scheduler rollback-<hash> with start-time now + N.
    • lifecycle.precondition reads the routeros_files data source and fails if rolled-back-<hash> exists. This is the re-apply loop guard.
  2. Config. The device module has depends_on = [terraform_data.arm].
  3. Router decides. When the scheduler fires, the script reads /tool netwatch status (k8s API VIP, a node, internal DNS, the peer router, the WAN or local anchor).
    • All up: delete the backup and the scheduler. The change is committed.
    • Any down: write rolled-back-<hash>, then /system backup load.
  4. Optional early disarm. terraform_data.confirm depends on the module and deletes the scheduler once its own REST probe succeeds.

Nothing off the router has to answer. It also works when the cluster is the thing that's down.

Open, verify in CHR sim (#63)

  • Whether backup load keeps the same .ids. Mitigation if not: provider import resolves by name or field (#66).
  • netwatch probe types available on the pinned RouterOS 7 version (http-get, dns).
  • Size N against measured plan and apply time.
  • Backup password comes from OpenBao, never from git.
  • Never arm both routers at once. The precondition checks the peer for an armed rollback-* scheduler.
  • Air-gap: provider and tofu baked into the runner image through a filesystem provider_installation mirror.
Part of #43 Refs: #45, #46, #63 (CHR sim), #65 (controller objects), #66 (import) Revised 2026-11-13 for air-gapped use with no outside orchestration. Replaces the first draft's cluster-side confirmer. ## Constraints - tofu-controller (`api/v1alpha2`, main) has no pre- or post-apply hooks. `healthChecks` are post-apply TCP/HTTP probes that only mark the object not Ready. `runnerPodTemplate.initContainers` runs on every reconcile, including no-op plans. Neither can arm or roll back. - No chained Kustomizations or Jobs: those count as orchestration. - RouterOS Safe Mode is tied to a terminal session and isn't available over REST. RouterOS has no rollback menu. ## Design: hooks inside the Terraform graph, decision on the router 1. **Arm.** `terraform_data.arm`, `triggers_replace` = hash of the rendered device config, so it runs only when the config changes. local-exec through REST: save a backup `pre-<hash>`, then create a script and a scheduler `rollback-<hash>` with start-time now + N. - `lifecycle.precondition` reads the `routeros_files` data source and fails if `rolled-back-<hash>` exists. This is the re-apply loop guard. 2. **Config.** The device module has `depends_on = [terraform_data.arm]`. 3. **Router decides.** When the scheduler fires, the script reads `/tool netwatch` status (k8s API VIP, a node, internal DNS, the peer router, the WAN or local anchor). - All up: delete the backup and the scheduler. The change is committed. - Any down: write `rolled-back-<hash>`, then `/system backup load`. 4. **Optional early disarm.** `terraform_data.confirm` depends on the module and deletes the scheduler once its own REST probe succeeds. Nothing off the router has to answer. It also works when the cluster is the thing that's down. ## Open, verify in CHR sim (#63) - Whether `backup load` keeps the same `.id`s. Mitigation if not: provider import resolves by name or field (#66). - netwatch probe types available on the pinned RouterOS 7 version (http-get, dns). - Size N against measured plan and apply time. - Backup password comes from OpenBao, never from git. - Never arm both routers at once. The precondition checks the peer for an armed `rollback-*` scheduler. - Air-gap: provider and tofu baked into the runner image through a filesystem `provider_installation` mirror.
ginjiruu changed title from RouterOS: armed rollback timer + cluster-confirmed applies (commit-confirm) to RouterOS: in-graph arm + on-box self-judging rollback timer 2026-11-14 01:54:57 +00:00
Author
Owner

ADR-0009: a cert rotation is a normal Terraform change, so it is armed like any other apply. A bad cert or binding that breaks REST stops the cluster confirming and rolls back on the router's timer.

ADR-0009: a cert rotation is a normal Terraform change, so it is armed like any other apply. A bad cert or binding that breaks REST stops the cluster confirming and rolls back on the router's timer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/iac#74
No description provided.