Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
# Conflicts: # internal/provision/plan9_b8_census_test.go # internal/provision/testdata/plan14-root-reads-chain.tsv
14 files changed,
+1,100
−83
docs/superpowers/notes/census-claims-member-backups-drill-nodb.tsv+6 −0docs/superpowers/notes/census-proposal-member-backups-drill-nodb.md+23 −0docs/superpowers/notes/census-proposal-platform-mail-submission.md+1 −1internal/dbverify/dbverify.go+62 −9internal/dbverify/dbverify_test.go+112 −0internal/metrics/verify_test.go+18 −0internal/ops/hibernate_verify.go+166 −39internal/ops/hibernate_verify_run_test.go+445 −4internal/ops/hibernate_verify_test.go+140 −5internal/ops/ops.go+71 −22internal/provision/member_backups_drill_nodb_census_test.go+43 −0internal/provision/platform_mail_submission_census_test.go+2 −2internal/provision/testdata/plan14-root-reads-chain.tsv+2 −1internal/provision/testdata/plan14-root-reads-member-backups-drill-nodb.tsv+9 −0
diff --git a/docs/superpowers/notes/census-claims-member-backups-drill-nodb.tsv b/docs/superpowers/notes/census-claims-member-backups-drill-nodb.tsv| new file mode 100644 |
| index 000000000..869257059 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-member-backups-drill-nodb.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census claims for the restore drill fix after the first drill night (#898), 2026-11-13, with Astra round 1 fixes. <file>:<unit> TAB <what changed>. |
| +# Who runs what: the drill is carlos-hibernate-verify.service (User=carlos, oneshot). hibernateRun.run still refuses euid 0 first, |
| +# before any monitor file, store or registry is touched, so none of this runs as root in the shipped unit. |
| +# Round 1 census verdict (Astra): APPROVE. Round 1 fixes re-digest both units; no read source is added. |
| +internal/ops/ops.go:hibernateRun.run the drill (user carlos). No read added or changed, same refusals in the same order (root first, then self.json, then the region gate). One new exit: when openDeployStore answers errNoDeployStore (neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR set) and Fleet (CARLOS_FLEET trimmed, read once in runHibernateVerify) is non-empty, it prints one line and returns 0 before the registry is opened, publishing nothing. Any other store error, and a platform box with no store, still log NOT RUN and return 1. The record it already loaded (dbverify.Load of its own control/verify/<ref>.json) is also handed to the drill as Drill.Prior, read only to refuse a leave-out for an incarnation that once had data. The publisher now takes RunResults and merges with dbverify.MergeLeftOut: hosts the run left out (no database) go to the record's additive left_out field instead of hosts, written by the same PublishOver Put of control/verify/<ref>.json and the same local copy <data>/monitor/verify.json; the summary lines count them. |
| +internal/ops/hibernate_verify.go:noDatabase new, the drill (user carlos): os.Lstat of a hibernating route's DBPath from this box's own registry (the path HibernatingHosts already returns and freshness already reads through localFreshness), only when the path is absolute (a relative or empty path answers false with no syscall); only its error is looked at, nothing is opened or followed (lstat does not follow a final symlink). Called once per host, only in drillOne's final restoreNothing case after the identity bracket and the move staging closed clean; not-exist leaves the host out of the record only if, for an HA route, this box holds the lease (the same lockState read freshness makes) and the prior record shows no data for the incarnation; anything else keeps unverified/nothing_replicated. |
diff --git a/docs/superpowers/notes/census-proposal-member-backups-drill-nodb.md b/docs/superpowers/notes/census-proposal-member-backups-drill-nodb.md| new file mode 100644 |
| index 000000000..86d9d70f9 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-member-backups-drill-nodb.md |
| @@ -0,0 +1,23 @@ |
| +# Census approval: member-backups-drill-nodb |
| + |
| +Ruling `census-ruling-member-backups-drill-nodb`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/ops/ops.go` `hibernateRun.run` | body | unchanged (1) | the drill (user carlos). No read added or changed, same refusals in the same order (root first, then self.json, then the region gate). One new exit: when openDeployStore answers errNoDeployStore (neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR set) and Fleet (CARLOS_FLEET trimmed, read once in runHibernateVerify) is non-empty, it prints one line and returns 0 before the registry is opened, publishing nothing. Any other store error, and a platform box with no store, still log NOT RUN and return 1. The record it already loaded (dbverify.Load of its own control/verify/<ref>.json) is also handed to the drill as Drill.Prior, read only to refuse a leave-out for an incarnation that once had data. The publisher now takes RunResults and merges with dbverify.MergeLeftOut: hosts the run left out (no database) go to the record's additive left_out field instead of hosts, written by the same PublishOver Put of control/verify/<ref>.json and the same local copy <data>/monitor/verify.json; the summary lines count them. | |
| + |
| +Envelopes re-pinned: `internal/dbverify`, `internal/ops`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/ops/ops.go` `hibernateRun.run`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-member-backups-2a;basis=new, the drill (carlos ops hibernate-verify, user carlos): the verb's body, moved out of runHibernateVerify so a test can run it whole. First of all it refuses root (Root, from os.Geteuid() == 0 in runHibernateVerify): one log line, exit 1, before any monitor file is read, the deployment store opened or the registry opened (census round 1 P1, ls284: self.json, which the carlos user writes, names the record a run replaces). Then, as before: boxself.ReadFresh of self.json (refuses to run without a fresh record), dbreads.ValidRegion(CARLOS_REGION), openDeployStore, registry.Open(RegPath) (its +file:Open, the same registry the old body opened, closed after HibernatingHosts), dbverify.Load of this box's own control/verify/<ref>.json, selectHosts (verify-assign.json on a group box), MkdirTemp under the unit's on-disk TMPDIR, the drill, and dbverify.Publish to control/verify/<ref>.json only. Final fix wave (still refusing root first): the self.json read is retried every 15 s for up to 5 minutes (SelfWait, the same boxself.ReadFresh), a fleet box's CARLOS_REGION fleet/<name> is accepted beside dbreads.ValidRegion, it calls clearCrashedScratch on its own TmpDir right after the root refusal and the hibernate-config check, before the self record and both empty-fleet returns (re-review item 9), and its publisher now writes through dbverify.PublishOver (the same Get-then-CAS Put of control/verify/<ref>.json, also parsing the record it reads to drop hosts a landing removed). No new read source.;rev3=census-ruling-member-backups-2a-landing;basis=R3 (#898): an empty CARLOS_REGION (a home-region box) is the home region and no longer refuses; the bracket matches records whose region is "" exactly. A malformed non-empty region still refuses (dbreads.ValidRegion, or a fleet/<name> placement). No read added or changed: the same refusals in the same order (root first, then self.json, then the region gate), the same stores. Package envelopes: internal/ops adds one read-only bounded ListPage (one key) of moves/<host>/ in the drill's own data bucket at each end of a host's bracket (R1), and the bracket compares the record's LastMove (R1b) and the record object's stamp (R1c: ETag, version id, last-modified) at open and close, all from the same record GET it already made (now provision.GetRecordStamped / GetSidecarRecordStamped); internal/provision adds those two read-only getters (decodeSidecarAt shared with GetSidecarRecord, no writer touched); internal/release adds GetStamped, S3Store.GetStamped and ObjectStamp; internal/lease adds VerifyReaderAt and a read-only litestream client (R2); internal/dbdoor adds PlanListed, the planner's listing as a list/open reader (R2). The drill runs as carlos and refuses root. |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/ops/hibernate_verify.go:noDatabase`: reads +file:Lstat; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376` → `07b748a749084fdaf61c5087a6edfca8a79273962822ce551dd4d42b0d20c063`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-member-backups-drill-nodb.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-platform-mail-submission.md b/docs/superpowers/notes/census-proposal-platform-mail-submission.md| index aec7a48a2..59cab5142 100644 |
| --- a/docs/superpowers/notes/census-proposal-platform-mail-submission.md |
| +++ b/docs/superpowers/notes/census-proposal-platform-mail-submission.md |
| @@ -6,6 +6,6 @@ Envelopes re-pinned: `.`. |
| Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| -Seal: `5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376` → `5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376`. |
| +Seal: `07b748a749084fdaf61c5087a6edfca8a79273962822ce551dd4d42b0d20c063` → `07b748a749084fdaf61c5087a6edfca8a79273962822ce551dd4d42b0d20c063`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/internal/dbverify/dbverify.go b/internal/dbverify/dbverify.go| index 84ce3d015..f911ca8f7 100644 |
| --- a/internal/dbverify/dbverify.go |
| +++ b/internal/dbverify/dbverify.go |
| @@ -164,11 +164,27 @@ func (v Verdict) OK() bool { return v.Result == ResultPassed } |
| func (v Verdict) Unverified() bool { return v.Result == ResultUnverified } |
| // Record is one box's standing at CheckedAt, at KeyFor(Box). |
| +// |
| +// LeftOut is the hosts the drill left out for having no database to back |
| +// up (nothing replicated, and no database where the drill can prove its |
| +// absence). It is scheduling history, not a verdict: no alert rule reads |
| +// it, and a host is in Hosts or in LeftOut, never both. It is additive: |
| +// the record stays v 2, every reader decodes it leniently, and a record |
| +// with none omits it. |
| type Record struct { |
| V int `json:"v"` // 2 |
| Box string `json:"box"` |
| CheckedAt time.Time `json:"checked_at"` |
| Hosts map[string]Verdict `json:"hosts"` |
| + LeftOut map[string]LeftOut `json:"left_out,omitempty"` |
| +} |
| + |
| +// LeftOut is when a run last left a host out, and the incarnation it found. |
| +// The drill orders the host by At, as if it had been decided then, so it |
| +// rotates behind hosts never seen or decided longer ago. |
| +type LeftOut struct { |
| + At time.Time `json:"at"` |
| + Incarnation string `json:"incarnation,omitempty"` |
| } |
| // Merge folds a run's verdicts into the prior record of box ref. prior may |
| @@ -200,15 +216,41 @@ type Record struct { |
| // three over. A result with no identity (zero) keeps the prior verdict's |
| // last known one; a prior with none is never "different". |
| func Merge(prior *Record, ref string, now time.Time, fleet []string, results map[string]Verdict) *Record { |
| + return MergeLeftOut(prior, ref, now, fleet, results, nil) |
| +} |
| + |
| +// MergeLeftOut is Merge with the hosts this run left out (no database to |
| +// back up). A fleet host in leftOut goes to the record's LeftOut and out |
| +// of Hosts, whatever its prior verdict. A fleet host the run did not |
| +// visit keeps what it had: its verdict, or else its LeftOut entry. Any |
| +// result this run, an abandoned attempt included, puts the host in Hosts |
| +// and takes it out of LeftOut, so a host that has a database again, or |
| +// that no run can finish, is counted rather than hidden. Hosts no longer |
| +// in fleet leave LeftOut as they leave Hosts. |
| +func MergeLeftOut(prior *Record, ref string, now time.Time, fleet []string, results map[string]Verdict, leftOut map[string]LeftOut) *Record { |
| now = now.UTC() |
| rec := &Record{V: 2, Box: ref, CheckedAt: now, Hosts: map[string]Verdict{}} |
| + addLeftOut := func(host string, lo LeftOut) { |
| + if rec.LeftOut == nil { |
| + rec.LeftOut = map[string]LeftOut{} |
| + } |
| + lo.At = lo.At.UTC() |
| + rec.LeftOut[host] = lo |
| + } |
| for _, host := range fleet { |
| var p Verdict |
| had := false |
| + var plo LeftOut |
| + wasLeftOut := false |
| if prior != nil { |
| p, had = prior.Hosts[host] |
| + plo, wasLeftOut = prior.LeftOut[host] |
| } |
| r, visited := results[host] |
| + if lo, out := leftOut[host]; out { |
| + addLeftOut(host, lo) |
| + continue |
| + } |
| switch { |
| case visited && r.Result == ResultUnverified && r.Reason == ReasonNotReached: |
| v := p |
| @@ -224,6 +266,8 @@ func Merge(prior *Record, ref string, now time.Time, fleet []string, results map |
| rec.Hosts[host] = mergeOne(p, had, r, now) |
| case had: |
| rec.Hosts[host] = p |
| + case wasLeftOut: |
| + addLeftOut(host, plo) |
| default: |
| rec.Hosts[host] = Verdict{Result: ResultUnverified, Reason: ReasonNotReached, FirstSeen: now} |
| } |
| @@ -314,9 +358,9 @@ func Load(ctx context.Context, s release.Store, ref string) (*Record, error) { |
| return &rec, nil |
| } |
| -// RemoveHost drops host's verdict from box ref's own record: a moved |
| -// instance's replica is no longer this box's to verify (moves spec §6.3, |
| -// §7.6 local). Other boxes' records are never touched; their verdicts for |
| +// RemoveHost drops host's verdict, or its LeftOut entry, from box ref's |
| +// own record: a moved instance's replica is no longer this box's to |
| +// verify (moves spec §6.3, §7.6 local). Other boxes' records are never touched; their verdicts for |
| // the host leave at their next run, when Merge drops hosts no longer in |
| // their fleet. The load, the delete and the put run inside each CAS |
| // attempt (moves Plan 2 ruling G31), so a record changed between the read |
| @@ -339,10 +383,13 @@ func RemoveHost(ctx context.Context, s release.Store, ref, host string) error { |
| if err := json.Unmarshal(body, &rec); err != nil { |
| return fmt.Errorf("parse %s: %w", key, err) |
| } |
| - if _, ok := rec.Hosts[host]; !ok { |
| + _, inHosts := rec.Hosts[host] |
| + _, inLeftOut := rec.LeftOut[host] |
| + if !inHosts && !inLeftOut { |
| return nil |
| } |
| delete(rec.Hosts, host) |
| + delete(rec.LeftOut, host) |
| next, err := json.Marshal(&rec) |
| if err != nil { |
| return err |
| @@ -365,9 +412,10 @@ func Publish(ctx context.Context, s release.Store, rec *Record) error { |
| } |
| // PublishOver is Publish for a writer whose rec was built from an earlier |
| -// read of the record: known is the hosts that read held. Inside each CAS |
| -// attempt it reads the record now in the bucket, and every host in known |
| -// that the record no longer has was removed by someone else since (a |
| +// read of the record: known is the hosts that read held, in Hosts or |
| +// LeftOut (a removal clears either). Inside each CAS attempt it reads the |
| +// record now in the bucket, and every host in known that the record no |
| +// longer has, in either, was removed by someone else since (a |
| // landing move's RemoveHost, the record's only other writer): it is |
| // deleted from rec, so the publish does not put it back, and returned in |
| // dropped. Hosts not in known are rec's own news and are kept. A record |
| @@ -389,11 +437,16 @@ func PublishOver(ctx context.Context, s release.Store, rec *Record, known map[st |
| var now Record |
| if json.Unmarshal(cur, &now) == nil { |
| for _, h := range sortedHosts(known) { |
| - if _, still := now.Hosts[h]; still { |
| + _, still := now.Hosts[h] |
| + _, stillOut := now.LeftOut[h] |
| + if still || stillOut { |
| continue |
| } |
| - if _, ok := rec.Hosts[h]; ok { |
| + _, inHosts := rec.Hosts[h] |
| + _, inLeftOut := rec.LeftOut[h] |
| + if inHosts || inLeftOut { |
| delete(rec.Hosts, h) |
| + delete(rec.LeftOut, h) |
| dropped = append(dropped, h) |
| } |
| } |
diff --git a/internal/dbverify/dbverify_test.go b/internal/dbverify/dbverify_test.go| index 5caf92150..43229bc8f 100644 |
| --- a/internal/dbverify/dbverify_test.go |
| +++ b/internal/dbverify/dbverify_test.go |
| @@ -3,6 +3,7 @@ package dbverify |
| import ( |
| "bytes" |
| "context" |
| + "encoding/json" |
| "errors" |
| "slices" |
| "strings" |
| @@ -677,3 +678,114 @@ func TestMergeUnknownIdentityKeepsTheLastKnown(t *testing.T) { |
| t.Fatalf("A, unknown, B kept A's history for B: %+v", v) |
| } |
| } |
| + |
| +// TestMergeLeftOut: a host the run left out (no database to back up) is |
| +// recorded under LeftOut, never in Hosts, whatever the prior verdict was. |
| +// An unvisited host keeps what it had, a verdict or a LeftOut entry; a |
| +// host with a verdict this run leaves LeftOut; a host started and |
| +// abandoned is an attempt like any other, so it goes to Hosts as |
| +// not_reached rather than staying hidden; and a host no longer in the |
| +// fleet leaves LeftOut as it leaves Hosts. |
| +func TestMergeLeftOut(t *testing.T) { |
| + night1 := at("2026-11-13T03:00:00Z") |
| + night2 := night1.Add(24 * time.Hour) |
| + fleet := []string{"was-unverified.example.com", "still-out.example.com", "came-back.example.com", |
| + "abandoned.example.com", "new.example.com"} |
| + prior := &Record{V: 2, Box: "box-a", CheckedAt: night1, |
| + Hosts: map[string]Verdict{ |
| + "was-unverified.example.com": {Result: ResultUnverified, Reason: "nothing_replicated", UnverifiedRuns: 2, FirstSeen: night1}, |
| + }, |
| + LeftOut: map[string]LeftOut{ |
| + "still-out.example.com": {At: night1, Incarnation: "s1"}, |
| + "came-back.example.com": {At: night1, Incarnation: "c1"}, |
| + "abandoned.example.com": {At: night1, Incarnation: "a1"}, |
| + "gone.example.com": {At: night1, Incarnation: "g1"}, |
| + }} |
| + rec := MergeLeftOut(prior, "box-a", night2, fleet, |
| + map[string]Verdict{ |
| + "came-back.example.com": passed(Identity{Incarnation: "c1"}, night2), |
| + "abandoned.example.com": {Result: ResultUnverified, Reason: ReasonNotReached, AttemptedAt: night2}, |
| + }, |
| + map[string]LeftOut{"was-unverified.example.com": {At: night2, Incarnation: "w1"}}) |
| + |
| + if want := []string{"abandoned.example.com", "came-back.example.com", "new.example.com"}; !slices.Equal(sortedKeys(rec.Hosts), want) { |
| + t.Fatalf("Hosts %v, want %v", sortedKeys(rec.Hosts), want) |
| + } |
| + if got := sortedLeftOut(rec.LeftOut); !slices.Equal(got, []string{"still-out.example.com", "was-unverified.example.com"}) { |
| + t.Fatalf("LeftOut %v", got) |
| + } |
| + if lo := rec.LeftOut["was-unverified.example.com"]; !lo.At.Equal(night2) || lo.Incarnation != "w1" { |
| + t.Fatalf("this run's entry: %+v", lo) |
| + } |
| + if lo := rec.LeftOut["still-out.example.com"]; !lo.At.Equal(night1) || lo.Incarnation != "s1" { |
| + t.Fatalf("an unvisited host's entry was not carried: %+v", lo) |
| + } |
| + if v := rec.Hosts["came-back.example.com"]; !v.OK() { |
| + t.Fatalf("came-back: %+v", v) |
| + } |
| + if v := rec.Hosts["abandoned.example.com"]; v.Reason != ReasonNotReached || !v.AttemptedAt.Equal(night2) { |
| + t.Fatalf("abandoned: %+v", v) |
| + } |
| + |
| + // Merge is MergeLeftOut with nothing left out this run: it still |
| + // carries an unvisited host's entry. |
| + if lo, ok := Merge(prior, "box-a", night2, fleet, nil).LeftOut["still-out.example.com"]; !ok || !lo.At.Equal(night1) { |
| + t.Fatalf("Merge dropped an unvisited LeftOut entry: %+v", lo) |
| + } |
| + // And a record with none says nothing about it on the wire. |
| + body, err := json.Marshal(Merge(nil, "box-a", night2, []string{"a.example.com"}, nil)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if bytes.Contains(body, []byte("left_out")) { |
| + t.Fatalf("an empty LeftOut was written: %s", body) |
| + } |
| +} |
| + |
| +func sortedLeftOut(m map[string]LeftOut) []string { |
| + out := make([]string, 0, len(m)) |
| + for k := range m { |
| + out = append(out, k) |
| + } |
| + slices.Sort(out) |
| + return out |
| +} |
| + |
| +// A landing move clears a left-out host from the landing box's record as |
| +// it clears a verdict, and a publish built before the landing does not put |
| +// it back. |
| +func TestRemoveHostAndPublishOverClearLeftOut(t *testing.T) { |
| + ctx := context.Background() |
| + s := release.NewDirStore(t.TempDir()) |
| + now := at("2026-11-13T03:00:00Z") |
| + start := MergeLeftOut(nil, "box-a", now, []string{"a.example.com", "site.example.com"}, |
| + map[string]Verdict{"a.example.com": passed(idA, now)}, |
| + map[string]LeftOut{"site.example.com": {At: now, Incarnation: "s1"}}) |
| + if err := Publish(ctx, s, start); err != nil { |
| + t.Fatal(err) |
| + } |
| + known := map[string]bool{"a.example.com": true, "site.example.com": true} |
| + if err := RemoveHost(ctx, s, "box-a", "site.example.com"); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, err := Load(ctx, s, "box-a") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ok := got.LeftOut["site.example.com"]; ok { |
| + t.Fatalf("RemoveHost left the LeftOut entry: %+v", got.LeftOut) |
| + } |
| + later := now.Add(10 * time.Minute) |
| + rec := MergeLeftOut(start, "box-a", later, []string{"a.example.com", "site.example.com"}, nil, |
| + map[string]LeftOut{"site.example.com": {At: later, Incarnation: "s1"}}) |
| + dropped, err := PublishOver(ctx, s, rec, known) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !slices.Equal(dropped, []string{"site.example.com"}) { |
| + t.Fatalf("dropped %v, want the removed left-out host", dropped) |
| + } |
| + if got, err = Load(ctx, s, "box-a"); err != nil || len(got.LeftOut) != 0 || !slices.Equal(sortedKeys(got.Hosts), []string{"a.example.com"}) { |
| + t.Fatalf("published %+v, %v; want a alone and nothing left out", got, err) |
| + } |
| +} |
diff --git a/internal/metrics/verify_test.go b/internal/metrics/verify_test.go| index 1b4d41171..42d808711 100644 |
| --- a/internal/metrics/verify_test.go |
| +++ b/internal/metrics/verify_test.go |
| @@ -252,3 +252,21 @@ func TestReadVerifyMissingAndBroken(t *testing.T) { |
| t.Fatalf("unknown version = %+v, %v", v, err) |
| } |
| } |
| + |
| +// TestReadVerifyIgnoresLeftOut: a host the drill left out for having no |
| +// database is recorded under left_out, which the rules do not read: it is |
| +// in no list, has no streak and is never behind. The field is additive |
| +// (the record stays v 2), so the reading of the hosts is unchanged. |
| +func TestReadVerifyIgnoresLeftOut(t *testing.T) { |
| + now := time.Date(2026, 11, 20, 3, 0, 0, 0, time.UTC) |
| + long := now.Add(-30 * 24 * time.Hour) |
| + rec := &dbverify.Record{V: 2, Box: "b", CheckedAt: now, |
| + Hosts: map[string]dbverify.Verdict{ |
| + "a.example.com": {Result: dbverify.ResultPassed, FirstSeen: long, LastDecidedAt: now}, |
| + }, |
| + LeftOut: map[string]dbverify.LeftOut{"site.example.com": {At: long, Incarnation: "s1"}}} |
| + v := writeVerify(t, rec, now) |
| + if !reflect.DeepEqual(v.Hosts, []string{"a.example.com"}) || len(v.UnverifiedStreak) != 0 || len(v.Behind) != 0 || len(v.Failed) != 0 { |
| + t.Fatalf("reading %+v, want a.example.com alone, nothing behind", v) |
| + } |
| +} |
diff --git a/internal/ops/hibernate_verify.go b/internal/ops/hibernate_verify.go| index ce0bd223d..e6fb77162 100644 |
| --- a/internal/ops/hibernate_verify.go |
| +++ b/internal/ops/hibernate_verify.go |
| @@ -25,6 +25,7 @@ import ( |
| "net" |
| "net/url" |
| "os" |
| + "path/filepath" |
| "slices" |
| "sort" |
| "strings" |
| @@ -193,6 +194,10 @@ type Drill struct { |
| Budget time.Duration |
| Max int |
| PublishEvery time.Duration |
| + // Prior is the record this box published last (nil when none): a host |
| + // whose verdict there, for the same incarnation, shows it once had data |
| + // is never left out for having none now. |
| + Prior *dbverify.Record |
| // staging is the data bucket the staged-copy check lists, opened once |
| // by VerifyHibernating; stagingErr is why it could not be. |
| @@ -229,7 +234,14 @@ type Drill struct { |
| // restore found. So is its move staging (R1): a staged copy waiting for |
| // the first wake's promotion at either end is unverified, moving. Freshness is judged only on the box that provably holds |
| // the live lease (P-14). |
| -func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, now func() time.Time, publish func(map[string]dbverify.Verdict) bool) map[string]dbverify.Verdict { |
| +// |
| +// A host whose bracket closed clean with nothing replicated, and whose |
| +// live database is proven absent (noDatabase, and for an HA host this box |
| +// holds its lease), has no database to back up (a static site, an |
| +// instance that never opened one): it gets no verdict and is left out |
| +// (RunResults.LeftOut), unless the prior record shows this incarnation |
| +// once had data. The record lists it under LeftOut, never in Hosts. |
| +func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, now func() time.Time, publish func(RunResults) bool) RunResults { |
| start := now() |
| runCtx, cancel := ctx, context.CancelFunc(func() {}) |
| if d.Budget > 0 { |
| @@ -282,25 +294,40 @@ func VerifyHibernating(ctx context.Context, d Drill, hosts []HibernatingRoute, n |
| break |
| } |
| visited++ |
| - v, ok := d.drillOne(runCtx, rt, now) |
| - if !ok { |
| + v, outcome := d.drillOne(runCtx, rt, now) |
| + switch outcome { |
| + case drillAbandoned: |
| fmt.Printf("abandoned %s: the run ended during its test; no verdict, and it goes to the back of the next run\n", rt.Host) |
| res.add(rt.Host, dbverify.Verdict{Result: dbverify.ResultUnverified, Reason: dbverify.ReasonNotReached, |
| Prefix: activator.HibernatePrefix(d.Cfg.Prefix, rt.Host), AttemptedAt: now().UTC()}) |
| - continue |
| + case drillNoDatabase: |
| + fmt.Printf("left out %s: no database here (nothing replicated, and no file at %s)\n", rt.Host, rt.DBPath) |
| + res.leaveOut(rt.Host, dbverify.LeftOut{At: v.VerifiedAt, Incarnation: v.Identity.Incarnation}) |
| + default: |
| + res.add(rt.Host, v) |
| + printVerdict(rt.Host, v) |
| } |
| - res.add(rt.Host, v) |
| - printVerdict(rt.Host, v) |
| } |
| return res.all() |
| } |
| +// RunResults is what a run has finished: a verdict per host it decided |
| +// (or abandoned, as not_reached), and the hosts it left out because they |
| +// have no database to back up. A host left out has no verdict: the |
| +// publisher records it under the record's LeftOut, out of Hosts, so it |
| +// has no streak, no coverage, and no carry-over of an earlier verdict. |
| +type RunResults struct { |
| + Verdicts map[string]dbverify.Verdict |
| + LeftOut map[string]dbverify.LeftOut |
| +} |
| + |
| // runResults is a run's verdicts so far, shared by the drill and the |
| // publish ticker. |
| type runResults struct { |
| mu sync.Mutex |
| out map[string]dbverify.Verdict |
| - version int // bumped by every add |
| + leftOut map[string]dbverify.LeftOut |
| + version int // bumped by every add and leaveOut |
| published int // the version the last successful ticker publish carried |
| } |
| @@ -314,22 +341,42 @@ func (r *runResults) add(host string, v dbverify.Verdict) { |
| r.version++ |
| } |
| -// all is a copy of every verdict so far. |
| -func (r *runResults) all() map[string]dbverify.Verdict { |
| +// leaveOut records a host with no database to back up. |
| +func (r *runResults) leaveOut(host string, lo dbverify.LeftOut) { |
| + r.mu.Lock() |
| + defer r.mu.Unlock() |
| + if r.leftOut == nil { |
| + r.leftOut = map[string]dbverify.LeftOut{} |
| + } |
| + r.leftOut[host] = lo |
| + r.version++ |
| +} |
| + |
| +// all is a copy of everything so far. |
| +func (r *runResults) all() RunResults { |
| r.mu.Lock() |
| defer r.mu.Unlock() |
| - return cloneVerdicts(r.out) |
| + return r.snapshot() |
| } |
| -// unpublished is a copy of every verdict so far and its version, when |
| +// unpublished is a copy of everything so far and its version, when |
| // something was added since the last acknowledged publish. |
| -func (r *runResults) unpublished() (map[string]dbverify.Verdict, int, bool) { |
| +func (r *runResults) unpublished() (RunResults, int, bool) { |
| r.mu.Lock() |
| defer r.mu.Unlock() |
| if r.version == r.published { |
| - return nil, 0, false |
| + return RunResults{}, 0, false |
| + } |
| + return r.snapshot(), r.version, true |
| +} |
| + |
| +// snapshot copies the results; the caller holds mu. |
| +func (r *runResults) snapshot() RunResults { |
| + left := make(map[string]dbverify.LeftOut, len(r.leftOut)) |
| + for h, lo := range r.leftOut { |
| + left[h] = lo |
| } |
| - return cloneVerdicts(r.out), r.version, true |
| + return RunResults{Verdicts: cloneVerdicts(r.out), LeftOut: left} |
| } |
| // acknowledge records that the snapshot at version was published. |
| @@ -379,21 +426,36 @@ type restoreResult struct { |
| err error |
| } |
| -// drillOne tests one host. ok is false when the run's context ended while |
| -// the host was in progress: the host is abandoned, with no verdict. |
| -func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() time.Time) (dbverify.Verdict, bool) { |
| +// drillOutcome is what drillOne came to for one host. |
| +type drillOutcome int |
| + |
| +const ( |
| + // drillAbandoned: the run's context ended while the host was in |
| + // progress. No verdict; the run records it not_reached. |
| + drillAbandoned drillOutcome = iota |
| + // drillDecided: the host has a verdict. |
| + drillDecided |
| + // drillNoDatabase: the bracket closed clean, the replica holds |
| + // nothing, and the live database is proven absent: there is no |
| + // database to back up, so the host is left out of the record. The |
| + // verdict returned carries only the identity and VerifiedAt. |
| + drillNoDatabase |
| +) |
| + |
| +// drillOne tests one host. |
| +func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() time.Time) (dbverify.Verdict, drillOutcome) { |
| prefix := activator.HibernatePrefix(d.Cfg.Prefix, rt.Host) |
| v := dbverify.Verdict{Prefix: prefix, BracketOpenedAt: now().UTC()} |
| - unverified := func(reason, detail string) (dbverify.Verdict, bool) { |
| + unverified := func(reason, detail string) (dbverify.Verdict, drillOutcome) { |
| v.Result, v.Reason, v.Detail = dbverify.ResultUnverified, reason, detail |
| v.VerifiedAt = now().UTC() |
| - return v, true |
| + return v, drillDecided |
| } |
| id, code, detail, err := captureDrillIdentity(ctx, d.Store, d.Region, rt) |
| if err != nil { |
| if ctx.Err() != nil { |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| } |
| return unverified(ReasonRecordUnreadable, err.Error()) |
| } |
| @@ -413,7 +475,7 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| // and when the staging cannot be read, nothing is either. |
| switch staged, err := d.stagedCopy(ctx, rt.Host); { |
| case err != nil && ctx.Err() != nil: |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| case err != nil: |
| return unverified(ReasonStorageUnavailable, err.Error()) |
| case staged: |
| @@ -427,13 +489,13 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| scratch, err := os.MkdirTemp(d.TmpDir, "drill-") |
| if err != nil { |
| fmt.Printf("hibernate-verify: %s: no scratch directory on this box: %v\n", rt.Host, err) |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| } |
| defer os.RemoveAll(scratch) |
| res := d.restore(ctx, prefix, scratch) |
| if res.err != nil && ctx.Err() != nil { |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| } |
| // Freshness is read before the bracket closes, so a record change |
| // while it is read discards it too. |
| @@ -443,14 +505,25 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| if res.kind == restoreClean { |
| fresh, stale, staleDetail = d.freshness(ctx, rt, prefix, res.counter) |
| if ctx.Err() != nil { |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| + } |
| + } |
| + // An HA host's database lives on whichever box holds its lease, so |
| + // absence here proves nothing unless that is this box: the same lease |
| + // read freshness trusts, read before the bracket closes for the same |
| + // reason. |
| + ownsLease := false |
| + if res.kind == restoreNothing && rt.HA { |
| + ownsLease = d.holdsLease(ctx, prefix) |
| + if ctx.Err() != nil { |
| + return dbverify.Verdict{}, drillAbandoned |
| } |
| } |
| code, err = confirmDrillIdentity(ctx, d.Store, rt, id) |
| if err != nil { |
| if ctx.Err() != nil { |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| } |
| return unverified(ReasonRecordUnreadable, "the record could not be read again after the restore, so its result was discarded: "+err.Error()) |
| } |
| @@ -462,7 +535,7 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| // so neither a stale pass nor a mixed-lineage failure can stand. |
| switch staged, err := d.stagedCopy(ctx, rt.Host); { |
| case err != nil && ctx.Err() != nil: |
| - return dbverify.Verdict{}, false |
| + return dbverify.Verdict{}, drillAbandoned |
| case err != nil: |
| return unverified(ReasonStorageUnavailable, "the move staging could not be read again after the restore, so its result was discarded: "+err.Error()) |
| case staged: |
| @@ -472,26 +545,65 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| v.VerifiedAt = now().UTC() |
| switch res.kind { |
| case restoreNothing: |
| + // Only here, with the bracket and the staging closed clean, and only |
| + // on a proven absence: a file that is there is a database with |
| + // nothing replicated, a real gap; so is a database this incarnation |
| + // once had, now lost with its copy. |
| + if noDatabase(rt.DBPath) && (!rt.HA || ownsLease) && !d.hadData(rt.Host, v.Identity) { |
| + return v, drillNoDatabase |
| + } |
| v.Result, v.Reason, v.Detail = dbverify.ResultUnverified, ReasonNothingReplicated, "no replica yet" |
| - return v, true |
| + return v, drillDecided |
| case restorePlanMoved: |
| v.Result, v.Reason, v.Detail = dbverify.ResultUnverified, ReasonPlanMoved, res.err.Error() |
| - return v, true |
| + return v, drillDecided |
| case restoreFailed: |
| v.Result, v.Reason, v.Detail = dbverify.ResultFailed, ReasonRestoreError, res.err.Error() |
| - return v, true |
| + return v, drillDecided |
| case restoreUnavailable: |
| v.Result, v.Reason, v.Detail = dbverify.ResultUnverified, ReasonStorageUnavailable, res.err.Error() |
| - return v, true |
| + return v, drillDecided |
| } |
| v.TXID, v.WrittenAt, v.RestoredBytes = res.plan.TXID, res.plan.At, res.plan.RestoredBytes |
| v.Freshness = fresh |
| if stale { |
| v.Result, v.Reason, v.Detail = dbverify.ResultFailed, ReasonStale, staleDetail |
| - return v, true |
| + return v, drillDecided |
| } |
| v.Result = dbverify.ResultPassed |
| - return v, true |
| + return v, drillDecided |
| +} |
| + |
| +// noDatabase reports whether the live database at path is proven absent |
| +// from this box: lstat answers that nothing at all is there. Any other |
| +// answer (a file, a dangling symlink, a permission or path error) is not |
| +// proof, and neither is a route with no path recorded, or a relative one, |
| +// which would be looked up from the drill's working directory rather than |
| +// where the instance keeps it. |
| +func noDatabase(path string) bool { |
| + if path == "" || !filepath.IsAbs(path) { |
| + return false |
| + } |
| + _, err := os.Lstat(path) |
| + return errors.Is(err, fs.ErrNotExist) |
| +} |
| + |
| +// hadData reports whether the prior record's verdict for host, about the |
| +// same incarnation as id, shows the instance once had data: passed or |
| +// failed, a restored position, or a decision ever. A prior verdict whose |
| +// identity is unknown is not proof of another incarnation, so it counts. |
| +func (d Drill) hadData(host string, id dbverify.Identity) bool { |
| + if d.Prior == nil { |
| + return false |
| + } |
| + p, ok := d.Prior.Hosts[host] |
| + if !ok { |
| + return false |
| + } |
| + if p.Identity != (dbverify.Identity{}) && p.Identity.Incarnation != id.Incarnation { |
| + return false |
| + } |
| + return p.Result == dbverify.ResultPassed || p.Result == dbverify.ResultFailed || p.TXID != 0 || !p.LastDecidedAt.IsZero() |
| } |
| // stagedCopy reports whether a move's staged copy of host waits under |
| @@ -641,11 +753,7 @@ func (d Drill) plan(ctx context.Context, prefix string) (dbdoor.RestorePlan, dbd |
| // box's sleeping host carries a release marker, which ParseOwner refuses: |
| // unknown, as the plan expects. |
| func (d Drill) freshness(ctx context.Context, rt HibernatingRoute, prefix string, counter uint32) (fresh string, stale bool, detail string) { |
| - held, owner, _, err := lockState(ctx, d.Cfg.Bucket, prefix, d.Cfg.Region) |
| - if err != nil || !held { |
| - return dbverify.FreshnessUnknown, false, "" |
| - } |
| - if o, ok := hafresh.ParseOwner(owner); !ok || o.Ref != d.SelfRef { |
| + if !d.holdsLease(ctx, prefix) { |
| return dbverify.FreshnessUnknown, false, "" |
| } |
| switch f, detail := localFreshness(rt.DBPath, counter); f { |
| @@ -666,6 +774,19 @@ func (d Drill) freshness(ctx context.Context, rt HibernatingRoute, prefix string |
| } |
| } |
| +// holdsLease reports whether this box provably holds the live lease on the |
| +// replica at prefix (P-14): the lock read without error, held, and owned |
| +// by this box's reference. A group box's sleeping host carries a release |
| +// marker, which ParseOwner refuses: not held. |
| +func (d Drill) holdsLease(ctx context.Context, prefix string) bool { |
| + held, owner, _, err := lockState(ctx, d.Cfg.Bucket, prefix, d.Cfg.Region) |
| + if err != nil || !held { |
| + return false |
| + } |
| + o, ok := hafresh.ParseOwner(owner) |
| + return ok && o.Ref == d.SelfRef |
| +} |
| + |
| // drillSet is a run's hosts as this box records them: Drill to test, and |
| // NoAssignment verdicts for the group box's hosts no usable assignment |
| // gave it. Fleet is every host the box's record keeps, the two together; |
| @@ -729,11 +850,17 @@ func selectHosts(self boxself.Self, dataDir string, now time.Time, hosts []Hiber |
| // attempted (the later of VerifiedAt and AttemptedAt), most stale first, |
| // so a run that runs out of budget works through the fleet instead of |
| // drilling the same alphabetical prefix every night, and a host that was |
| -// started and abandoned waits behind the others. Hosts with no verdict at |
| -// all sort first — never verified is staler than any timestamp. |
| +// started and abandoned waits behind the others. A host left out for |
| +// having no database is ordered by when (LeftOut.At), as if decided then, |
| +// so it rotates rather than taking the head of every run. Hosts with no |
| +// verdict and no LeftOut entry sort first — never verified is staler than |
| +// any timestamp. |
| func OldestFirst(hosts []HibernatingRoute, prior *dbverify.Record) []HibernatingRoute { |
| stamp := map[string]time.Time{} |
| if prior != nil { |
| + for h, lo := range prior.LeftOut { |
| + stamp[h] = lo.At |
| + } |
| for h, v := range prior.Hosts { |
| stamp[h] = v.VerifiedAt |
| if v.AttemptedAt.After(v.VerifiedAt) { |
diff --git a/internal/ops/hibernate_verify_run_test.go b/internal/ops/hibernate_verify_run_test.go| index 2361eea71..33b0987d1 100644 |
| --- a/internal/ops/hibernate_verify_run_test.go |
| +++ b/internal/ops/hibernate_verify_run_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "errors" |
| "fmt" |
| + "io" |
| "os" |
| "path/filepath" |
| "slices" |
| @@ -13,6 +14,9 @@ import ( |
| "time" |
| "github.com/carlosframework/platform/internal/dbverify" |
| + "github.com/carlosframework/platform/internal/metrics" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| ) |
| // A failed periodic upload is not acknowledged: the next tick publishes |
| @@ -36,10 +40,10 @@ func TestVerifyHibernatingRetriesAFailedPublish(t *testing.T) { |
| var mu sync.Mutex |
| var calls []int |
| up := false |
| - publish := func(r map[string]dbverify.Verdict) bool { |
| + publish := func(r RunResults) bool { |
| mu.Lock() |
| defer mu.Unlock() |
| - calls = append(calls, len(r)) |
| + calls = append(calls, len(r.Verdicts)) |
| return up |
| } |
| seen := func() []int { |
| @@ -85,11 +89,11 @@ func TestVerifyPublisherReportsSuccess(t *testing.T) { |
| fx := newDrillFx(t) |
| store := &failingStore{ctxStore: ctxStore{Store: fx.store}, fail: true} |
| pub := newVerifyPublisher(context.Background(), store, fxSelf, nil, []string{"a.example.com"}, nil, t.TempDir(), fx.clock.Now, t.Logf) |
| - if pub.publish(nil) { |
| + if pub.publish(RunResults{}) { |
| t.Fatal("a failed upload reported success") |
| } |
| store.fail = false |
| - if !pub.publish(nil) { |
| + if !pub.publish(RunResults{}) { |
| t.Fatal("an upload that landed reported failure") |
| } |
| } |
| @@ -362,3 +366,440 @@ func TestRunHibernateVerifyEmptyFleetClearsCrashedScratch(t *testing.T) { |
| }) |
| } |
| } |
| + |
| +// captureStdout runs f and returns what it printed: the run's own lines go |
| +// to stdout, its refusals through Logf. |
| +func captureStdout(t *testing.T, f func()) string { |
| + t.Helper() |
| + r, w, err := os.Pipe() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + old := os.Stdout |
| + os.Stdout = w |
| + restored := false |
| + restore := func() { |
| + if !restored { |
| + os.Stdout = old |
| + w.Close() |
| + restored = true |
| + } |
| + } |
| + t.Cleanup(restore) |
| + out := make(chan string) |
| + go func() { |
| + b, _ := io.ReadAll(r) |
| + r.Close() |
| + out <- string(b) |
| + }() |
| + f() |
| + restore() |
| + return <-out |
| +} |
| + |
| +// TestRunHibernateVerifyLeavesOutHostsWithNoDatabase: a host with nothing |
| +// replicated and no database file on this box (a static site, an |
| +// instance that never opened a database) has nothing to back up. It is |
| +// left out of the record, in the bucket and in the local copy the alerts |
| +// read, so it carries no streak and counts for no coverage; one that was |
| +// unverified on earlier nights drops out rather than being carried over. |
| +// A host with nothing replicated whose database file is there is a real |
| +// gap and stays unverified, nothing_replicated. |
| +func TestRunHibernateVerifyLeavesOutHostsWithNoDatabase(t *testing.T) { |
| + const app, site, gap = "app.example.com", "site.example.com", "gap.example.com" |
| + fx := newRunFx(t, app, site, gap) |
| + fx.writeSelf(fxSelf, false) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + fx.replicaFor[fx.prefix(gap)] = fx.empty |
| + fx.holdLease(site) // the rows are HA: absence proves nothing elsewhere |
| + if err := os.WriteFile(filepath.Join(fx.dataDir, gap+".db"), []byte("x"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: at("2026-11-11T03:00:00Z"), Hosts: map[string]dbverify.Verdict{ |
| + site: {Result: dbverify.ResultUnverified, Reason: ReasonNothingReplicated, Detail: "no replica yet", |
| + Identity: fx.identity(site), UnverifiedRuns: 2, FirstSeen: at("2026-11-02T03:00:00Z"), VerifiedAt: at("2026-11-11T03:00:00Z")}, |
| + app: {Result: dbverify.ResultPassed, Identity: fx.identity(app), FirstSeen: at("2026-11-02T03:00:00Z"), |
| + VerifiedAt: at("2026-11-11T03:00:00Z"), LastDecidedAt: at("2026-11-11T03:00:00Z")}, |
| + }} |
| + if err := dbverify.Publish(context.Background(), fx.store, prior); err != nil { |
| + t.Fatal(err) |
| + } |
| + |
| + var code int |
| + out := captureStdout(t, func() { code = fx.runner().run(context.Background()) }) |
| + if code != 0 { |
| + t.Fatalf("exited %d: %s\n%s", code, fx.logs, out) |
| + } |
| + rec := fx.published(fxSelf) |
| + if got, want := sortedHosts(rec), []string{app, gap}; !slices.Equal(got, want) { |
| + t.Fatalf("record names %v, want %v (%s has no database)", got, want, site) |
| + } |
| + if v := rec.Hosts[gap]; !v.Unverified() || v.Reason != ReasonNothingReplicated || v.UnverifiedRuns != 1 { |
| + t.Fatalf("%s, a database with nothing replicated: %+v, want unverified/nothing_replicated, streak 1", gap, v) |
| + } |
| + if !rec.Hosts[app].OK() { |
| + t.Fatalf("%s: %+v", app, rec.Hosts[app]) |
| + } |
| + if lo, ok := rec.LeftOut[site]; !ok || lo.Incarnation != fx.identity(site).Incarnation || !lo.At.Equal(fx.clock.Now()) { |
| + t.Fatalf("left_out %+v, want %s at %s", rec.LeftOut, site, fx.clock.Now()) |
| + } |
| + if len(rec.LeftOut) != 1 { |
| + t.Fatalf("left_out %+v, want %s alone", rec.LeftOut, site) |
| + } |
| + local, err := fx.localCopy() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := sortedHosts(local); !slices.Equal(got, sortedHosts(rec)) || len(local.LeftOut) != 1 { |
| + t.Fatalf("local copy names %v and left out %v, the bucket's %v", got, local.LeftOut, sortedHosts(rec)) |
| + } |
| + // The alert rules read the local copy: nothing there for the host, a |
| + // week on or not. |
| + reading, err := metrics.ReadVerify(dbverify.LocalPath(fx.dataDir), fx.clock.Now().Add(8*24*time.Hour)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, streak := reading.UnverifiedStreak[site]; streak || slices.Contains(reading.Hosts, site) || slices.Contains(reading.Behind, site) { |
| + t.Fatalf("the alerts still see %s: %+v", site, reading) |
| + } |
| + if !strings.Contains(out, "left out "+site+": no database here") { |
| + t.Fatalf("the run log does not say %s was left out:\n%s", site, out) |
| + } |
| + if !strings.Contains(out, "1 left out (no database)") { |
| + t.Fatalf("the run's summary does not count the host left out:\n%s", out) |
| + } |
| +} |
| + |
| +// TestRunHibernateVerifyLastHostLeftOutClearsTheRecord: when every host is |
| +// left out, the record published has no verdicts, not the prior one's. |
| +func TestRunHibernateVerifyLastHostLeftOutClearsTheRecord(t *testing.T) { |
| + const site = "site.example.com" |
| + fx := newRunFx(t, site) |
| + fx.writeSelf(fxSelf, false) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + fx.holdLease(site) |
| + prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: at("2026-11-11T03:00:00Z"), Hosts: map[string]dbverify.Verdict{ |
| + site: {Result: dbverify.ResultUnverified, Reason: ReasonNothingReplicated, Identity: fx.identity(site), |
| + UnverifiedRuns: 2, FirstSeen: at("2026-11-02T03:00:00Z"), VerifiedAt: at("2026-11-11T03:00:00Z")}, |
| + }} |
| + if err := dbverify.Publish(context.Background(), fx.store, prior); err != nil { |
| + t.Fatal(err) |
| + } |
| + var code int |
| + captureStdout(t, func() { code = fx.runner().run(context.Background()) }) |
| + if code != 0 { |
| + t.Fatalf("exited %d: %s", code, fx.logs) |
| + } |
| + if rec := fx.published(fxSelf); rec == nil || len(rec.Hosts) != 0 || len(rec.LeftOut) != 1 { |
| + t.Fatalf("published %+v, want no verdicts and %s left out", rec, site) |
| + } |
| + if local, err := fx.localCopy(); err != nil || len(local.Hosts) != 0 { |
| + t.Fatalf("local copy %+v, %v; want no verdicts", local, err) |
| + } |
| +} |
| + |
| +// TestRunHibernateVerifyFleetBoxWithoutDeploymentStore: a fleet box reaches |
| +// its deployment through the console, not a bucket of its own, so the |
| +// instances' records are out of its reach. It says so once and exits 0, |
| +// publishing nothing, instead of failing its unit every night. A platform |
| +// box missing its deployment bucket still fails loudly. |
| +func TestRunHibernateVerifyFleetBoxWithoutDeploymentStore(t *testing.T) { |
| + t.Setenv("CARLOS_DEPLOYMENT_BUCKET", "") |
| + t.Setenv("CARLOS_DEPLOYMENT_DIR", "") |
| + for name, c := range map[string]struct { |
| + fleet string |
| + code int |
| + }{ |
| + "fleet box": {fleet: "acme", code: 0}, |
| + "platform box": {fleet: "", code: 1}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + fx := newRunFx(t, "a.example.com") |
| + fx.writeSelf(fxSelf, false) |
| + restored := false |
| + fx.stubVerify(func(context.Context, string, string, uint64) (uint32, error) { |
| + restored = true |
| + return 1, nil |
| + }) |
| + r := fx.runner() |
| + r.OpenStore = openDeployStore |
| + r.Fleet = c.fleet |
| + var code int |
| + out := captureStdout(t, func() { code = r.run(context.Background()) }) |
| + if code != c.code { |
| + t.Fatalf("exited %d, want %d: %s\n%s", code, c.code, fx.logs, out) |
| + } |
| + if restored { |
| + t.Fatal("drilled with no deployment store") |
| + } |
| + keys, err := fx.store.List(context.Background(), "control/") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(keys) != 0 { |
| + t.Fatalf("published %v", keys) |
| + } |
| + if _, err := fx.localCopy(); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("a local copy was written: %v", err) |
| + } |
| + fleetLine := "hibernate-verify: fleet box: instance records are not reachable from here, so the drill does not run on fleet boxes yet" |
| + if c.fleet != "" { |
| + if !strings.Contains(out, fleetLine) || fx.logs.Len() != 0 { |
| + t.Fatalf("stdout %q, log %q; want the one fleet line", out, fx.logs) |
| + } |
| + return |
| + } |
| + if strings.Contains(out, fleetLine) || !strings.Contains(fx.logs.String(), "NOT RUN: the deployment bucket") { |
| + t.Fatalf("stdout %q, log %q; want the NOT RUN refusal", out, fx.logs) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// holdLease makes this box the lease holder of host's replica, as |
| +// freshness reads it, and nobody the holder of any other. |
| +func (fx *runFx) holdLease(host string) { |
| + fx.t.Helper() |
| + swap(fx.t, &lockState, func(_ context.Context, _, location, _ string) (bool, string, time.Time, error) { |
| + if location == fx.prefix(host) { |
| + return true, selfOwner(fxSelf), time.Now().Add(time.Minute), nil |
| + } |
| + return false, "", time.Time{}, nil |
| + }) |
| +} |
| + |
| +// addPlain puts non-HA sleeping rows and their records in the run fixture: |
| +// a host on this box alone, whose absence here is proof. |
| +func (fx *runFx) addPlain(hosts ...string) { |
| + fx.t.Helper() |
| + for _, h := range hosts { |
| + fx.addRoute(registry.Route{Host: h, Hibernate: true}) |
| + fx.putRecord(fxAccount, h, time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC), nil) |
| + } |
| +} |
| + |
| +// night runs the drill once, a day after the last, and returns what it |
| +// printed and the hosts it restored. |
| +func (fx *runFx) night(r hibernateRun) (out string, restored []string) { |
| + fx.t.Helper() |
| + fx.clock.Advance(24 * time.Hour) |
| + fx.writeSelf(fxSelf, false) |
| + fx.stubVerify(func(_ context.Context, prefix, _ string, _ uint64) (uint32, error) { |
| + restored = append(restored, filepath.Base(prefix)) |
| + return 1, nil |
| + }) |
| + var code int |
| + out = captureStdout(fx.t, func() { code = r.run(context.Background()) }) |
| + if code != 0 { |
| + fx.t.Fatalf("exited %d: %s\n%s", code, fx.logs, out) |
| + } |
| + return out, restored |
| +} |
| + |
| +// TestRunHibernateVerifyLeftOutHostsRotate: a host left out is recorded |
| +// with when, and the next run orders it as if decided then, so under a |
| +// cap of one the host with a database is drilled on the second night |
| +// rather than never (Astra P1: a host with no prior verdict sorted first |
| +// every night and took the only visit). |
| +func TestRunHibernateVerifyLeftOutHostsRotate(t *testing.T) { |
| + const site, db = "a-site.example.com", "b-db.example.com" |
| + fx := newRunFx(t) |
| + fx.addPlain(site, db) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + r := fx.runner() |
| + r.Max = 1 |
| + |
| + if _, restored := fx.night(r); len(restored) != 0 { |
| + t.Fatalf("night 1 restored %v, want the site (alphabetically first) alone, which restores nothing", restored) |
| + } |
| + rec := fx.published(fxSelf) |
| + if _, ok := rec.LeftOut[site]; !ok || rec.Hosts[db].Reason != dbverify.ReasonNotReached { |
| + t.Fatalf("after night 1: %+v", rec) |
| + } |
| + if _, restored := fx.night(r); !slices.Equal(restored, []string{db}) { |
| + t.Fatalf("night 2 restored %v, want %s", restored, db) |
| + } |
| + rec = fx.published(fxSelf) |
| + if !rec.Hosts[db].OK() { |
| + t.Fatalf("%s after night 2: %+v", db, rec.Hosts[db]) |
| + } |
| + if _, ok := rec.LeftOut[site]; !ok { |
| + t.Fatalf("the unvisited site lost its entry: %+v", rec.LeftOut) |
| + } |
| + if _, ok := rec.Hosts[site]; ok { |
| + t.Fatalf("the unvisited site gained a verdict: %+v", rec.Hosts[site]) |
| + } |
| +} |
| + |
| +// TestRunHibernateVerifyManyLeftOutHostsDoNotStarve: hosts with no |
| +// database that eat the run's time budget every night still leave room, |
| +// within two nights, for the one host with a database, and the run goes |
| +// on rotating through all of them. |
| +func TestRunHibernateVerifyManyLeftOutHostsDoNotStarve(t *testing.T) { |
| + sites := []string{"s1.example.com", "s2.example.com", "s3.example.com", "s4.example.com", "s5.example.com"} |
| + const db = "z-db.example.com" |
| + fx := newRunFx(t) |
| + fx.addPlain(append(slices.Clone(sites), db)...) |
| + for _, h := range sites { |
| + fx.replicaFor[fx.prefix(h)] = fx.empty |
| + // Each listing of an empty replica takes 20 minutes of the run's |
| + // 45-minute budget: three hosts a night. |
| + fx.onList[fx.prefix(h)] = func() { fx.clock.Advance(20 * time.Minute) } |
| + } |
| + r := fx.runner() |
| + drilled := 0 |
| + first := 0 |
| + for n := 1; n <= 6; n++ { |
| + if _, restored := fx.night(r); slices.Contains(restored, db) { |
| + drilled++ |
| + if first == 0 { |
| + first = n |
| + } |
| + } |
| + } |
| + if first == 0 || first > 2 { |
| + t.Fatalf("%s first drilled on night %d, want by night 2", db, first) |
| + } |
| + if drilled < 2 { |
| + t.Fatalf("%s drilled %d times in six nights, want the rotation to come back to it", db, drilled) |
| + } |
| + rec := fx.published(fxSelf) |
| + if want := slices.Clone(sites); !slices.Equal(sortedLeftOutHosts(rec), want) { |
| + t.Fatalf("left out %v, want %v", sortedLeftOutHosts(rec), want) |
| + } |
| + if got := sortedHosts(rec); !slices.Equal(got, []string{db}) { |
| + t.Fatalf("record names %v, want %s alone", got, db) |
| + } |
| +} |
| + |
| +func sortedLeftOutHosts(rec *dbverify.Record) []string { |
| + var out []string |
| + for h := range rec.LeftOut { |
| + out = append(out, h) |
| + } |
| + slices.Sort(out) |
| + return out |
| +} |
| + |
| +// TestRunHibernateVerifyDatabaseReappears: a host left out on one night |
| +// whose replica holds a database on the next is drilled as any other: it |
| +// leaves left_out and gets its verdict. |
| +func TestRunHibernateVerifyDatabaseReappears(t *testing.T) { |
| + const site = "site.example.com" |
| + fx := newRunFx(t) |
| + fx.addPlain(site) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + r := fx.runner() |
| + fx.night(r) |
| + if rec := fx.published(fxSelf); len(rec.LeftOut) != 1 || len(rec.Hosts) != 0 { |
| + t.Fatalf("after night 1: %+v", rec) |
| + } |
| + delete(fx.replicaFor, fx.prefix(site)) // the instance opened a database, and it replicated |
| + if _, restored := fx.night(r); !slices.Equal(restored, []string{site}) { |
| + t.Fatalf("night 2 restored %v", restored) |
| + } |
| + rec := fx.published(fxSelf) |
| + if len(rec.LeftOut) != 0 || !rec.Hosts[site].OK() { |
| + t.Fatalf("after night 2: hosts %+v, left out %+v; want a pass and nothing left out", rec.Hosts, rec.LeftOut) |
| + } |
| +} |
| + |
| +// TestRunHibernateVerifyPriorDataIsNeverLeftOut: a host whose record, for |
| +// this incarnation, shows it once restored, and which now has neither a |
| +// replica nor a file, is a loss, not a host without a database: it stays |
| +// unverified, nothing_replicated, and its streak moves. The run hands the |
| +// record it loaded to the drill. |
| +func TestRunHibernateVerifyPriorDataIsNeverLeftOut(t *testing.T) { |
| + const site = "site.example.com" |
| + fx := newRunFx(t) |
| + fx.addPlain(site) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: fx.clock.Now(), Hosts: map[string]dbverify.Verdict{ |
| + site: {Result: dbverify.ResultPassed, Identity: fx.identity(site), TXID: 9, FirstSeen: at("2026-11-02T03:00:00Z"), |
| + VerifiedAt: fx.clock.Now(), LastDecidedAt: fx.clock.Now()}, |
| + }} |
| + if err := dbverify.Publish(context.Background(), fx.store, prior); err != nil { |
| + t.Fatal(err) |
| + } |
| + fx.night(fx.runner()) |
| + rec := fx.published(fxSelf) |
| + if v := rec.Hosts[site]; !v.Unverified() || v.Reason != ReasonNothingReplicated || v.UnverifiedRuns != 1 { |
| + t.Fatalf("%s: %+v, want unverified/nothing_replicated, streak 1", site, v) |
| + } |
| + if len(rec.LeftOut) != 0 { |
| + t.Fatalf("left out %+v", rec.LeftOut) |
| + } |
| +} |
| + |
| +// TestRunHibernateVerifyUnreadablePriorPublishesNothing: an unreadable |
| +// history is not an absent one (Astra rounds 2 and 3). When the run's read |
| +// of its record fails, it publishes nothing and fails, so the record keeps |
| +// the evidence that a host once had data; the next run that can read it |
| +// still refuses to leave that host out. |
| +func TestRunHibernateVerifyUnreadablePriorPublishesNothing(t *testing.T) { |
| + const site = "site.example.com" |
| + fx := newRunFx(t, site) |
| + fx.writeSelf(fxSelf, false) |
| + fx.replicaFor[fx.prefix(site)] = fx.empty |
| + fx.holdLease(site) |
| + prior := &dbverify.Record{V: 2, Box: fxSelf, CheckedAt: at("2026-11-11T03:00:00Z"), Hosts: map[string]dbverify.Verdict{ |
| + site: {Result: dbverify.ResultPassed, Identity: fx.identity(site), FirstSeen: at("2026-11-02T03:00:00Z"), |
| + VerifiedAt: at("2026-11-11T03:00:00Z"), LastDecidedAt: at("2026-11-11T03:00:00Z"), TXID: 9}, |
| + }} |
| + if err := dbverify.Publish(context.Background(), fx.store, prior); err != nil { |
| + t.Fatal(err) |
| + } |
| + under := fx.store |
| + fx.store = &firstGetFails{Store: under, key: dbverify.KeyFor(fxSelf)} |
| + |
| + // Night A: the read fails. Nothing is published, bucket or local. |
| + var code int |
| + out := captureStdout(t, func() { code = fx.runner().run(context.Background()) }) |
| + if code == 0 { |
| + t.Fatalf("exited 0 over an unreadable record: %s\n%s", fx.logs, out) |
| + } |
| + fx.store = under |
| + if rec := fx.published(fxSelf); !rec.Hosts[site].OK() || rec.Hosts[site].TXID != 9 || len(rec.LeftOut) != 0 { |
| + t.Fatalf("the record was rewritten on a failed read: %+v", rec) |
| + } |
| + if _, err := fx.localCopy(); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("a local copy was written on a failed read (err %v)", err) |
| + } |
| + |
| + // Night B: the read succeeds. The history still shows data, so the |
| + // host is not left out. |
| + fx.clock.Advance(24 * time.Hour) |
| + fx.writeSelf(fxSelf, false) |
| + out = captureStdout(t, func() { code = fx.runner().run(context.Background()) }) |
| + if code != 0 { |
| + t.Fatalf("night B exited %d: %s\n%s", code, fx.logs, out) |
| + } |
| + rec := fx.published(fxSelf) |
| + if len(rec.LeftOut) != 0 { |
| + t.Fatalf("left out %+v: the host once had data", rec.LeftOut) |
| + } |
| + if v, ok := rec.Hosts[site]; !ok || !v.Unverified() || v.Reason != ReasonNothingReplicated { |
| + t.Fatalf("%s: %+v (in record %v), want unverified/nothing_replicated", site, v, ok) |
| + } |
| +} |
| + |
| +// firstGetFails fails the first read of key, then reads through. |
| +type firstGetFails struct { |
| + release.Store |
| + key string |
| + mu sync.Mutex |
| + failed bool |
| +} |
| + |
| +func (s *firstGetFails) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + s.mu.Lock() |
| + fail := key == s.key && !s.failed |
| + if fail { |
| + s.failed = true |
| + } |
| + s.mu.Unlock() |
| + if fail { |
| + return nil, "", errors.New("s3: get: SlowDown") |
| + } |
| + return s.Store.Get(ctx, key) |
| +} |
diff --git a/internal/ops/hibernate_verify_test.go b/internal/ops/hibernate_verify_test.go| index 2f2f7fa8e..fd3905c04 100644 |
| --- a/internal/ops/hibernate_verify_test.go |
| +++ b/internal/ops/hibernate_verify_test.go |
| @@ -354,7 +354,12 @@ func (fx *drillFx) routes(hosts ...string) []HibernatingRoute { |
| return out |
| } |
| -func (fx *drillFx) run(ctx context.Context, d Drill, hosts []HibernatingRoute, publish func(map[string]dbverify.Verdict) bool) map[string]dbverify.Verdict { |
| +func (fx *drillFx) run(ctx context.Context, d Drill, hosts []HibernatingRoute, publish func(RunResults) bool) map[string]dbverify.Verdict { |
| + return fx.runAll(ctx, d, hosts, publish).Verdicts |
| +} |
| + |
| +// runAll is run with the hosts left out too. |
| +func (fx *drillFx) runAll(ctx context.Context, d Drill, hosts []HibernatingRoute, publish func(RunResults) bool) RunResults { |
| return VerifyHibernating(ctx, d, hosts, fx.clock.Now, publish) |
| } |
| @@ -431,6 +436,136 @@ func TestVerifyHibernatingVerdicts(t *testing.T) { |
| fx.scratchEmpty() |
| } |
| +// TestVerifyHibernatingLeavesOutAHostWithNoDatabase: a host whose replica |
| +// holds nothing and whose live database file is absent from this box has |
| +// no database to back up (a static site, an instance that never opened |
| +// one). It gets no verdict: the run leaves it out, with when and the |
| +// incarnation. Only a proven absence counts: a file that is there, any |
| +// other answer from the disk, a relative path, and a route with no |
| +// database path keep nothing_replicated. Absence here proves nothing for |
| +// an HA host unless this box holds its lease (the evidence freshness |
| +// trusts); nor for a host whose prior verdict, for this incarnation, |
| +// shows it once had data. And the leave-out comes last: a host the |
| +// bracket refused, or whose bracket did not close clean, keeps the |
| +// verdict that says so. |
| +func TestVerifyHibernatingLeavesOutAHostWithNoDatabase(t *testing.T) { |
| + const host = "site.example.com" |
| + dir := t.TempDir() |
| + absent := filepath.Join(dir, "absent.db") |
| + present := filepath.Join(dir, "present.db") |
| + notADir := filepath.Join(dir, "file") |
| + dangling := filepath.Join(dir, "dangling.db") |
| + for _, p := range []string{present, notADir} { |
| + if err := os.WriteFile(p, []byte("x"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if err := os.Symlink(filepath.Join(dir, "nowhere.db"), dangling); err != nil { |
| + t.Fatal(err) |
| + } |
| + lock := func(held bool, owner string, err error) func(fx *drillFx) { |
| + return func(fx *drillFx) { |
| + swap(fx.t, &lockState, func(_ context.Context, _, location, _ string) (bool, string, time.Time, error) { |
| + if location != fx.prefix(host) { |
| + fx.t.Errorf("lock read at %s, want %s", location, fx.prefix(host)) |
| + } |
| + return held, owner, time.Now().Add(time.Minute), err |
| + }) |
| + } |
| + } |
| + prior := func(mutate func(fx *drillFx, v *dbverify.Verdict)) func(fx *drillFx) dbverify.Verdict { |
| + return func(fx *drillFx) dbverify.Verdict { |
| + v := dbverify.Verdict{Result: dbverify.ResultUnverified, Reason: ReasonNothingReplicated, Identity: fx.identity(host), |
| + UnverifiedRuns: 2, FirstSeen: at("2026-11-01T03:00:00Z"), VerifiedAt: at("2026-11-11T03:00:00Z")} |
| + mutate(fx, &v) |
| + return v |
| + } |
| + } |
| + cases := map[string]struct { |
| + dbPath string |
| + ha bool |
| + setup func(fx *drillFx) |
| + prior func(fx *drillFx) dbverify.Verdict |
| + leftOut bool |
| + reason string |
| + }{ |
| + "no database file": {dbPath: absent, leftOut: true}, |
| + "database file present": {dbPath: present, reason: ReasonNothingReplicated}, |
| + "stat fails another way": {dbPath: filepath.Join(notADir, "x.db"), reason: ReasonNothingReplicated}, |
| + "a dangling symlink": {dbPath: dangling, reason: ReasonNothingReplicated}, |
| + "no database path recorded": {dbPath: "", reason: ReasonNothingReplicated}, |
| + "a relative database path": {dbPath: filepath.Join("no-such-dir", "site.db"), reason: ReasonNothingReplicated}, |
| + "no record": {dbPath: absent, reason: dbverify.ReasonNoRecord, |
| + setup: func(fx *drillFx) { fx.deleteRecord(fxAccount, host) }}, |
| + "a staged copy waits": {dbPath: absent, reason: ReasonMoving, |
| + setup: func(fx *drillFx) { fx.stage(host) }}, |
| + "staging unreadable": {dbPath: absent, reason: ReasonStorageUnavailable, |
| + setup: func(fx *drillFx) { fx.stagingErr = errors.New("AccessDenied") }}, |
| + "record changed during the test": {dbPath: absent, reason: ReasonRecordChanged, |
| + setup: func(fx *drillFx) { |
| + fx.onList[fx.prefix(host)] = func() { fx.deleteRecord(fxAccount, host) } |
| + }}, |
| + |
| + "HA, this box holds the lease": {dbPath: absent, ha: true, leftOut: true, |
| + setup: lock(true, selfOwner(fxSelf), nil)}, |
| + "HA, no lease holder": {dbPath: absent, ha: true, reason: ReasonNothingReplicated, |
| + setup: lock(false, "", nil)}, |
| + "HA, another box holds the lease": {dbPath: absent, ha: true, reason: ReasonNothingReplicated, |
| + setup: lock(true, selfOwner("box-b"), nil)}, |
| + "HA, the lease cannot be read": {dbPath: absent, ha: true, reason: ReasonNothingReplicated, |
| + setup: lock(true, selfOwner(fxSelf), errors.New("SlowDown"))}, |
| + |
| + "prior unverified, never decided": {dbPath: absent, leftOut: true, |
| + prior: prior(func(*drillFx, *dbverify.Verdict) {})}, |
| + "prior passed, same incarnation": {dbPath: absent, reason: ReasonNothingReplicated, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.Result, v.Reason = dbverify.ResultPassed, "" })}, |
| + "prior failed, same incarnation": {dbPath: absent, reason: ReasonNothingReplicated, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.Result, v.Reason = dbverify.ResultFailed, ReasonRestoreError })}, |
| + "prior restored a position": {dbPath: absent, reason: ReasonNothingReplicated, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.TXID = 7 })}, |
| + "prior was decided once": {dbPath: absent, reason: ReasonNothingReplicated, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { v.LastDecidedAt = at("2026-11-05T03:00:00Z") })}, |
| + "prior passed, identity unknown": {dbPath: absent, reason: ReasonNothingReplicated, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { |
| + v.Result, v.Reason, v.Identity = dbverify.ResultPassed, "", dbverify.Identity{} |
| + })}, |
| + "prior passed, another incarnation": {dbPath: absent, leftOut: true, |
| + prior: prior(func(_ *drillFx, v *dbverify.Verdict) { |
| + v.Result, v.Reason = dbverify.ResultPassed, "" |
| + v.Identity.Incarnation = "an-earlier-one" |
| + })}, |
| + } |
| + for name, c := range cases { |
| + t.Run(name, func(t *testing.T) { |
| + fx := newDrillFx(t, host) |
| + fx.replicaFor[fx.prefix(host)] = fx.empty |
| + if c.setup != nil { |
| + c.setup(fx) |
| + } |
| + rt := fx.routes(host) |
| + rt[0].DBPath, rt[0].HA = c.dbPath, c.ha |
| + d := fx.drill() |
| + if c.prior != nil { |
| + d.Prior = &dbverify.Record{V: 2, Box: fxSelf, Hosts: map[string]dbverify.Verdict{host: c.prior(fx)}} |
| + } |
| + res := fx.runAll(context.Background(), d, rt, nil) |
| + v, decided := res.Verdicts[host] |
| + lo, left := res.LeftOut[host] |
| + switch { |
| + case c.leftOut && (decided || !left): |
| + t.Fatalf("verdict %+v (decided %v), left out %v; want no verdict, left out", v, decided, res.LeftOut) |
| + case c.leftOut && (!lo.At.Equal(fx.clock.Now()) || lo.Incarnation != fx.identity(host).Incarnation): |
| + t.Fatalf("left out as %+v, want at %s, incarnation %s", lo, fx.clock.Now(), fx.identity(host).Incarnation) |
| + case !c.leftOut && (!decided || left): |
| + t.Fatalf("left out %v, verdict %v; want unverified/%s", res.LeftOut, decided, c.reason) |
| + case !c.leftOut && (!v.Unverified() || v.Reason != c.reason): |
| + t.Fatalf("verdict %s/%s, want unverified/%s (%+v)", v.Result, v.Reason, c.reason, v) |
| + } |
| + fx.scratchEmpty() |
| + }) |
| + } |
| +} |
| + |
| // The per-host prefix must be the one the activator actually writes to, or |
| // every drill reports "no replica" over perfectly good backups; the lock |
| // read is the same prefix's. |
| @@ -1078,9 +1213,9 @@ func TestVerifyHibernatingPublishesPeriodically(t *testing.T) { |
| published := make(chan map[string]dbverify.Verdict, 8) |
| done := make(chan map[string]dbverify.Verdict) |
| go func() { |
| - done <- fx.run(context.Background(), d, fx.routes(hosts...), func(r map[string]dbverify.Verdict) bool { |
| + done <- fx.run(context.Background(), d, fx.routes(hosts...), func(r RunResults) bool { |
| ok := pub.publish(r) |
| - published <- r |
| + published <- r.Verdicts |
| return ok |
| }) |
| }() |
| @@ -1143,7 +1278,7 @@ func TestVerifyHibernatingTickWithNothingNewIsQuiet(t *testing.T) { |
| var calls atomic.Int32 |
| done := make(chan struct{}) |
| go func() { |
| - fx.run(context.Background(), d, fx.routes("a.example.com"), func(map[string]dbverify.Verdict) bool { calls.Add(1); return true }) |
| + fx.run(context.Background(), d, fx.routes("a.example.com"), func(RunResults) bool { calls.Add(1); return true }) |
| close(done) |
| }() |
| <-blocked |
| @@ -1194,7 +1329,7 @@ func TestVerifyHibernatingStreakOncePerRun(t *testing.T) { |
| d.PublishEvery = 10 * time.Minute |
| pub := newVerifyPublisher(context.Background(), store, fxSelf, prior, hosts, nil, t.TempDir(), fx.clock.Now, t.Logf) |
| // The unverified host first, so every publish of the run carries it. |
| - fx.run(context.Background(), d, fx.routes(hosts...), func(r map[string]dbverify.Verdict) bool { |
| + fx.run(context.Background(), d, fx.routes(hosts...), func(r RunResults) bool { |
| ok := pub.publish(r) |
| published <- struct{}{} |
| return ok |
diff --git a/internal/ops/ops.go b/internal/ops/ops.go| index 843976418..15bd44131 100644 |
| --- a/internal/ops/ops.go |
| +++ b/internal/ops/ops.go |
| @@ -374,6 +374,7 @@ func runHibernateVerify(args []string) { |
| Root: os.Geteuid() == 0, |
| Cfg: cfg, |
| OpenStore: openDeployStore, |
| + Fleet: fleetBox(os.Getenv), |
| Region: strings.TrimSpace(os.Getenv("CARLOS_REGION")), |
| DataDir: dir, |
| RegPath: rp, |
| @@ -404,9 +405,12 @@ var ( |
| // box named, so a test can run it whole. |
| type hibernateRun struct { |
| // Root is a run as effective uid 0, which run refuses first of all. |
| - Root bool |
| - Cfg *activator.Config |
| - OpenStore func(context.Context) (release.Store, error) |
| + Root bool |
| + Cfg *activator.Config |
| + OpenStore func(context.Context) (release.Store, error) |
| + // Fleet is the fleet this box is on (CARLOS_FLEET), "" on a platform |
| + // box. A fleet box with no deployment store of its own does not run. |
| + Fleet string |
| Region string // CARLOS_REGION: the region an instance's record must name; "" on a home-region box |
| DataDir string |
| RegPath string |
| @@ -483,6 +487,14 @@ func (r hibernateRun) run(ctx context.Context) int { |
| return 1 |
| } |
| store, err := r.OpenStore(ctx) |
| + if errors.Is(err, errNoDeployStore) && r.Fleet != "" { |
| + // A fleet box reaches its deployment through the console door, not |
| + // a bucket of its own (openDeployStore), so the records the bracket |
| + // binds each verdict to are out of its reach. Not a failure of the |
| + // box: a unit failing every night on every fleet box is noise. |
| + fmt.Println("hibernate-verify: fleet box: instance records are not reachable from here, so the drill does not run on fleet boxes yet") |
| + return 0 |
| + } |
| if err != nil { |
| r.Logf("hibernate-verify: NOT RUN: the deployment bucket, which holds the instances' records and this box's verdicts: %v", err) |
| return 1 |
| @@ -505,12 +517,15 @@ func (r hibernateRun) run(ctx context.Context) int { |
| ref := self.Ref |
| prior, err := dbverify.Load(ctx, store, ref) |
| if err != nil { |
| - if len(hosts) == 0 { |
| - r.Logf("hibernate-verify: reading %s: %v; no hosts here, and whether a record needs clearing is unknown, so nothing is published", dbverify.KeyFor(ref), err) |
| - return 1 |
| - } |
| - r.Logf("hibernate-verify: reading %s: %v (continuing; this run starts the record over)", dbverify.KeyFor(ref), err) |
| - prior = nil |
| + // An unreadable history is not an absent one: publishing over it |
| + // would reset every streak and erase the evidence that a host once |
| + // had data, which the leave-out rule relies on (a host with no |
| + // database is left out only when its history shows none). So the |
| + // run publishes nothing and fails; the record stands until a run |
| + // can read it, and a record that stays unreadable surfaces as |
| + // verify_coverage. |
| + r.Logf("hibernate-verify: NOT RUN: reading %s: %v; nothing is published, so the record stands until it can be read", dbverify.KeyFor(ref), err) |
| + return 1 |
| } |
| set, why := selectHosts(self, r.DataDir, r.Now(), hosts, r.Cfg.Prefix) |
| @@ -528,7 +543,7 @@ func (r hibernateRun) run(ctx context.Context) int { |
| fmt.Println("hibernate-verify: no hibernating instances for this box to drill") |
| return 0 |
| } |
| - pub.publish(nil) |
| + pub.publish(RunResults{}) |
| fmt.Println("hibernate-verify: no hibernating instances for this box to drill; its record is cleared") |
| return 0 |
| } |
| @@ -541,9 +556,10 @@ func (r hibernateRun) run(ctx context.Context) int { |
| defer os.RemoveAll(tmp) |
| d := Drill{Cfg: r.Cfg, Store: store, Region: r.Region, SelfRef: ref, TmpDir: tmp, |
| - Budget: r.Budget, Max: r.Max, PublishEvery: r.PublishEvery} |
| + Budget: r.Budget, Max: r.Max, PublishEvery: r.PublishEvery, Prior: prior} |
| results := VerifyHibernating(ctx, d, OldestFirst(set.Drill, prior), r.Now, pub.publish) |
| rec := pub.last |
| + left := len(results.LeftOut) |
| if n := rec.Failures(); n > 0 { |
| r.Logf("hibernate-verify: %d replica(s) did not restore clean", n) |
| @@ -553,13 +569,15 @@ func (r hibernateRun) run(ctx context.Context) int { |
| // coverage, and a summary that said otherwise would be the same comfortable |
| // lie this verb exists to remove. |
| proven := 0 |
| - for _, v := range results { |
| + for _, v := range results.Verdicts { |
| if v.OK() { |
| proven++ |
| } |
| } |
| - fmt.Printf("hibernate-verify: %d of %d replicas this box drills proven this run (%d visited, %d in its record)\n", |
| - proven, len(set.Drill), len(results), len(set.Fleet)) |
| + // A host left out has no database, so no replica to prove: it is |
| + // counted apart, not as one this box drills. |
| + fmt.Printf("hibernate-verify: %d of %d replicas this box drills proven this run (%d visited, %d in its record%s)\n", |
| + proven, len(set.Drill)-left, len(results.Verdicts)+left, len(rec.Hosts), leftOutNote(left)) |
| return 0 |
| } |
| @@ -628,6 +646,9 @@ func newVerifyPublisher(ctx context.Context, store release.Store, ref string, pr |
| for h := range prior.Hosts { |
| p.known[h] = true |
| } |
| + for h := range prior.LeftOut { |
| + p.known[h] = true |
| + } |
| } |
| return p |
| } |
| @@ -638,17 +659,22 @@ func newVerifyPublisher(ctx context.Context, store release.Store, ref string, pr |
| // stopped, still publishes what it finished. The local copy is written |
| // whether or not the publish succeeded, so the box's own alerts see it. |
| // It reports whether the bucket took the record. |
| -func (p *verifyPublisher) publish(results map[string]dbverify.Verdict) bool { |
| - all := make(map[string]dbverify.Verdict, len(results)+len(p.extra)) |
| +// |
| +// A host the run left out (no database to back up) goes to the record's |
| +// LeftOut (dbverify.MergeLeftOut), so neither its verdict from the |
| +// run-start record nor a not_reached is carried for it. |
| +func (p *verifyPublisher) publish(results RunResults) bool { |
| + all := make(map[string]dbverify.Verdict, len(results.Verdicts)+len(p.extra)) |
| for h, v := range p.extra { |
| all[h] = v |
| } |
| - for h, v := range results { |
| + for h, v := range results.Verdicts { |
| all[h] = v |
| } |
| - rec := dbverify.Merge(p.prior, p.ref, p.now(), p.fleet, all) |
| + rec := dbverify.MergeLeftOut(p.prior, p.ref, p.now(), p.fleet, all, results.LeftOut) |
| for h := range p.dropped { |
| delete(rec.Hosts, h) |
| + delete(rec.LeftOut, h) |
| } |
| ctx, cancel := context.WithTimeout(context.WithoutCancel(p.ctx), publishTimeout) |
| defer cancel() |
| @@ -664,7 +690,10 @@ func (p *verifyPublisher) publish(results map[string]dbverify.Verdict) bool { |
| for h := range rec.Hosts { |
| p.known[h] = true |
| } |
| - fmt.Printf("hibernate-verify: published %s (%d hosts, %d unverified)\n", dbverify.KeyFor(p.ref), len(rec.Hosts), rec.Unverified()) |
| + for h := range rec.LeftOut { |
| + p.known[h] = true |
| + } |
| + fmt.Printf("hibernate-verify: published %s (%d hosts, %d unverified%s)\n", dbverify.KeyFor(p.ref), len(rec.Hosts), rec.Unverified(), leftOutNote(len(results.LeftOut))) |
| } else { |
| p.logf("hibernate-verify: NOT PUBLISHED: %v; the verdicts exist only in this log and %s", err, localVerifyPath(p.dataDir)) |
| } |
| @@ -674,6 +703,15 @@ func (p *verifyPublisher) publish(results map[string]dbverify.Verdict) bool { |
| return ok |
| } |
| +// leftOutNote is the run log's count of the hosts left out for having no |
| +// database, "" when there are none. |
| +func leftOutNote(n int) string { |
| + if n == 0 { |
| + return "" |
| + } |
| + return fmt.Sprintf(", %d left out (no database)", n) |
| +} |
| + |
| // localVerifyPath is the local alert copy, beside the agent's self record: |
| // <data>/monitor/verify.json. |
| func localVerifyPath(dataDir string) string { |
| @@ -693,11 +731,22 @@ func writeLocalVerify(dataDir string, rec *dbverify.Record) error { |
| return boxself.WriteFile(localVerifyPath(dataDir), body, dbverify.LocalMax) |
| } |
| +// errNoDeployStore is openDeployStore's answer when neither variable is set. |
| +var errNoDeployStore = errors.New("neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR is set") |
| + |
| +// fleetBox is the fleet this box is on (CARLOS_FLEET), "" on a platform box. |
| +// The agent's own test is the variable being set (internal/host, |
| +// shouldSkipPublisherElection); a value of only spaces is not a fleet here, |
| +// so it fails as a platform box would rather than going quiet. |
| +func fleetBox(getenv func(string) string) string { |
| + return strings.TrimSpace(getenv("CARLOS_FLEET")) |
| +} |
| + |
| // openDeployStore resolves the deployment bucket the same way the agent's |
| // bucket/dir env vars do. A fleet box that reaches its deployment through the |
| // console door instead (openDeployStoreEnv's third case in internal/host) is |
| -// NOT covered here and is told so out loud rather than publishing nothing |
| -// quietly. |
| +// NOT covered here: it gets errNoDeployStore, and the run says so in one |
| +// line and stops without failing (hibernateRun.Fleet). |
| func openDeployStore(ctx context.Context) (release.Store, error) { |
| if b := os.Getenv("CARLOS_DEPLOYMENT_BUCKET"); b != "" { |
| return release.NewDeploymentS3Store(ctx, b) |
| @@ -707,5 +756,5 @@ func openDeployStore(ctx context.Context) (release.Store, error) { |
| ds.EnableChangeIndex() |
| return ds, nil |
| } |
| - return nil, errors.New("neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR is set") |
| + return nil, errNoDeployStore |
| } |
diff --git a/internal/provision/member_backups_drill_nodb_census_test.go b/internal/provision/member_backups_drill_nodb_census_test.go| new file mode 100644 |
| index 000000000..024b51af4 |
| --- /dev/null |
| +++ b/internal/provision/member_backups_drill_nodb_census_test.go |
| @@ -0,0 +1,43 @@ |
| +package provision |
| + |
| +// memberBackupsDrillNodbWriteCensusInventory is the review of the restore |
| +// drill's no-database fix (member-backups-drill-nodb, #898) of the |
| +// record-write census, layered on staticSiteGeo962WriteCensusInventory. |
| +// |
| +// The drill now records the hosts it left out for having no database in a |
| +// new, additive field of its own record, left_out, beside hosts. Two units |
| +// are re-digested; no record write is added and no class or kind changes. |
| +// Neither touches an instance record or a sidecar: |
| +// - dbverify.PublishOver: the same Get-then-CAS Put of |
| +// dbverify.KeyFor(rec.Box), three attempts, with the same |
| +// ErrInvalidRef refusal. Inside each attempt the hosts the caller knew |
| +// that the record in the bucket no longer has, in hosts or in |
| +// left_out, are deleted from rec's hosts and left_out both. It writes |
| +// nothing else and no record path. nonrecord / sel:Put, as before. |
| +// - dbverify.RemoveHost: the same load, delete and CAS Put of box ref's |
| +// own record at KeyFor(ref) inside each attempt; it now deletes the |
| +// host from left_out as well as from hosts, and does nothing when it is |
| +// in neither. Other boxes' records are never touched. nonrecord / |
| +// sel:Put, as before. |
| +func memberBackupsDrillNodbWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), staticSiteGeo962WriteCensusInventory()...) |
| + repins := []censusEntry{ |
| + {"internal/dbverify/dbverify.go", "PublishOver", "nonrecord", "sel:Put", "ffbd3d714522880a236b80fa45136872739d864305243979bf181e17057ee7dd"}, |
| + {"internal/dbverify/dbverify.go", "RemoveHost", "nonrecord", "sel:Put", "78aad0af7e4d298fd00814984f0bd9e4ecce9d95b8007e11658b75b7e8e14779"}, |
| + } |
| + for _, r := range repins { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("member-backups-drill-nodb census: classification changed for " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], found = r, true |
| + } |
| + } |
| + if !found { |
| + panic("member-backups-drill-nodb census: re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + return entries |
| +} |
diff --git a/internal/provision/platform_mail_submission_census_test.go b/internal/provision/platform_mail_submission_census_test.go| index c0b219953..79437a39e 100644 |
| --- a/internal/provision/platform_mail_submission_census_test.go |
| +++ b/internal/provision/platform_mail_submission_census_test.go |
| @@ -3,7 +3,7 @@ package provision |
| // platformMailSubmissionWriteCensusInventory is the platform mail submission |
| // review (plan docs/superpowers/plans/2026-11-13-platform-mail-submission.md, |
| // Task 1) of the record-write census, layered on |
| -// staticSiteGeo962WriteCensusInventory. |
| +// memberBackupsDrillNodbWriteCensusInventory. |
| // |
| // Four units are re-digested; no record write is added and no class or kind |
| // changes. Each one reads a sender's pause through EffectivePause (the new |
| @@ -22,7 +22,7 @@ package provision |
| // follows the app's pause by EffectivePause. reference / id:Put, as |
| // before. |
| func platformMailSubmissionWriteCensusInventory() []censusEntry { |
| - entries := append([]censusEntry(nil), staticSiteGeo962WriteCensusInventory()...) |
| + entries := append([]censusEntry(nil), memberBackupsDrillNodbWriteCensusInventory()...) |
| repins := []censusEntry{ |
| {"internal/mail/walk.go", "claimUnserializedEnable", "reference", "id:Put", "d1846550f43f9150ea6205f5c2f0c9c257964796a6242736bfed0b976a9c6475"}, |
| {"internal/mail/walk.go", "claimUnserializedRotate", "reference", "id:Put", "77f02ea1bdece0db273af097dc73ac3713642ebbbaadd79a44c55e57b04cbb53"}, |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 15a693f58..db711e74d 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -201,4 +201,5 @@ plan14-root-reads-ha-unclean-marker-waits.tsv 821598970e60a776d4a62138d5adbfa393 |
| plan14-root-reads-ha-unclean-files-only.tsv bc138ce5435f3ab37f6adff46656eea1c20f48168c569550fe94e390c69ba309 |
| plan14-root-reads-edge-ppv2.tsv 44e5745a1d22ea2ddd6e73d775d87759afe7121666212b6ed2563c1518261bc4 |
| plan14-root-reads-static-site-geo-962.tsv 5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376 |
| -plan14-root-reads-platform-mail-submission.tsv 5e8a72175700a3e60c1e283b133c1ee25e36f292e2e319f02a19138f15186376 |
| +plan14-root-reads-member-backups-drill-nodb.tsv 07b748a749084fdaf61c5087a6edfca8a79273962822ce551dd4d42b0d20c063 |
| +plan14-root-reads-platform-mail-submission.tsv 07b748a749084fdaf61c5087a6edfca8a79273962822ce551dd4d42b0d20c063 |
diff --git a/internal/provision/testdata/plan14-root-reads-member-backups-drill-nodb.tsv b/internal/provision/testdata/plan14-root-reads-member-backups-drill-nodb.tsv| new file mode 100644 |
| index 000000000..5ddec2bec |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-member-backups-drill-nodb.tsv |
| @@ -0,0 +1,9 @@ |
| +# Census overlay member-backups-drill-nodb, written by census-propose (#369). census-ruling-member-backups-drill-nodb, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-member-backups-drill-nodb.md. |
| +# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 8186546efb3553303c18ab31151b5129d3011e505cebee7caf84d21992202b42 internal/ops/ops.go hibernateRun.run legacy accepted-legacy accepted-legacy;rev3=census-ruling-member-backups-2a;basis=new, the drill (carlos ops hibernate-verify, user carlos): the verb's body, moved out of runHibernateVerify so a test can run it whole. First of all it refuses root (Root, from os.Geteuid() == 0 in runHibernateVerify): one log line, exit 1, before any monitor file is read, the deployment store opened or the registry opened (census round 1 P1, ls284: self.json, which the carlos user writes, names the record a run replaces). Then, as before: boxself.ReadFresh of self.json (refuses to run without a fresh record), dbreads.ValidRegion(CARLOS_REGION), openDeployStore, registry.Open(RegPath) (its +file:Open, the same registry the old body opened, closed after HibernatingHosts), dbverify.Load of this box's own control/verify/<ref>.json, selectHosts (verify-assign.json on a group box), MkdirTemp under the unit's on-disk TMPDIR, the drill, and dbverify.Publish to control/verify/<ref>.json only. Final fix wave (still refusing root first): the self.json read is retried every 15 s for up to 5 minutes (SelfWait, the same boxself.ReadFresh), a fleet box's CARLOS_REGION fleet/<name> is accepted beside dbreads.ValidRegion, it calls clearCrashedScratch on its own TmpDir right after the root refusal and the hibernate-config check, before the self record and both empty-fleet returns (re-review item 9), and its publisher now writes through dbverify.PublishOver (the same Get-then-CAS Put of control/verify/<ref>.json, also parsing the record it reads to drop hosts a landing removed). No new read source.;rev3=census-ruling-member-backups-2a-landing;basis=R3 (#898): an empty CARLOS_REGION (a home-region box) is the home region and no longer refuses; the bracket matches records whose region is "" exactly. A malformed non-empty region still refuses (dbreads.ValidRegion, or a fleet/<name> placement). No read added or changed: the same refusals in the same order (root first, then self.json, then the region gate), the same stores. Package envelopes: internal/ops adds one read-only bounded ListPage (one key) of moves/<host>/ in the drill's own data bucket at each end of a host's bracket (R1), and the bracket compares the record's LastMove (R1b) and the record object's stamp (R1c: ETag, version id, last-modified) at open and close, all from the same record GET it already made (now provision.GetRecordStamped / GetSidecarRecordStamped); internal/provision adds those two read-only getters (decodeSidecarAt shared with GetSidecarRecord, no writer touched); internal/release adds GetStamped, S3Store.GetStamped and ObjectStamp; internal/lease adds VerifyReaderAt and a read-only litestream client (R2); internal/dbdoor adds PlanListed, the planner's listing as a list/open reader (R2). The drill runs as carlos and refuses root.;rev3=census-ruling-member-backups-drill-nodb;basis=the drill (user carlos). No read added or changed, same refusals in the same order (root first, then self.json, then the region gate). One new exit: when openDeployStore answers errNoDeployStore (neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR set) and Fleet (CARLOS_FLEET trimmed, read once in runHibernateVerify) is non-empty, it prints one line and returns 0 before the registry is opened, publishing nothing. Any other store error, and a platform box with no store, still log NOT RUN and return 1. The record it already loaded (dbverify.Load of its own control/verify/<ref>.json) is also handed to the drill as Drill.Prior, read only to refuse a leave-out for an incarnation that once had data. The publisher now takes RunResults and merges with dbverify.MergeLeftOut: hosts the run left out (no database) go to the record's additive left_out field instead of hosts, written by the same PublishOver Put of control/verify/<ref>.json and the same local copy <data>/monitor/verify.json; the summary lines count them. file:Open@2885 b3bf8afe0b9932aed22d86c1bdde1411078aafc72087001b7c4eb18615ae171e |
| +@legacy eda29e15054dad56308472163a577413301cab4d12cf640768dc892458459f8a internal/ops/hibernate_verify.go noDatabase legacy accepted-legacy accepted-legacy;rev3=census-ruling-member-backups-drill-nodb;basis=new, the drill (user carlos): os.Lstat of a hibernating route's DBPath from this box's own registry (the path HibernatingHosts already returns and freshness already reads through localFreshness), only when the path is absolute (a relative or empty path answers false with no syscall); only its error is looked at, nothing is opened or followed (lstat does not follow a final symlink). Called once per host, only in drillOne's final restoreNothing case after the identity bracket and the move staging closed clean; not-exist leaves the host out of the record only if, for an HA route, this box holds the lease (the same lockState read freshness makes) and the prior record shows no data for the incarnation; anything else keeps unverified/nothing_replicated. file:Lstat@107 1a971e6818d7e0478444b0c2fc6904e7b772fa22cbe90c86a20d11f521ceeda1 |
| +internal/ops/ops.go hibernateRun.run legacy accepted-legacy accepted-legacy;rev3=census-ruling-member-backups-2a;basis=new, the drill (carlos ops hibernate-verify, user carlos): the verb's body, moved out of runHibernateVerify so a test can run it whole. First of all it refuses root (Root, from os.Geteuid() == 0 in runHibernateVerify): one log line, exit 1, before any monitor file is read, the deployment store opened or the registry opened (census round 1 P1, ls284: self.json, which the carlos user writes, names the record a run replaces). Then, as before: boxself.ReadFresh of self.json (refuses to run without a fresh record), dbreads.ValidRegion(CARLOS_REGION), openDeployStore, registry.Open(RegPath) (its +file:Open, the same registry the old body opened, closed after HibernatingHosts), dbverify.Load of this box's own control/verify/<ref>.json, selectHosts (verify-assign.json on a group box), MkdirTemp under the unit's on-disk TMPDIR, the drill, and dbverify.Publish to control/verify/<ref>.json only. Final fix wave (still refusing root first): the self.json read is retried every 15 s for up to 5 minutes (SelfWait, the same boxself.ReadFresh), a fleet box's CARLOS_REGION fleet/<name> is accepted beside dbreads.ValidRegion, it calls clearCrashedScratch on its own TmpDir right after the root refusal and the hibernate-config check, before the self record and both empty-fleet returns (re-review item 9), and its publisher now writes through dbverify.PublishOver (the same Get-then-CAS Put of control/verify/<ref>.json, also parsing the record it reads to drop hosts a landing removed). No new read source.;rev3=census-ruling-member-backups-2a-landing;basis=R3 (#898): an empty CARLOS_REGION (a home-region box) is the home region and no longer refuses; the bracket matches records whose region is "" exactly. A malformed non-empty region still refuses (dbreads.ValidRegion, or a fleet/<name> placement). No read added or changed: the same refusals in the same order (root first, then self.json, then the region gate), the same stores. Package envelopes: internal/ops adds one read-only bounded ListPage (one key) of moves/<host>/ in the drill's own data bucket at each end of a host's bracket (R1), and the bracket compares the record's LastMove (R1b) and the record object's stamp (R1c: ETag, version id, last-modified) at open and close, all from the same record GET it already made (now provision.GetRecordStamped / GetSidecarRecordStamped); internal/provision adds those two read-only getters (decodeSidecarAt shared with GetSidecarRecord, no writer touched); internal/release adds GetStamped, S3Store.GetStamped and ObjectStamp; internal/lease adds VerifyReaderAt and a read-only litestream client (R2); internal/dbdoor adds PlanListed, the planner's listing as a list/open reader (R2). The drill runs as carlos and refuses root.;rev3=census-ruling-member-backups-drill-nodb;basis=the drill (user carlos). No read added or changed, same refusals in the same order (root first, then self.json, then the region gate). One new exit: when openDeployStore answers errNoDeployStore (neither CARLOS_DEPLOYMENT_BUCKET nor CARLOS_DEPLOYMENT_DIR set) and Fleet (CARLOS_FLEET trimmed, read once in runHibernateVerify) is non-empty, it prints one line and returns 0 before the registry is opened, publishing nothing. Any other store error, and a platform box with no store, still log NOT RUN and return 1. The record it already loaded (dbverify.Load of its own control/verify/<ref>.json) is also handed to the drill as Drill.Prior, read only to refuse a leave-out for an incarnation that once had data. The publisher now takes RunResults and merges with dbverify.MergeLeftOut: hosts the run left out (no database) go to the record's additive left_out field instead of hosts, written by the same PublishOver Put of control/verify/<ref>.json and the same local copy <data>/monitor/verify.json; the summary lines count them. file:Open@2885 b3bf8afe0b9932aed22d86c1bdde1411078aafc72087001b7c4eb18615ae171e |
| +internal/ops/hibernate_verify.go noDatabase legacy accepted-legacy accepted-legacy;rev3=census-ruling-member-backups-drill-nodb;basis=new, the drill (user carlos): os.Lstat of a hibernating route's DBPath from this box's own registry (the path HibernatingHosts already returns and freshness already reads through localFreshness), only when the path is absolute (a relative or empty path answers false with no syscall); only its error is looked at, nothing is opened or followed (lstat does not follow a final symlink). Called once per host, only in drillOne's final restoreNothing case after the identity bracket and the move staging closed clean; not-exist leaves the host out of the record only if, for an HA route, this box holds the lease (the same lockState read freshness makes) and the prior record shows no data for the incarnation; anything else keeps unverified/nothing_replicated. file:Lstat@107 1a971e6818d7e0478444b0c2fc6904e7b772fa22cbe90c86a20d11f521ceeda1 |
| +@coverage internal/dbverify 35634dfea8793484ea365d297ccfc4811c9dfe3db997603bcf6e37b0c1dd6c34 |
| +@coverage internal/ops c40936f746ee5dee21d2d11f98c3c7e52f0922c117bf331b53073e4c44df8157 |