diff --git a/modules/mesh-delivery-sdk/buildstep/ask_test.go b/modules/mesh-delivery-sdk/buildstep/ask_test.go index 1a47f3500..188118cc9 100644 --- a/modules/mesh-delivery-sdk/buildstep/ask_test.go +++ b/modules/mesh-delivery-sdk/buildstep/ask_test.go @@ -561,11 +561,9 @@ func TestPauseCapacityAndComposerKey(t *testing.T) { if !IsPassing(fmt.Errorf("fetch: %w", &Passing{Err: errors.New("s")})) || IsPassing(errors.New("i/o timeout")) { t.Error("a wrapped Passing is a Passing error and a bare error is none") } - // A call a stopping tool runner did not take is passing by its typed fault, wrapped or not; its words alone, and a bare - // "timeout", are not (design 47 H2 H-A-542). - if !IsPassing(kindedFault("stopping")) || !IsPassing(fmt.Errorf("publish: %w", kindedFault("stopping"))) || - IsPassing(kindedFault("away")) || IsPassing(errors.New("the tool runner is stopping")) || IsPassing(errors.New("timeout")) { - t.Error("a stopping tool runner's fault is passing by its kind alone") + // H-A-570 (3): no fault kind makes a passing fault; only a Passing does, by its type, and words and a bare "timeout" are none. + if IsPassing(kindedFault("stopping")) || IsPassing(kindedFault("away")) || IsPassing(errors.New("the tool runner is stopping")) || IsPassing(errors.New("timeout")) { + t.Error("only a Passing is passing") } if Ended(Step{State: StepRunning}) || Ended(Step{State: StepAgain}) || !Ended(Step{State: StepPassed}) || !Ended(Step{State: StepFailed}) { t.Error("Ended: running and again are no end") diff --git a/modules/mesh-delivery-sdk/buildstep/passing.go b/modules/mesh-delivery-sdk/buildstep/passing.go index 4aafd08b0..fc11a9369 100644 --- a/modules/mesh-delivery-sdk/buildstep/passing.go +++ b/modules/mesh-delivery-sdk/buildstep/passing.go @@ -14,21 +14,12 @@ type Passing struct{ Err error } func (p *Passing) Error() string { return p.Err.Error() } func (p *Passing) Unwrap() error { return p.Err } -// IsPassing says err is, or wraps, a Passing, or a call a stopping tool runner did not take (errorKindStopping): the one -// place every step's fault reading counts stopping as passing, by its kind and never by its words (design 47 H2 H-A-542). +// IsPassing says err is, or wraps, a Passing: the one place every step's fault reading counts a fault as passing, by its +// type and never by its words. A call that met no responders is the build module's to wrap, as steprun.PublishFault does +// (design 47 H2 H-A-570 (3), H-A-658). func IsPassing(err error) bool { var p *Passing - return errors.As(err, &p) || stopping(err) -} - -// errorKindStopping is the typed fault a stopping tool runner answers each call it does not take with, mesh-sdk stdio's -// ErrorKindStopping (design 47 H2 H-A-542); this package reaches no bus, so it reads the kind by the error's ErrorKind. -const errorKindStopping = "stopping" - -// stopping says err is, or wraps, an error whose typed fault is stopping (ErrorKind() string). -func stopping(err error) bool { - var kinded interface{ ErrorKind() string } - return errors.As(err, &kinded) && kinded.ErrorKind() == errorKindStopping + return errors.As(err, &p) } // passingWords are the words of a network that did not answer, lower-cased: go's and git's (a lookup, a timeout, a refused or diff --git a/modules/mesh-delivery-sdk/steprun/again_test.go b/modules/mesh-delivery-sdk/steprun/again_test.go index 9e051373a..79b15cbb0 100644 --- a/modules/mesh-delivery-sdk/steprun/again_test.go +++ b/modules/mesh-delivery-sdk/steprun/again_test.go @@ -11,20 +11,12 @@ import ( sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" ) -// stoppingFault is a call a stopping tool runner did not take, as mesh-sdk's stdio hands it: its typed fault stopping. -type stoppingFault struct{} - -func (stoppingFault) Error() string { - return "registry's publish was not taken: the tool runner is stopping" -} -func (stoppingFault) ErrorKind() string { return "stopping" } - // Design 47 H2 §799: a fetch met by a forge's 401 or a connection fault, and a publish met by no responders or a bundle // that exited, end their run `again` after again-delays' delay, with no seat call; a third run's fault ends the step failed // with the why `fetch: ` or `publish: `. ADR 0664 §1 with the bus's count above the runs that started: an ask // given back twice before its first run (the bus says delivered 3, the step key 1 run began) meets its fault in run 2, -// given again after again-delays' second, 60 s, not 3. A publish met by a stopping tool runner is one too (H-A-542); a -// bare timeout is not. +// given again after again-delays' second, 60 s, not 3. A publish met by a stopping tool runner is met by no responders (H-A-570 (3)), so it +// is one too; a bare timeout is not. func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { delay, err := AgainDelays("") if err != nil || delay(1) != 15*time.Second || delay(2) != time.Minute || delay(3) != time.Minute { @@ -47,7 +39,8 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { {"a publish met by a bundle that exited", "publish: ", PublishFault(errors.New("the bundle exited"))}, {"a fetch of a commit that is not there", "", gitFailure("fetch", "fatal: unknown revision or path not in the working tree")}, {"a publish refused", "", PublishFault(errors.New("refused: the digest differs"))}, - {"a publish met by a stopping tool runner", "publish: ", PublishFault(fmt.Errorf("asked again: %w", stoppingFault{}))}, + {"a publish met by a stopping tool runner, no responders wrapped", "publish: ", PublishFault(fmt.Errorf("asked again: %w", errors.New("nats: no responders available for request")))}, + {"a publish met by a fault kinded stopping, which no code reads", "", PublishFault(errors.New("registry's publish was not taken: the tool runner is stopping"))}, {"a publish met by a bare timeout", "", PublishFault(errors.New("timeout"))}, } { t.Run(tc.name, func(t *testing.T) { diff --git a/modules/mesh-delivery-sdk/steprun/publish.go b/modules/mesh-delivery-sdk/steprun/publish.go index cbe6af466..a5141188a 100644 --- a/modules/mesh-delivery-sdk/steprun/publish.go +++ b/modules/mesh-delivery-sdk/steprun/publish.go @@ -82,8 +82,8 @@ func PublishParts(ctx context.Context, call SeatCall, seat string, in reg.Publis return sent, PublishFault(err) } -// PublishFault is err, or, when a publish met no responders, a registry's bundle that exited or a stopping tool runner (its -// typed fault stopping, which sdkstep.IsPassing counts, design 47 H2 H-A-542), a sdkstep.Passing whose words open with +// PublishFault is err, or, when a publish met no responders (a stopping tool runner's calls meet none, design 47 H2 H-A-570 +// (3)) or a registry's bundle that exited, a sdkstep.Passing whose words open with // "publish: " (design 47 H2 §799, ADR 0664 §1): the run ends `again`, with no seat call to learn why, and a third run's // fault ends the step failed with the why `publish: `. Any other error, a bare "timeout" among them, is returned as // it is. @@ -93,7 +93,7 @@ func PublishFault(err error) error { return err } words := strings.ToLower(err.Error()) - if !sdkstep.IsPassing(err) && !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") { + if !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") { return err } return &sdkstep.Passing{Err: fmt.Errorf("publish: %w", err)}