package main // Exhibit 24. `rc rehearse` rebuilds the whole platform on a scratch machine from the tools repo, the // secrets bundle and the newest backup, and records the verdict. Root copies it into every app's fact // backup.json (rehearsal, rehearsal_last_pass). import "core:fmt" import "ratcloud:rc" e24 :: proc() -> Exhibit { return { n = 24, wing = "Operations", title = "The server can be replaced", promise = "The whole platform can be rebuilt on a fresh machine from the tools repo, one bundle of secrets, and one backup.", 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.", src = {"e24_replaceable.odin", #load("e24_replaceable.odin", string)}, show = proc(me: ^rc.User) -> string { b := fact("backup.json") last := jget(b, "rehearsal") if !jhas(b, "rehearsal") do return `

No rehearsal has been recorded yet.

` p := jget(b, "rehearsal_last_pass") return fmt.tprintf("

Last rehearsal %s: %s.%s

", ago(parse_time(jstr(last, "at"))), "everything came back" if jstr(last, "result") == "pass" else "it failed", cat(" Last one that passed: ", ago(parse_time(jstr(p, "at"))), ".") if jhas(b, "rehearsal_last_pass") else "") }, check = proc() -> Check { b := fact("backup.json") if !jhas(b, "rehearsal_last_pass") do return fail("no rehearsal has passed yet") days := (now() - parse_time(jstr(b, "rehearsal_last_pass", "at"))) / 86400 // 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). if days > 90 do return fail(fmt.tprintf("the last passing rehearsal was %d days ago", days)) if days > 14 do return pass(fmt.tprintf("the last rehearsal that passed was %d days ago: due", days), struct { amber: bool `json:"amber"`, }{true}) return pass(fmt.tprintf("the last rehearsal that passed was %d day(s) ago", days)) }, } }