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
55 lines
2.8 KiB
Go
55 lines
2.8 KiB
Go
package buildstep
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
)
|
|
|
|
// Passing is a fault of the network between a build node and what it reaches (a name lookup, a timeout, a reset
|
|
// connection, a forge's sshd refusing a burst, a store that does not answer), not of the source or the toolchain. A
|
|
// build module wraps it, and the shared runner then writes the step again and settles its ask with a delayed nak, up to
|
|
// AskRuns runs (ADR 0664 §1, §2). Any other error ends the step failed at once.
|
|
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).
|
|
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
|
|
}
|
|
|
|
// 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
|
|
// reset connection, ssh's key exchange cut by a forge's per-source penalty) and npm's error codes. "no responders" alone is not
|
|
// one: a publish's is the build module's to say (steprun.PublishFault, design 47 H2 §799).
|
|
var passingWords = []string{"i/o timeout", "no such host", "temporary failure in name resolution", "connection refused",
|
|
"connection reset", "tls handshake timeout", "network is unreachable", "no route to host", "lookup ", "kex_exchange_identification", "connection closed by",
|
|
"could not resolve host", "client.timeout", "operation timed out", "connection timed out", "eai_again", "etimedout", "econnreset", "econnrefused", "enotfound"}
|
|
|
|
// PassingCause says words (a tool's output or a step's reason) are those of a transport fault.
|
|
func PassingCause(words string) bool {
|
|
words = strings.ToLower(words)
|
|
for _, w := range passingWords {
|
|
if strings.Contains(words, w) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// TransportFaultWords open the reason of a step that ended failed after its runs met a transport fault (the asker says them,
|
|
// "a transport fault on 3 runs (nodes): cause"): a reader tells that end from a fault of the source by them (ADR 0664 §3).
|
|
const TransportFaultWords = "a transport fault on "
|