Give up a distinct degraded result and retry rails steps

Closes #38 (closed)

What changes

up now ends in one of three states, and a failed later step no longer looks like a lab that never came up.

flowchart TD
  A[up starts] --> B{External HTTP gate passes?}
  B -- no --> F[failed: exit 1]
  B -- yes --> C[rails_config, license, aigw]
  C -- all pass --> D{final_http passes?}
  D -- yes --> R[ready: exit 0]
  D -- no --> F
  C -- a step fails --> E{Signal, or no probe answers?}
  E -- yes --> F
  E -- no --> G[degraded: exit 3, failed_step kept]
  • degraded, exit 3. The external HTTP gate passed, then rails_config, license or aigw failed, and the lab still answers a probe. State keeps phase: degraded and failed_step. Run the step alone or tear down.
  • failed, exit 1. Anything before the gate, a signal, a lab that stops answering, or a failure at final_http.
  • status --json keeps schema 9; no key is added.

The rails_config cause

The failure was a transport error on the Rails command path. Each Rails command is a gcloud compute ssh call that runs kubectl exec into the toolbox pod, so the pods rolling is not on the path. Measured on a caproni rig:

Run Result
up on the baseline engine rails_config passed, with the webservice restart done about 20 s before the step
Control: rails-config alone on the settled rig rc 0
Pods rolling: restart webservice and sidekiq, then rails-config at once rc 0 in 106 s
Injected local gcloud SSLEOFError (baseline engine) rc 1, no retry
Injected ssh exit 255 (baseline engine) rc 255, no retry
Same two injections (this change) rc 0, with the retry lines logged

The rolling-pods candidate is falsified: the control and the rolling arm match. The earlier failure left a local SSLEOFError from gcloud during the token mint. vm_ssh's 255 retry never ran under set -e (rc=$? is not reached), and gcloud's own errors were never retried.

The fix reruns the idempotent whitelist write and the root token mint whole, up to five times, sending the script again each time. vm_ssh also skips its own retry when a script arrives on stdin, because a second try would send nothing. I did not reproduce the original failure unprompted; the cause is shown by the injected faults, the settled-rig control and the earlier log.

Live proof

  • Caproni progress (MR 165's path): polled status --json every 30 s during up; step_index advanced 1 to 10, then ready. status --json --live listed 11 components, none not ready.
  • Forced degraded: with every Rails call failing, up retried five times and ended phase: degraded, failed_step: rails_config, exit 3. Status read live there too. All rigs are down.

Tests

The new engine selftest sections go red without the change: 16 checks fail on the baseline engine (the degraded exit, phase, log line and status reading on caproni and omnibus; the retry counts, logged attempts, token in state and the five-attempt give-up). With the change the selftest passes. operations.md gives up three sentences to pay for the new text (word budget 40486 of 40489).

Merge request reports

Loading
Loading