Read the backup holders of every machine, and the notes fixture's data at a resource (issues 1065, 1066)
mesh/merge-gate waits for its group's composed check
mesh/repo-check head 08e000bb56aa merged into trunk 7c9c187ca6e2 beside mesh-catalog#353@c898a937 — fail: its merge-check.sh failed: --- FAIL: TestADeliver…
mesh/delivery-group group feat/backup-before-send rejected: a member's own check failed
mesh/delivery superseded: a newer head of the same pull request

This commit is contained in:
2026-10-17 23:04:52 +02:00
parent a39d6ce78d
commit 08e000bb56
3 changed files with 44 additions and 7 deletions
@@ -98,7 +98,8 @@ func TestADeliveryThatMovesABackedUpModuleWaitsForItsBackupAndAFailedOneHoldsItA
register(t, open, catalogue.Manifest{Module: "keeper", Version: "1",
Claims: []catalogue.Claim{{Name: catalogue.BackupSeat, Scope: catalogue.ScopeNode, Serves: []string{"backed-up", "now", "restore"}}}})
notes, err := catalogue.ParseManifest([]byte(`{"module":"notes","version":"1","data":{"own":[` +
`{"id":"files","path":"/srv/notes","class":"valuable","why":"people's notes"}]}}`))
`{"id":"files","path":"${dir:files}","class":"valuable","why":"people's notes"}]},` +
`"resources":[{"id":"files","type":"directory"}]}`))
if err != nil {
t.Fatal(err)
}
+27 -6
View File
@@ -115,17 +115,38 @@ func backupFactsFrom(entries []inventory.Entry, held []catalogue.Held) backupFac
return f
}
// loadBackupFacts reads the facts from the inventory.
// loadBackupFacts reads the facts from the inventory. The holders are read as `seats` reads them, from the world
// every machine's composition makes (theRestOfTheMesh): the seat_holding table keeps one holder of a node seat, and
// node-backup is held on every machine.
func loadBackupFacts(ctx context.Context, inv *inventory.Inventory) (backupFacts, error) {
entries, err := inv.Catalogued(ctx)
return loadBackupFactsFrom(inv.Catalogued, func() ([]catalogue.Held, error) {
shelf, err := inv.Catalogue(ctx)
if err != nil {
return nil, err
}
world, err := theRestOfTheMesh(ctx, inv, shelf, "")
if err != nil {
return nil, err
}
return world.Held, nil
}, ctx)
}
// loadBackupFactsFrom is loadBackupFacts given where the entries and the holdings come from. A source that fails
// fails the step, to be tried again: a failure never reads as a machine with no holder, which would send without a
// backup.
func loadBackupFactsFrom(entries func(context.Context) ([]inventory.Entry, error),
held func() ([]catalogue.Held, error), ctx context.Context) (backupFacts, error) {
es, err := entries(ctx)
if err != nil {
return backupFacts{}, err
return backupFacts{}, fmt.Errorf("the backups of the plan could not be worked out: %w", err)
}
held, err := inv.Holdings(ctx)
h, err := held()
if err != nil {
return backupFacts{}, err
return backupFacts{}, fmt.Errorf("the backups of the plan could not be worked out: who holds %s: %w",
catalogue.BackupSeat, err)
}
return backupFactsFrom(entries, held), nil
return backupFactsFrom(es, h), nil
}
// stepBackups takes one step of a plan's backups and says whether the plan may go on to ask its first tier. It
+15
View File
@@ -222,3 +222,18 @@ func TestAPlanThatMovesNoBackedUpItemAsksNothing(t *testing.T) {
t.Fatalf("proceed=%v err=%v record=%+v asked=%v", proceed, err, p.Backups, seat.asked)
}
}
// The holders of a node seat are every machine's, and a source that fails is no machine without a holder.
func TestTheBackupHoldersAreEveryMachinesAndAFailedReadIsNotNoHolder(t *testing.T) {
entries := func(context.Context) ([]inventory.Entry, error) {
return []inventory.Entry{aModuleWith(t, "mail", []string{"ace", "g14"}, anItem("a", ""))}, nil
}
f, err := loadBackupFactsFrom(entries, func() ([]catalogue.Held, error) { return holders("ace", "g14"), nil }, t.Context())
if err != nil || !f.holder["ace"] || !f.holder["g14"] {
t.Fatalf("%+v %v", f, err)
}
if _, err := loadBackupFactsFrom(entries, func() ([]catalogue.Held, error) { return nil, fmt.Errorf("store down") },
t.Context()); err == nil || !strings.Contains(err.Error(), "store down") {
t.Fatalf("a failed read of the holders must fail the step: %v", err)
}
}