24. The server can be replaced
The whole platform can be rebuilt on a fresh machine from the tools repo, one bundle of secrets, and one backup.
Nothing refers to the machine: a rehearsal restores everything onto a scratch box and checks every app answers. Its verdict reaches each app in the fact backup.json.
This is the code serving the zoo right now: the bytes this very program was built from (each file is embedded when the zoo is compiled), at commit
55c71513c5 (staging). The zoo's own self-check fetches this page and compares it byte for byte with the file it runs.
e24_replaceable.odin sha256 f1da144ec3e0 · raw
1package main 2 3// Exhibit 24. `rc rehearse` rebuilds the whole platform on a scratch machine from the tools repo, the 4// secrets bundle and the newest backup, and records the verdict. Root copies it into every app's fact 5// backup.json (rehearsal, rehearsal_last_pass). 6 7import "core:fmt" 8import "ratcloud:rc" 9 10e24 :: proc() -> Exhibit { 11 return { 12 n = 24, wing = "Operations", 13 title = "The server can be replaced", 14 promise = "The whole platform can be rebuilt on a fresh machine from the tools repo, one bundle of secrets, and one backup.", 15 block = "Nothing refers to the machine: a rehearsal restores everything onto a scratch box and checks every app answers. Its verdict reaches each app in the fact backup.json.", 16 src = {"e24_replaceable.odin", #load("e24_replaceable.odin", string)}, 17 show = proc(me: ^rc.User) -> string { 18 b := fact("backup.json") 19 last := jget(b, "rehearsal") 20 if !jhas(b, "rehearsal") do return `<p class="muted">No rehearsal has been recorded yet.</p>` 21 p := jget(b, "rehearsal_last_pass") 22 return fmt.tprintf("<p>Last rehearsal %s: <b>%s</b>.%s</p>", ago(parse_time(jstr(last, "at"))), "everything came back" if jstr(last, "result") == "pass" else "it failed", 23 cat(" Last one that passed: ", ago(parse_time(jstr(p, "at"))), ".") if jhas(b, "rehearsal_last_pass") else "") 24 }, 25 check = proc() -> Check { 26 b := fact("backup.json") 27 if !jhas(b, "rehearsal_last_pass") do return fail("no rehearsal has passed yet") 28 days := (now() - parse_time(jstr(b, "rehearsal_last_pass", "at"))) / 86400 29 // Green within 14 days, amber (a warning, not an alarm) up to 90, red after. The Mac runs it weekly (tools/dev/rehearse-weekly.sh). 30 if days > 90 do return fail(fmt.tprintf("the last passing rehearsal was %d days ago", days)) 31 if days > 14 do return pass(fmt.tprintf("the last rehearsal that passed was %d days ago: due", days), struct { 32 amber: bool `json:"amber"`, 33 }{true}) 34 return pass(fmt.tprintf("the last rehearsal that passed was %d day(s) ago", days)) 35 }, 36 } 37}