node-tools: a stopping tool runner takes its subscriptions down, so callers meet no responders (issue 721)
The runner answered each call it did not take once its stop began with the typed fault stopping (#90). Callers built before mesh-sdk read it as the callee's refusal and ended their kept call, and no edge delivered the new answer after its readers. Now, once told to stop, the runner first drains every subscription it answers calls on (a tool's, a seat verb's and a seat proof's) and subscribes none again, then finishes the calls in flight within drain-bound. A call made after the stop meets no responders at once, a transport fault every caller of every mesh-sdk already waits out, until the new runner subscribes. A call that still reached it is answered nothing, as H-A-369 has it. The typed answer goes whole: the reply's error-kind, KindedError, ErrorKindStopping and the bundle's error data. Tests: 721/AC4 in the bus (a call and a proof after the stop meet no responders within a second, the call in flight is answered, a subject served after the stop is refused) and in launch (a call that still reaches the runner gets no answer and no typed fault); the whole test meets no responders while a call is still in flight, before the drain bound. Builds: design 47 H2 H-A-570 (1), (3) (mesh-tools' part), amending §813 (12) as H-A-369 has it
This commit is contained in:
@@ -166,6 +166,9 @@ func serve(ctx context.Context) error {
|
||||
// First of all: the service manager signalled every bundle with this process, and none is started again
|
||||
// (issue 1126).
|
||||
launch.ShutDown()
|
||||
// Then it unsubscribes from every subject it answers calls on, so a call made from now on meets no responders wherever no
|
||||
// other tool runner serves it, until the new runner subscribes (design 47 H2 H-A-570 (1)).
|
||||
conn.StopAnswering()
|
||||
// Then it drains (design 47 H2 §813 (12), H-A-353): no new call is taken, the calls in flight finish within the drain bound
|
||||
// or are cut and said, and only then are the bundles stopped, by the runner itself.
|
||||
launch.Drain(drainBound, log.Printf)
|
||||
|
||||
@@ -238,8 +238,8 @@ func TestTheToolRunnerStartedByItsEntryServesABundleOverTheSeatListItReads(t *te
|
||||
}
|
||||
|
||||
// at its stop the runner drains (design 47 H2 §813 (12), H-A-353; the bound 2 s here for the setting's 30 s): a call of 1 s in
|
||||
// flight is answered, one of 6 s is cut at the bound, said, and its caller answered nothing; a call after the stop is answered
|
||||
// the typed fault stopping (H-A-542)
|
||||
// flight is answered, one of 6 s is cut at the bound, said, and its caller answered nothing; a call after the stop meets no
|
||||
// responders, since the runner took its subscriptions down first (H-A-570 (1))
|
||||
type answer struct {
|
||||
got string
|
||||
err error
|
||||
@@ -261,16 +261,24 @@ func TestTheToolRunnerStartedByItsEntryServesABundleOverTheSeatListItReads(t *te
|
||||
return nil
|
||||
})
|
||||
stop()
|
||||
// a call after the stop began is answered the typed fault stopping, never silence, so its caller asks again after a pause and
|
||||
// meets the new runner (H-A-369 as H-A-542 amends it): until the drain began it is still answered
|
||||
mt.Until(t, func() error {
|
||||
answered, err := asker.AskWithin("ledger.who", map[string]any{}, "", 500*time.Millisecond)
|
||||
var kinded interface{ ErrorKind() string }
|
||||
if !errors.As(err, &kinded) || kinded.ErrorKind() != "stopping" {
|
||||
return fmt.Errorf("a call after the stop was answered %s, %v; want the typed fault stopping", answered.Result, err)
|
||||
// a call after the stop began, of a tool and of a seat verb, meets no responders within a second, a transport fault its
|
||||
// caller's kept call waits out until the new runner subscribes, never an answer of the old runner's (H-A-570 (1)): until
|
||||
// the runner took its subscriptions down it is still answered. The runner takes them down before it drains, so its callers
|
||||
// meet no responders while the call of 6 s is still in flight, before the drain bound cuts it.
|
||||
for _, key := range []string{"ledger.who", "seat:node-desk.who@anchor"} {
|
||||
mt.Until(t, func() error {
|
||||
at := time.Now()
|
||||
answered, err := asker.AskWithin(key, map[string]any{}, "", 300*time.Millisecond)
|
||||
if took := time.Since(at); !errors.Is(err, bus.ErrNoResponders) || took > time.Second {
|
||||
return fmt.Errorf("a call of %s after the stop was answered %s, %v in %s; want no responders within a second", key,
|
||||
answered.Result, err, took)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if journal.has("cut ledger's call hold") {
|
||||
t.Errorf("a call of %s met no responders only once the drain had ended, want it from the stop on", key)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
if got := <-short; got.err != nil || !strings.Contains(got.got, `"held":1`) {
|
||||
t.Errorf("the call of 1 s in flight at the stop was answered %s, %v; want it finished", got.got, got.err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user