A7 bound-armed-once: a wait's bound and a settle's end arm the one timer only while still to come, the bound only while the module does not run
The bound is no deadline for a module that runs its wanted build or once it has run; a wait that ended arms nothing; past its bound a wait is judged again on an input alone. (The mesh-sdk request counter of 828's last row is not in the assigner's reach: asked.) Builds: design 47 H2b §828
This commit is contained in:
@@ -273,7 +273,7 @@ func (p *passer) outsideReview(ctx context.Context, module, fp string, nodes []s
|
||||
case d.Counted:
|
||||
override[node] = nodeengineclient.HealthOK
|
||||
}
|
||||
p.outsideApply(ctx, key, hex, node, module, fp, prev, d, now)
|
||||
p.outsideApply(ctx, key, hex, node, module, fp, prev, d, now, running)
|
||||
}
|
||||
o.mu.Lock()
|
||||
o.started = true
|
||||
@@ -320,7 +320,7 @@ func (p *passer) outsideAnswered(w *outside.Wait, node, module, fp string) bool
|
||||
}
|
||||
|
||||
// outsideApply keeps what a judging came to: the wait's record, its events, its finding and its ask.
|
||||
func (p *passer) outsideApply(ctx context.Context, key, hex, node, module, fp string, prev *outside.Wait, d outside.Decision, now time.Time) {
|
||||
func (p *passer) outsideApply(ctx context.Context, key, hex, node, module, fp string, prev *outside.Wait, d outside.Decision, now time.Time, running bool) {
|
||||
o := p.outside
|
||||
switch {
|
||||
case d.End != "":
|
||||
@@ -363,11 +363,16 @@ func (p *passer) outsideApply(ctx context.Context, key, hex, node, module, fp st
|
||||
}
|
||||
}
|
||||
o.mu.Unlock()
|
||||
if w.Settling {
|
||||
p.wakeSet("wait."+key, w.SettleEnds)
|
||||
} else if w.Standing() {
|
||||
p.wakeSet("wait."+key, w.ClockFrom.Add(o.bound))
|
||||
// The one deadline timer is armed at a settle's end or a wait's bound only while that time is still to come, and the bound
|
||||
// only while the module does not run its wanted build (design 47 H2b §828): past it nothing is armed, and the wait is judged
|
||||
// again only on an input.
|
||||
var at time.Time
|
||||
if w.Settling && now.Before(w.SettleEnds) {
|
||||
at = w.SettleEnds
|
||||
} else if w.Standing() && !running && now.Before(w.ClockFrom.Add(o.bound)) {
|
||||
at = w.ClockFrom.Add(o.bound)
|
||||
}
|
||||
p.wakeSet("wait."+key, at)
|
||||
p.keepWait(ctx, key, w)
|
||||
}
|
||||
}
|
||||
@@ -410,6 +415,7 @@ func (p *passer) outsideEnd(ctx context.Context, key string, w outside.Wait, how
|
||||
p.outside.causes[w.Cause] = removeString(p.outside.causes[w.Cause], w.Node)
|
||||
p.outside.mu.Unlock()
|
||||
}
|
||||
p.wakeSet("wait."+key, time.Time{}) // a wait that ended arms nothing
|
||||
p.remove(ctx, buckets.Waits(), key)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ type outsideRig struct {
|
||||
health string
|
||||
// notRunning: the node-engine seat's last running does not name the module at the fingerprint (it is not running its wanted build).
|
||||
notRunning bool
|
||||
// reads counts the conditions reads a judging started.
|
||||
reads int
|
||||
}
|
||||
|
||||
func newOutsideRig(t *testing.T) *outsideRig {
|
||||
@@ -47,6 +49,7 @@ func newOutsideRig(t *testing.T) *outsideRig {
|
||||
r.p.now = func() time.Time { return r.now }
|
||||
r.p.w.put(buckets.Asks(), "x", nil)
|
||||
r.p.outside = newOutsideActs(func(key string, body any) (json.RawMessage, error) {
|
||||
r.reads++
|
||||
if r.unread {
|
||||
return nil, context.DeadlineExceeded
|
||||
}
|
||||
@@ -220,6 +223,47 @@ func TestTheWaitOnAnOutsideCause(t *testing.T) {
|
||||
t.Fatalf("the ask is not raised at once when the module stops running past the bound: %+v", r.wait())
|
||||
}
|
||||
})
|
||||
t.Run("the bound is armed once, only while to come and the module does not run; past it a wait is judged again only on an input (§828)", func(t *testing.T) {
|
||||
armed := func(r *outsideRig) bool {
|
||||
r.p.wakes.mu.Lock()
|
||||
defer r.p.wakes.mu.Unlock()
|
||||
for k := range r.p.wakes.at {
|
||||
if strings.HasPrefix(k, "wait.") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
input := func(r *outsideRig) {
|
||||
r.p.outside.Heard("mesh.seat.mesh-conditions.event.condition-changed", []byte(`{"key":"machine.hub.silent","subject":{"id":"hub","scope":"machine","machine":"hub","also":["ace"]}}`))
|
||||
<-r.woke
|
||||
}
|
||||
for _, notRunning := range []bool{false, true} {
|
||||
r := newOutsideRig(t)
|
||||
r.notRunning = notRunning
|
||||
r.cond("machine.hub.silent", "ace")
|
||||
r.review(false, nil)
|
||||
if armed(r) != notRunning { // a running module's bound is no deadline; a module not running has its bound to come
|
||||
t.Fatalf("notRunning %v: the bound's timer armed = %v before the bound", notRunning, armed(r))
|
||||
}
|
||||
r.now = r.now.Add(31 * time.Minute)
|
||||
input(r)
|
||||
r.review(false, nil)
|
||||
if armed(r) {
|
||||
t.Fatalf("notRunning %v: a timer stands past the bound", notRunning)
|
||||
}
|
||||
reads := r.reads
|
||||
r.review(false, nil) // nothing changed: not judged again
|
||||
if r.reads != reads {
|
||||
t.Errorf("notRunning %v: a wait past its bound was judged again with no input (%d reads, then %d)", notRunning, reads, r.reads)
|
||||
}
|
||||
input(r) // a condition raised on M judges it again
|
||||
r.review(false, nil)
|
||||
if r.reads == reads {
|
||||
t.Errorf("notRunning %v: a condition event on the machine did not judge the wait again", notRunning)
|
||||
}
|
||||
}
|
||||
})
|
||||
t.Run("past the bound the operator is asked; Go on counts it healthy and Count as failed holds it, each said ended", func(t *testing.T) {
|
||||
for how, want := range map[string]string{assign.OptionGoOn: nodeengineclient.HealthOK, assign.OptionFailed: nodeengineclient.HealthFailed} {
|
||||
r := newOutsideRig(t)
|
||||
|
||||
Reference in New Issue
Block a user