mesh-delivery-sdk: a stopping tool runner's fault is passing, in one place (H-A-542)
A build step's publish met by a tool runner that restarted ended failed (main.440): PublishFault counted only "no responders" and "bundle exited". sdkstep.IsPassing now counts a call a stopping tool runner did not take, by its typed fault stopping (the error's ErrorKind, as mesh-sdk's stdio hands it), so every step's fault reading and PublishFault's "publish: " why read it the same; a bare "timeout" stays a failure. Builds: design 47 H2 H-A-542
This commit is contained in:
@@ -554,6 +554,12 @@ 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")
|
||||
}
|
||||
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")
|
||||
}
|
||||
@@ -703,3 +709,9 @@ func TestAskSubjectBy(t *testing.T) {
|
||||
t.Error("a subject of four tokens after accept parses")
|
||||
}
|
||||
}
|
||||
|
||||
// kindedFault is an error with a typed fault, as mesh-sdk's stdio hands a runtime's answer naming one.
|
||||
type kindedFault string
|
||||
|
||||
func (k kindedFault) Error() string { return "the call was not taken: " + string(k) }
|
||||
func (k kindedFault) ErrorKind() string { return string(k) }
|
||||
|
||||
@@ -14,10 +14,21 @@ 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.
|
||||
// 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).
|
||||
func IsPassing(err error) bool {
|
||||
var p *Passing
|
||||
return errors.As(err, &p)
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
@@ -3,6 +3,7 @@ package steprun
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -10,11 +11,20 @@ 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: <words>` or `publish: <words>`. 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.
|
||||
// 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.
|
||||
func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) {
|
||||
delay, err := AgainDelays("")
|
||||
if err != nil || delay(1) != 15*time.Second || delay(2) != time.Minute || delay(3) != time.Minute {
|
||||
@@ -37,6 +47,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 bare timeout", "", PublishFault(errors.New("timeout"))},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if tc.why == "" {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -81,15 +82,18 @@ 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 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: <words>`. Any other error is returned as it is.
|
||||
// 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
|
||||
// "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: <words>`. Any other error, a bare "timeout" among them, is returned as
|
||||
// it is.
|
||||
func PublishFault(err error) error {
|
||||
if err == nil || sdkstep.IsPassing(err) {
|
||||
var passing *sdkstep.Passing
|
||||
if err == nil || errors.As(err, &passing) {
|
||||
return err
|
||||
}
|
||||
words := strings.ToLower(err.Error())
|
||||
if !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") {
|
||||
if !sdkstep.IsPassing(err) && !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") {
|
||||
return err
|
||||
}
|
||||
return &sdkstep.Passing{Err: fmt.Errorf("publish: %w", err)}
|
||||
|
||||
Reference in New Issue
Block a user