rootfs apps plan 3: Task 5 fix round 1, retention needs a report for every runtime record, rootfs rows are not nested evidence, recovery drops a rootfs host's journal unmoved
Retention requires a fresh, complete box report for every record with a runtime; the kind, unit and hibernation exclusions apply to binary records only. nestedRowsPresent and addMintsNested count only binary rows as evidence the box moved to nested. Journal recovery checks the runtime before it stops anything and again on the row under the fence: a journal naming a rootfs or unknown-runtime host is refused, removed, and nothing moves. Stale comments updated; two more left-on-Hibernate notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 files changed,
+286
−27
cli.go+3 −1internal/edge/prober.go+2 −2internal/host/layoutleg.go+5 −3internal/host/retention.go+8 −6internal/host/rootfs_advice_test.go+90 −13internal/layout/pass.go+28 −0internal/layout/rootfs_pass_test.go+107 −0internal/provision/provision.go+2 −1internal/provision/reconcile.go+1 −1internal/release/adopt.go+2 −0internal/release/rootrestart_history.go+2 −0rootfs_layout_evidence_test.go+36 −0
diff --git a/cli.go b/cli.go| index 8701cf506..bbac051f4 100644 |
| --- a/cli.go |
| +++ b/cli.go |
| @@ -138,8 +138,10 @@ func addMintsNested(ctx context.Context, store release.Store, boxLabel func() st |
| return in.Mode == release.LayoutModeNested, nil |
| } |
| } |
| + // Only a binary row is evidence the box moved: a row with a runtime is |
| + // minted nested on every box. |
| for _, rt := range routes { |
| - if activator.ActivatorManaged(rt) && provision.NestedPaths(dd, rt) { |
| + if activator.ActivatorManaged(rt) && rt.Runtime == "" && provision.NestedPaths(dd, rt) { |
| return true, nil |
| } |
| } |
diff --git a/internal/edge/prober.go b/internal/edge/prober.go| index b6b0b6de8..5ebc6d21b 100644 |
| --- a/internal/edge/prober.go |
| +++ b/internal/edge/prober.go |
| @@ -23,8 +23,8 @@ package edge |
| // provision.ValidateShape refuses `addrs` together with `hibernate: true` |
| // outright (internal/provision/provision.go, "addr with hibernate"), so a |
| // probed route is never activator-managed in the first place. Reload's |
| -// `hib` gate is NOT that door — it reads `Kind == "instance" && Hibernate |
| -// && !viaTunnel` and says nothing about addrs — so a hand-written registry |
| +// `hib` gate is NOT that door — it reads `ActivatorOwned() && !viaTunnel` |
| +// and says nothing about addrs — so a hand-written registry |
| // row could still pair the two, and would then hibernate a process whose |
| // upstream the probe keeps marking down. Fixing that means widening the |
| // gate, not trusting this comment. |
diff --git a/internal/host/layoutleg.go b/internal/host/layoutleg.go| index 740486151..296bfc5ff 100644 |
| --- a/internal/host/layoutleg.go |
| +++ b/internal/host/layoutleg.go |
| @@ -287,12 +287,14 @@ func socketsGID() int { |
| return n |
| } |
| -// nestedRowsPresent reports whether any activator-managed row on the box is |
| -// already at the nested paths. |
| +// nestedRowsPresent reports whether any activator-managed binary row on the |
| +// box is already at the nested paths. A row with a runtime is not evidence: |
| +// a rootfs row is minted nested on every box, so it says nothing about |
| +// whether the box has moved. |
| func nestedRowsPresent(rows []registry.Route) bool { |
| dd := provisionTickConfig(os.Getenv).DataDir |
| for _, rt := range rows { |
| - if activator.ActivatorManaged(rt) && provision.NestedPaths(dd, rt) { |
| + if activator.ActivatorManaged(rt) && rt.Runtime == "" && provision.NestedPaths(dd, rt) { |
| return true |
| } |
| } |
diff --git a/internal/host/retention.go b/internal/host/retention.go| index 51aaacd29..f1a6ff60f 100644 |
| --- a/internal/host/retention.go |
| +++ b/internal/host/retention.go |
| @@ -391,13 +391,15 @@ func settingsProtected(ctx context.Context, store release.Store, boxes []status. |
| // never "nothing to protect". For a valid record this is |
| // keepsBuildState's instance rule (activator.ActivatorManaged): an |
| // instance with no unit that hibernates has no addr (the record door |
| - // refuses addr with hibernate), so reconcile mints it a socket. A |
| - // rootfs record is the same whether or not it hibernates: a resident |
| - // never sleeps but the activator owns it, reconcile mints it nested |
| - // (no addr: validateRuntime), and its box reports its build state like |
| - // a hibernating one's [Astra R3 2]. |
| + // refuses addr with hibernate), so reconcile mints it a socket. Every |
| + // record with a runtime needs a report whatever its kind, unit or |
| + // hibernation: a resident never sleeps but the activator owns it and |
| + // its box reports its build state like a hibernating one's [Astra R3 |
| + // 2], and a runtime this binary does not know (a newer console's) is |
| + // owned the same way, so its report is no less required. The |
| + // exclusions are a binary record's only. |
| for _, r := range recs { |
| - if r.KindOrDefault() != "instance" || r.Unit != "" || (!r.HibernateOrDefault() && r.Runtime != provision.RuntimeRootfsV1) { |
| + if r.Runtime == "" && (r.KindOrDefault() != "instance" || r.Unit != "" || !r.HibernateOrDefault()) { |
| continue |
| } |
| if _, ok := byHost[r.Host]; !ok { |
diff --git a/internal/host/rootfs_advice_test.go b/internal/host/rootfs_advice_test.go| index e079be04a..cb2c810dc 100644 |
| --- a/internal/host/rootfs_advice_test.go |
| +++ b/internal/host/rootfs_advice_test.go |
| @@ -2,6 +2,7 @@ package host |
| import ( |
| "context" |
| + "errors" |
| "log" |
| "os" |
| "path/filepath" |
| @@ -227,11 +228,56 @@ func TestRetentionRefusesWithoutAResidentReport(t *testing.T) { |
| // Through the pass: an eligible build named only by the resident's |
| // build state, whose report is absent. Nothing is deleted. |
| - dir := t.TempDir() |
| - ds := release.NewDirStore(dir) |
| - if err := provision.CreateRecord(ctx, ds, residentRecord(host)); err != nil { |
| + retentionPassWaitsForReport(t, host, registry.RuntimeRootfsV1, func(ds *release.DirStore) { |
| + if err := provision.CreateRecord(ctx, ds, residentRecord(host)); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| +} |
| + |
| +// unknownRuntimeRecord is a record a newer console wrote: a runtime this |
| +// binary does not know, awake. CreateRecord refuses it (ValidateShape), so |
| +// it goes into the store as the newer console would have put it. |
| +func unknownRuntimeRecord(t *testing.T, s release.Store, host string) { |
| + t.Helper() |
| + raw := `{"schema":1,"host":"` + host + `","app":"km","account":"bab","channel":"stable","runtime":"rootfs-v9","hibernate":false}` |
| + if _, err := s.Put(context.Background(), provision.RecordKey("bab", "km", host), []byte(raw), ""); err != nil { |
| t.Fatal(err) |
| } |
| +} |
| + |
| +// TestRetentionRefusesWithoutAnUnknownRuntimeReport (controller ruling, |
| +// task 5 fix round 1): every record with a runtime needs a fresh, complete |
| +// report, a runtime this binary does not know included, whatever its |
| +// hibernation. A rootfs-v9 record with hibernate=0 and no report makes |
| +// settingsProtected refuse, and the pass deletes nothing. |
| +func TestRetentionRefusesWithoutAnUnknownRuntimeReport(t *testing.T) { |
| + t.Parallel() |
| + ctx := context.Background() |
| + const host = "later.example.com" |
| + s := release.NewDirStore(t.TempDir()) |
| + unknownRuntimeRecord(t, s, host) |
| + recs, err := appRecords(ctx, s, "bab", "km") |
| + if err != nil || len(recs) != 1 || recs[0].Runtime != "rootfs-v9" || recs[0].HibernateOrDefault() { |
| + t.Fatalf("the newer console's record reads as %+v, %v; want one awake rootfs-v9 record", recs, err) |
| + } |
| + if _, err := settingsProtected(ctx, s, []status.Box{report("uk-1", now0.Add(-time.Minute), map[string]status.BuildStatePins{})}, true, now0, "bab", "km"); err == nil { |
| + t.Error("settingsProtected with no report naming an awake rootfs-v9 record = nil error, want a refusal") |
| + } |
| + retentionPassWaitsForReport(t, host, "rootfs-v9", func(ds *release.DirStore) { unknownRuntimeRecord(t, ds, host) }) |
| +} |
| + |
| +// retentionPassWaitsForReport runs retentionPass over an app whose one |
| +// record (put) names host, with v01..v05 eligible under keep-20 unless |
| +// host's build state names them. With no report naming host, nothing is |
| +// deleted; with a fresh, complete one naming v03, v01 goes and v03 stays, |
| +// so the zero is the refusal and nothing else. |
| +func retentionPassWaitsForReport(t *testing.T, host, runtime string, put func(*release.DirStore)) { |
| + t.Helper() |
| + ctx := context.Background() |
| + dir := t.TempDir() |
| + ds := release.NewDirStore(dir) |
| + put(ds) |
| base := time.Now().Add(-30 * 24 * time.Hour) |
| vname := func(i int) string { return "v" + string(rune('0'+i/10)) + string(rune('0'+i%10)) } |
| for i := 1; i <= 25; i++ { |
| @@ -239,9 +285,7 @@ func TestRetentionRefusesWithoutAResidentReport(t *testing.T) { |
| stampKey(t, ds, dir, release.ArtifactKey("bab", "km", vname(i), "linux-arm64"), base.Add(time.Duration(i)*time.Hour)) |
| } |
| _, pub := retentionKeys(t) |
| - // keep-20 protects v06..v25; the row pins v25. v01..v05 are eligible |
| - // unless the resident's build state names them, which only its |
| - // (absent) report could say. |
| + // keep-20 protects v06..v25; the row pins v25. |
| if err := release.SetRetention(ctx, ds, "bab", "km", 20, "test", time.Now()); err != nil { |
| t.Fatal(err) |
| } |
| @@ -251,7 +295,7 @@ func TestRetentionRefusesWithoutAResidentReport(t *testing.T) { |
| } |
| defer reg.Close() |
| if err := reg.Upsert(registry.Route{Host: host, Kind: "instance", App: "km", Account: "bab", Status: "ready", |
| - Runtime: registry.RuntimeRootfsV1, Version: "v25", Socket: provision.NestedSocket(host), DBPath: provision.NestedDBPath(dir, host)}); err != nil { |
| + Runtime: runtime, Version: "v25", Socket: provision.NestedSocket(host), DBPath: provision.NestedDBPath(dir, host)}); err != nil { |
| t.Fatal(err) |
| } |
| rec := &deleteRecorder{DirStore: ds} |
| @@ -260,17 +304,15 @@ func TestRetentionRefusesWithoutAResidentReport(t *testing.T) { |
| } |
| for _, k := range rec.deleted { |
| if strings.Contains(k, "/releases/") { |
| - t.Errorf("retention deleted %s with the resident's report absent", k) |
| + t.Errorf("%s: retention deleted %s with the report absent", runtime, k) |
| } |
| } |
| for _, v := range []string{"v01", "v02", "v03", "v04", "v05"} { |
| if _, _, err := ds.Get(ctx, release.ManifestKey("bab", "km", v)); err != nil { |
| - t.Errorf("%s pruned with the resident's report absent: %v", v, err) |
| + t.Errorf("%s: %s pruned with the report absent: %v", runtime, v, err) |
| } |
| } |
| - // The control: once a fresh, complete report names the resident, the |
| - // same pass prunes, so the zero above is the refusal and nothing else. |
| local := func() (map[string]status.BuildStatePins, error) { |
| return map[string]status.BuildStatePins{host: kmPins("v03")}, nil |
| } |
| @@ -278,10 +320,10 @@ func TestRetentionRefusesWithoutAResidentReport(t *testing.T) { |
| t.Fatal(err) |
| } |
| if _, _, err := ds.Get(ctx, release.ManifestKey("bab", "km", "v01")); err == nil { |
| - t.Error("v01 kept with a fresh, complete report naming the resident: the control pruned nothing") |
| + t.Errorf("%s: v01 kept with a fresh, complete report: the control pruned nothing", runtime) |
| } |
| if _, _, err := ds.Get(ctx, release.ManifestKey("bab", "km", "v03")); err != nil { |
| - t.Errorf("v03, named by the resident's build state, was pruned: %v", err) |
| + t.Errorf("%s: v03, named by the build state, was pruned: %v", runtime, err) |
| } |
| } |
| @@ -332,3 +374,38 @@ func TestLayoutLegIsQuietAboutKeptRootfsRows(t *testing.T) { |
| t.Errorf("a kept rootfs row was logged: %q", buf.String()) |
| } |
| } |
| + |
| +// TestMintEvidenceIgnoresRootfsRows (task 5 fix round 1): with no intent, |
| +// the nested default and its gate not yet passed, a binary row is minted |
| +// flat unless a binary managed row already sits at the nested paths. A |
| +// resident or an unknown runtime there is no such proof: rootfs rows are |
| +// nested by construction. Not parallel: it sets env and the layout globals. |
| +func TestMintEvidenceIgnoresRootfsRows(t *testing.T) { |
| + resetLayoutGlobals(t) |
| + t.Setenv(layoutDefaultEnv, "") |
| + prev := layoutBuild |
| + t.Cleanup(func() { layoutBuild = prev }) |
| + layoutBuild = func() string { return "v0.25.0" } |
| + t.Setenv("CARLOS_DATA_DIR", "/data") |
| + armDefaultGate(t, errors.New("not yet run")) |
| + ctx := context.Background() |
| + s := release.NewDirStore(t.TempDir()) |
| + nested := func(host, runtime string, hib bool) registry.Route { |
| + return registry.Route{Host: host, Kind: "instance", Runtime: runtime, Hibernate: hib, |
| + Socket: provision.NestedSocket(host), DBPath: provision.NestedDBPath("/data", host)} |
| + } |
| + for name, c := range map[string]struct { |
| + rt registry.Route |
| + want string |
| + }{ |
| + "resident rootfs": {nested("shop.example.com", registry.RuntimeRootfsV1, false), ""}, |
| + "hibernating rootfs": {nested("shop.example.com", registry.RuntimeRootfsV1, true), ""}, |
| + "unknown runtime": {nested("later.example.com", "rootfs-v9", false), ""}, |
| + "binary hibernating, nested": {nested("a.example.com", "", true), release.LayoutModeNested}, |
| + } { |
| + rows := func() ([]registry.Route, error) { return []registry.Route{c.rt}, nil } |
| + if mode, err := mintLayoutIntentWith(ctx, s, rows); err != nil || mode != c.want { |
| + t.Errorf("mint, gate not ready, only %s as evidence = %q, %v; want %q", name, mode, err, c.want) |
| + } |
| + } |
| +} |
diff --git a/internal/layout/pass.go b/internal/layout/pass.go| index af2b311d7..762c183fc 100644 |
| --- a/internal/layout/pass.go |
| +++ b/internal/layout/pass.go |
| @@ -1070,6 +1070,25 @@ func (p *Pass) recover(ctx context.Context, intent Mode, gate func() error) []Re |
| return out |
| } |
| +// dropRootfsJournal is recovery's answer for a journal naming a row with a |
| +// runtime (keptRootfs): the pass never writes one, so it is planted or left |
| +// by another life, and honouring it would stop a rootfs host and move its |
| +// files. It is refused loudly and removed without moving anything, so the |
| +// journal does not keep the host fenced for good. |
| +func (p *Pass) dropRootfsJournal(host string, rt registry.Route) (Result, bool) { |
| + kept, ok := keptRootfs(rt) |
| + if !ok { |
| + return Result{}, false |
| + } |
| + var err error |
| + p.serialize(func() { err = RemoveJournal(p.DataDir, host) }) |
| + if err != nil { |
| + return Result{host, "refused", fmt.Sprintf("a layout journal names it, but %s, and the journal could not be removed: %v; not acting", kept.Reason, err)}, true |
| + } |
| + reason := fmt.Sprintf("a layout journal named it, but %s: the journal is removed and nothing moved", kept.Reason) |
| + return Result{host, "refused", reason}, true |
| +} |
| + |
| // nestedGate asks NestedOK at most once, on first use, and remembers the |
| // answer for the rest of one pass. |
| func (p *Pass) nestedGate() func() error { |
| @@ -1133,6 +1152,12 @@ func (p *Pass) recoverHost(ctx context.Context, host string, byHost map[string]r |
| if !ok { |
| return Result{host, "refused", "journal names a host with no row; not acting"} |
| } |
| + // A row with a runtime is never the pass's to move, so no journal can |
| + // be one it wrote: checked before the stop, so a planted journal never |
| + // costs a rootfs host a stop, and again on the row under the fence. |
| + if r, kept := p.dropRootfsJournal(host, rt); kept { |
| + return r |
| + } |
| // Checked before the stop as well as after it, so a journal that |
| // cannot be honoured never costs its host a stop. |
| if _, err := Validate(j, p.DataDir, p.socketDir(), rt); err != nil { |
| @@ -1176,6 +1201,9 @@ func (p *Pass) recoverHost(ctx context.Context, host string, byHost map[string]r |
| if fresh == nil { |
| return Result{host, "refused", "row vanished under the fence; not acting"} |
| } |
| + if r, kept := p.dropRootfsJournal(host, *fresh); kept { |
| + return r |
| + } |
| atFrom, err := Validate(j, p.DataDir, p.socketDir(), *fresh) |
| if err != nil { |
| return Result{host, "refused", notActing(err)} |
diff --git a/internal/layout/rootfs_pass_test.go b/internal/layout/rootfs_pass_test.go| index b8844462e..f06b29cf2 100644 |
| --- a/internal/layout/rootfs_pass_test.go |
| +++ b/internal/layout/rootfs_pass_test.go |
| @@ -7,6 +7,7 @@ import ( |
| "errors" |
| "os" |
| "path/filepath" |
| + "strings" |
| "testing" |
| "time" |
| @@ -118,3 +119,109 @@ func TestRestoreHoldNeverHoldsARootfsRow(t *testing.T) { |
| t.Error("recheck made the rootfs host's instance directory") |
| } |
| } |
| + |
| +// assertJournalDropped checks recovery's answer for a planted journal |
| +// naming a rootfs host: refused loudly, the journal removed, nothing |
| +// moved, and no fence left behind. |
| +func assertJournalDropped(t *testing.T, p *Pass, f *fakeFence, h string, at Endpoint, db string, r Result) { |
| + t.Helper() |
| + if r.Outcome != "refused" || !strings.Contains(r.Reason, "rootfs instances are always nested") || !strings.Contains(r.Reason, "nothing moved") { |
| + t.Errorf("%s: result %+v, want refused: the journal removed and nothing moved", h, r) |
| + } |
| + if JournalPresent(p.DataDir, h) { |
| + t.Errorf("%s: the planted journal is still there, fencing the host", h) |
| + } |
| + if got := rowAt(t, p, h); got != at { |
| + t.Errorf("%s row moved: %+v, want %+v", h, got, at) |
| + } |
| + if b, err := os.ReadFile(db); err != nil || string(b) != "db "+h { |
| + t.Errorf("%s db: %q %v", h, b, err) |
| + } |
| + if f.fences[h] != 0 { |
| + t.Errorf("%s left fenced", h) |
| + } |
| +} |
| + |
| +// nestedHostWithRuntime moves box's binary host to nested for real, so a |
| +// flat-mode journal forged for it is one recovery would honour, then gives |
| +// its row runtime, at the same paths. It returns the row's endpoint and |
| +// where the database file sits (the raw instance directory). |
| +func nestedHostWithRuntime(t *testing.T, p *Pass, runtime string) (Endpoint, string) { |
| + t.Helper() |
| + if r := byHost(t, p.Converge(context.Background(), ModeNested))[host]; r.Outcome != "migrated" { |
| + t.Fatalf("setup: %+v", r) |
| + } |
| + at := rowAt(t, p, host) |
| + if runtime != "" { |
| + if err := p.Registry.Delete(host); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := p.Registry.Upsert(registry.Route{Host: host, Kind: "instance", Status: "ready", Runtime: runtime, |
| + Socket: at.Socket, DBPath: at.DB}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + return at, filepath.Join(rawInstanceDir(p.DataDir, host), filepath.Base(at.DB)) |
| +} |
| + |
| +// TestRecoveryRefusesAJournalNamingARootfsRow (task 5 fix round 1, Astra |
| +// 3): a valid flat-mode journal planted for a nested rootfs host (anyone |
| +// with the agent's uid can write one) must not stop it, move its database |
| +// or rewrite its row flat, through Recover or through Converge's own |
| +// recovery, for rootfs-v1 and an unknown runtime alike. The journal is |
| +// refused and removed, so it does not fence the host for good. |
| +func TestRecoveryRefusesAJournalNamingARootfsRow(t *testing.T) { |
| + for _, runtime := range []string{registry.RuntimeRootfsV1, "rootfs-v9"} { |
| + for _, via := range []string{"Recover", "Converge flat", "Converge nested"} { |
| + t.Run(runtime+" "+via, func(t *testing.T) { |
| + p, f := box(t) |
| + at, db := nestedHostWithRuntime(t, p, runtime) |
| + forgeFlatJournal(t, p, host) |
| + f.events = nil |
| + var out map[string]Result |
| + switch via { |
| + case "Recover": |
| + out = byHost(t, p.Recover(context.Background(), ModeNested)) |
| + case "Converge flat": |
| + out = byHost(t, p.Converge(context.Background(), ModeFlat)) |
| + default: |
| + out = byHost(t, p.Converge(context.Background(), ModeNested)) |
| + } |
| + assertJournalDropped(t, p, f, host, at, db, out[host]) |
| + for _, e := range f.events { |
| + if e == "fence "+host { |
| + t.Errorf("the rootfs host was fenced and stopped: %v", f.events) |
| + } |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +// TestRecoveryRechecksTheRuntimeUnderTheFence: a row that has a runtime by |
| +// the time the pass holds its fence (a new life minted while the journal |
| +// waited) is refused the same way on the refreshed row, and the fence is |
| +// lifted. |
| +func TestRecoveryRechecksTheRuntimeUnderTheFence(t *testing.T) { |
| + p, f := box(t) |
| + at, db := nestedHostWithRuntime(t, p, "") |
| + forgeFlatJournal(t, p, host) |
| + f.events = nil |
| + f.onFence = func(h string) { |
| + if h != host { |
| + return |
| + } |
| + if err := p.Registry.Delete(h); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := p.Registry.Upsert(registry.Route{Host: h, Kind: "instance", Status: "ready", Runtime: registry.RuntimeRootfsV1, |
| + Socket: at.Socket, DBPath: at.DB}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + r := byHost(t, p.Recover(context.Background(), ModeNested))[host] |
| + assertJournalDropped(t, p, f, host, at, db, r) |
| + if !strings.Contains(strings.Join(f.events, " "), "fence "+host) { |
| + t.Fatalf("the binary row was refused before the fence (%v): this test proves nothing about the recheck", f.events) |
| + } |
| +} |
diff --git a/internal/provision/provision.go b/internal/provision/provision.go| index 0cf2a88fa..c613899a1 100644 |
| --- a/internal/provision/provision.go |
| +++ b/internal/provision/provision.go |
| @@ -730,7 +730,8 @@ func ValidateShape(rec Record) error { |
| } |
| // Same wedge as static+hibernate, arriving from the other side. Addr does |
| // NOT exclude a route from activator management: internal/edge's gate is |
| - // `Kind == "instance" && Hibernate && !viaTunnel`, so an addr-backed |
| + // `ActivatorOwned() && !viaTunnel` (an instance, hibernating or with a |
| + // runtime; validateRuntime refuses addr on a rootfs record), so an addr-backed |
| // instance flagged for hibernation is armed for an exec-child wake it has |
| // no socket for and whose process the platform never spawned. |
| // HibernateOrDefault's own derivation already states the invariant ("an |
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go| index ca1408e33..75b09918e 100644 |
| --- a/internal/provision/reconcile.go |
| +++ b/internal/provision/reconcile.go |
| @@ -478,7 +478,7 @@ func (cfg ReconcileConfig) inScope(region, pool string, everywhere bool) bool { |
| // one database cost. Deriving DBPath EXPLICITLY here — rather than leaving it |
| // empty on a route that has one — is also what keeps ops.FleetDBs' |
| // hibernating-exclusion correct: internal/ops/litestream.go builds that |
| -// exclusion set from `r.Hibernate && r.DBPath != ""`, so a hibernating route |
| +// exclusion set from `r.ActivatorLeased() && r.DBPath != ""`, so a hibernating route |
| // whose row carried no path would be swept up by the dataDir glob and |
| // replicated box-wide as if it never slept. |
| // |
diff --git a/internal/release/adopt.go b/internal/release/adopt.go| index 8849d2302..287bdcad1 100644 |
| --- a/internal/release/adopt.go |
| +++ b/internal/release/adopt.go |
| @@ -2155,6 +2155,8 @@ func adoptHost(ctx context.Context, work hostwrite.Work, reg *registry.Registry, |
| fmt.Printf(" %s: repointed %s -> %s (%s; sidecar, its worker moves onto it on the agent's drift check)\n", rt.Host, cur, ver, channel) |
| return |
| } |
| + // Left on Hibernate: a resident is not asleep, so it gets the |
| + // "updated" line below; the scheduler moves it. |
| if rt.Hibernate { |
| // Two different facts, one grep. With no restart callback this pass |
| // genuinely only moved a symlink, and the next wake is when the new |
diff --git a/internal/release/rootrestart_history.go b/internal/release/rootrestart_history.go| index 4f67230ed..22db76fa6 100644 |
| --- a/internal/release/rootrestart_history.go |
| +++ b/internal/release/rootrestart_history.go |
| @@ -250,6 +250,8 @@ func (h *RootRestarts) Observe(b RestartBinding, in RestartSnapshot) (*RestartIn |
| yes, known := q.Scope.Selects(registry.Route{Host: target.Host, Environment: target.Environment}) |
| selected = selected || (known && yes) |
| } |
| + // Left on Hibernate: a resident is not asleep, so it is a restart |
| + // target like any awake row. |
| if selected && !target.Hibernate { |
| p.Targets = append(p.Targets, RestartProgress{Target: target}) |
| } |
diff --git a/rootfs_layout_evidence_test.go b/rootfs_layout_evidence_test.go| new file mode 100644 |
| index 000000000..22bd22cf7 |
| --- /dev/null |
| +++ b/rootfs_layout_evidence_test.go |
| @@ -0,0 +1,36 @@ |
| +package main |
| + |
| +import ( |
| + "context" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// TestAddMintsNestedIgnoresRootfsEvidence (task 5 fix round 1): a rootfs |
| +// row is minted nested on every box, so with no intent recorded neither a |
| +// resident nor an unknown runtime at the nested paths makes `carlos add` |
| +// mint a binary row nested. A binary managed nested row still does. |
| +func TestAddMintsNestedIgnoresRootfsEvidence(t *testing.T) { |
| + ctx := context.Background() |
| + label := func() string { return "kass-1" } |
| + nested := func(host, runtime string, hib bool) registry.Route { |
| + return registry.Route{Host: host, Kind: "instance", Runtime: runtime, Hibernate: hib, |
| + Socket: provision.NestedSocket(host), DBPath: provision.NestedDBPath("/data", host)} |
| + } |
| + for name, c := range map[string]struct { |
| + rt registry.Route |
| + want bool |
| + }{ |
| + "resident rootfs": {nested("shop.example.com", registry.RuntimeRootfsV1, false), false}, |
| + "hibernating rootfs": {nested("shop.example.com", registry.RuntimeRootfsV1, true), false}, |
| + "unknown runtime": {nested("later.example.com", "rootfs-v9", false), false}, |
| + "binary hibernating, nested": {nested("a.example.com", "", true), true}, |
| + } { |
| + got, err := addMintsNested(ctx, nil, label, []registry.Route{c.rt}, "/data") |
| + if err != nil || got != c.want { |
| + t.Errorf("addMintsNested(only %s) = %v, %v; want %v", name, got, err, c.want) |
| + } |
| + } |
| +} |