H-A-178: key restore-point-missing by module and node; test the placements read
Findings are keyed by scope, id and kind across the mesh, so the module
alone as the id let two machines clear each other's restore-point-missing:
its id is now <module>.<node>, as a held module's is. Before the watch of
the assignments has caught up the point is asked as before and a missing
answer holds the move (H-A-178, built in d217056c); the composer's Watch
test now shows RecoveryPlaced answers read only once the assignments are
caught up.
Builds: design 47 H §456, H-A-177, H-A-178
This commit is contained in:
@@ -10,18 +10,24 @@ import (
|
||||
|
||||
// RestorePointMissingKind is the finding the node-engine writes when it moves a module across a form change without its restore
|
||||
// point, because the assigner's placements name no holder of the seat mesh-recovery anywhere on the mesh (design 47 H, H-A-177,
|
||||
// H §456): a warning, scope the machine, its id the module. It clears at the module's next take-in with a point.
|
||||
// H §456): a warning, scope the machine, its id `<module>.<node>` (H-A-178), as a held module's is. It clears at the module's
|
||||
// next take-in with a point.
|
||||
const RestorePointMissingKind = "restore-point-missing"
|
||||
|
||||
// RestorePointMissingID is the finding's id for a module on a node: findings are keyed by scope, id and kind across the mesh, so
|
||||
// two machines never clear each other's (H-A-178).
|
||||
func RestorePointMissingID(module, node string) string { return module + "." + node }
|
||||
|
||||
// SayRestorePointMissing writes the finding for module when missing, with the words naming what moved without a point, and clears
|
||||
// it when no longer: a take-in of the module took its point. A write or a clear that fails is returned for the caller to say.
|
||||
func SayRestorePointMissing(ctx context.Context, w Writer, node, observer, module, words string, missing bool, now func() time.Time) error {
|
||||
id := RestorePointMissingID(module, node)
|
||||
if !missing {
|
||||
return w.Clear(ctx, scopeMachine, module, RestorePointMissingKind, "a take-in of the module took its restore point")
|
||||
return w.Clear(ctx, scopeMachine, id, RestorePointMissingKind, "a take-in of the module took its restore point")
|
||||
}
|
||||
return w.Write(ctx, condseat.Finding{Observer: observer, Kind: RestorePointMissingKind, Scope: scopeMachine, ID: module,
|
||||
return w.Write(ctx, condseat.Finding{Observer: observer, Kind: RestorePointMissingKind, Scope: scopeMachine, ID: id,
|
||||
Severity: condseat.FindingSeverityWarning, Source: RestorePointMissingKind,
|
||||
Subject: condseat.Subject{Scope: scopeMachine, ID: module, Machine: node},
|
||||
Subject: condseat.Subject{Scope: scopeMachine, ID: id, Machine: node},
|
||||
Summary: fmt.Sprintf("%s moved on %s without its restore point: %s", module, node, words),
|
||||
Headline: fmt.Sprintf("%s moved without a restore point on %s", module, node),
|
||||
Explanation: "No holder of the seat mesh-recovery is placed on the mesh, so the node-engine moved the module across a change of its kept data's form without taking a restore point first: that move cannot be reverted to the data as it was. The finding clears at the module's next take-in that takes its point.",
|
||||
|
||||
@@ -242,17 +242,17 @@ func caseAnEntryNotFoundIsAFindingOfTheFingerprint(t *testing.T) {
|
||||
t.Fatalf("cleared %+v, %v", u.cleared, err)
|
||||
}
|
||||
// And design 47 H, H-A-177: a module moved without its restore point is the finding restore-point-missing, a warning of scope
|
||||
// machine with the module as its id, on the node's machine, cleared by the same.
|
||||
// machine with `<module>.<node>` as its id (H-A-178), on the node's machine, cleared by the same.
|
||||
r := &fakeFindings{}
|
||||
if err := SayRestorePointMissing(context.Background(), r, "n1", "mesh-host", "db", "cache (form 1)", true, now); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(r.put) != 1 || RestorePointMissingKind != "restore-point-missing" || r.put[0].Kind != RestorePointMissingKind || r.put[0].Scope != "machine" ||
|
||||
r.put[0].ID != "db" || r.put[0].Severity != condseat.FindingSeverityWarning || r.put[0].Subject.Machine != "n1" || !strings.Contains(r.put[0].Summary, "cache (form 1)") {
|
||||
r.put[0].ID != "db.n1" || r.put[0].Severity != condseat.FindingSeverityWarning || r.put[0].Subject.Machine != "n1" || !strings.Contains(r.put[0].Summary, "cache (form 1)") {
|
||||
t.Fatalf("written %+v", r.put)
|
||||
}
|
||||
if err := SayRestorePointMissing(context.Background(), r, "n1", "mesh-host", "db", "", false, now); err != nil || len(r.cleared) != 1 ||
|
||||
r.cleared[0].Kind != RestorePointMissingKind || r.cleared[0].ID != "db" {
|
||||
r.cleared[0].Kind != RestorePointMissingKind || r.cleared[0].ID != "db.n1" {
|
||||
t.Fatalf("cleared %+v, %v", r.cleared, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +286,10 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
c.holdEntry(t, "oldie", oldieFp, oldie)
|
||||
b.put(t, buckets.Wants, "want.n1.lemurs", want)
|
||||
b.put(t, buckets.Wants, "want.n1.node", nodeWant)
|
||||
// Design 47 H, H-A-177, H-A-178: before the watch of the assignments has caught up, the placements are not read.
|
||||
if _, read := c.RecoveryPlaced(); read {
|
||||
t.Error("the placements are read before the watch of the assignments caught up")
|
||||
}
|
||||
for _, bucket := range []string{buckets.Wants, buckets.Assignments, buckets.Have, ResolvedBucket} {
|
||||
b.send(bucket, agent.Update{Caught: true})
|
||||
}
|
||||
@@ -294,6 +298,9 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
for {
|
||||
u := next(t, out)
|
||||
if u.Caught {
|
||||
if placed, read := c.RecoveryPlaced(); !read || placed {
|
||||
t.Errorf("once the assignments are caught up RecoveryPlaced answers placed %v read %v, want read with no holder", placed, read)
|
||||
}
|
||||
break
|
||||
}
|
||||
c, err := compositions.Decode(u.Value)
|
||||
|
||||
Reference in New Issue
Block a user