H2 H-A-504: every have read gives the run, pipeline and want revision
Review round 1: sessionHaves.Read gave no run, pipeline or want revision, so on the live engine every have written over an apply (held, failed, waiting, not composed) dropped the want revision, and the next want counted as nothing applied. Read now maps the have value the same way as ReadAt, through one function. Builds: design 47 H2 §813 (1); H-A-504 fourth addendum
This commit is contained in:
@@ -90,8 +90,15 @@ func (h sessionHaves) Read(ctx context.Context, module string) (agent.Have, bool
|
||||
if !ok {
|
||||
return agent.Have{}, false
|
||||
}
|
||||
return haveOf(module, got), true
|
||||
}
|
||||
|
||||
// haveOf is a module's have value as the agent reads it: every read gives the run, the pipeline and the want revision it
|
||||
// was applied from, so a have written over it (held, failed, waiting) keeps them (H-A-504 fourth addendum).
|
||||
func haveOf(module string, got nodeengine.HaveByNodeModuleValue) agent.Have {
|
||||
return agent.Have{Module: module, FP: got.Fp, Composed: got.Composed, Phase: string(got.Phase), Detail: got.Detail,
|
||||
Sealed: got.SealedAt, Wait: got.Wait}, true
|
||||
Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run, Pipeline: got.Pipeline,
|
||||
WantRevision: uint64(max(got.WantRevision, 0))}
|
||||
}
|
||||
|
||||
// ReadErr is Read telling a have absent from one the bus could not read (agent.HavesReadErr).
|
||||
@@ -114,9 +121,7 @@ func (h sessionHaves) ReadAt(ctx context.Context, module string) (agent.Have, ui
|
||||
if !ok || err != nil {
|
||||
return agent.Have{}, revision, false, err
|
||||
}
|
||||
return agent.Have{Module: module, FP: got.Fp, Composed: got.Composed, Phase: string(got.Phase), Detail: got.Detail,
|
||||
Sealed: got.SealedAt, Wait: got.Wait, Run: got.Run, Pipeline: got.Pipeline,
|
||||
WantRevision: uint64(max(got.WantRevision, 0))}, revision, true, nil
|
||||
return haveOf(module, got), revision, true, nil
|
||||
}
|
||||
|
||||
// WriteAt writes a module's have only while its key is at the revision read (agent.HavesAt, H-A-480).
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
"github.com/novox/mesh-host/internal/agent"
|
||||
"github.com/novox/mesh-host/internal/buckets"
|
||||
"github.com/novox/mesh-host/internal/link"
|
||||
"github.com/novox/mesh-host/internal/nodegrant"
|
||||
@@ -134,6 +135,17 @@ func TestNatsTheRecoveryStepAsksHearsBoundsAndCatchesUpOverTheBus(t *testing.T)
|
||||
|
||||
say("old", meshrecovery.RestoredEventOutcomeFailed) // said before anyone listens: the last message of the subject
|
||||
session := b.startSession()
|
||||
// H-A-504 fourth addendum: a have written through the agent's haves and read back gives the run, the pipeline and the
|
||||
// want revision it was applied from, by every read, so a have written over it keeps them.
|
||||
hv := sessionHaves{session: session}
|
||||
hv.Write(ctx, agent.Have{Module: "web", FP: "src2:" + strings.Repeat("a", 64), Composed: "sha256:" + strings.Repeat("b", 64),
|
||||
Phase: "running", Run: "12", Pipeline: "main.12", WantRevision: 301924})
|
||||
within(t, 5*time.Second, "the have read back through the agent's haves lacks its run, pipeline or want revision", func() bool {
|
||||
got, ok := hv.Read(ctx, "web")
|
||||
at, _, okAt, err := hv.ReadAt(ctx, "web")
|
||||
return ok && okAt && err == nil && got.Run == "12" && got.Pipeline == "main.12" && got.WantRevision == 301924 &&
|
||||
at.Run == got.Run && at.Pipeline == got.Pipeline && at.WantRevision == got.WantRevision
|
||||
})
|
||||
r := recoveryEnv(session, nil)
|
||||
// Design 47 H2 §775, H-A-364: over the same session, an ask of the seat is taken once in the state taken: the first time,
|
||||
// and never again within its bound.
|
||||
|
||||
Reference in New Issue
Block a user