P7 failed-finding-names: a module that leaves the registrations clears its pipeline-failed; the finding names the movers held behind the failed one and runner_unfinished_place
Builds: design 47 H2 H-A-605 (2), H-A-625 (2)
This commit is contained in:
@@ -105,7 +105,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
var resumer atomic.Pointer[func(string)]
|
||||
var advancer atomic.Pointer[func(string)]
|
||||
var placer atomic.Pointer[func(catalog.CatalogRevisionEvent) error]
|
||||
var registrar atomic.Pointer[func(catalog.Registration)]
|
||||
var registrar atomic.Pointer[func(catalog.Registration, bool)]
|
||||
var reviser atomic.Pointer[func(catalog.CatalogRevisionEvent) (int, error)]
|
||||
rv, err := startViews(ctx, js, conn, cred, hub, calls.State("findings"), calls.Call, func(branch string) {
|
||||
if f := resumer.Load(); f != nil {
|
||||
@@ -120,9 +120,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return (*f)(ev)
|
||||
}
|
||||
return fmt.Errorf("the candidate %s's revision %d is heard before the runner can place it", ev.Group, ev.Revision)
|
||||
}, func(reg catalog.Registration) {
|
||||
}, func(reg catalog.Registration, gone bool) {
|
||||
if f := registrar.Load(); f != nil {
|
||||
(*f)(reg)
|
||||
(*f)(reg, gone)
|
||||
}
|
||||
}, func(ev catalog.CatalogRevisionEvent) (int, error) {
|
||||
if f := reviser.Load(); f != nil {
|
||||
@@ -160,7 +160,14 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
hearer.Widens = widener.Reads
|
||||
hearer.LogLast = stepLog{ctx: ctx, js: js, module: cred.Module}.Last
|
||||
hearer.Where = routerRecordOf(cred.Module, calls.Call, calls.Ask)
|
||||
hearer.Failures = &pipeline.Failures{Findings: rv.Findings, Observer: cred.Module, Author: commitAuthor(calls.Call), Logf: logger.Printf}
|
||||
hearer.Failures = &pipeline.Failures{Findings: rv.Findings, Observer: cred.Module, Author: commitAuthor(calls.Call), Logf: logger.Printf,
|
||||
Behind: func(p seat.Pipeline, module string) []string {
|
||||
half, err := widener.Revision(p.Branch, p.Revision)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return pipeline.HeldBehind(p, module, half.Entries)
|
||||
}}
|
||||
// Every ask but a test run's is bounded until its holder's first word (H-A-235, H-A-238), its bounds keys of the state
|
||||
// bounds. A step's ask is put as a kept call within the same bound (design 47 H2 §775).
|
||||
askBound, err := askUnansweredBound(getenv)
|
||||
@@ -250,7 +257,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// A registration-changed places the steps of its module's pipelines started before it, from it (A-327), and binds the
|
||||
// takeins durable when its bind failed at the start (H-A-500 fifth addendum).
|
||||
var bindTakeInsAgain atomic.Pointer[func()]
|
||||
register := func(reg catalog.Registration) {
|
||||
register := func(reg catalog.Registration, gone bool) {
|
||||
if gone {
|
||||
hearer.Failures.ModuleGone(reg.Module)
|
||||
return
|
||||
}
|
||||
if f := bindTakeInsAgain.Load(); f != nil {
|
||||
(*f)()
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (h *holderView) Nodes(seats []string) ([]string, bool) {
|
||||
// after, then start hub once.
|
||||
func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cred process.Account, hub *process.EventHub, findingsState process.State,
|
||||
call meshcatalogclient.Call, onReady, onAdvance func(branch string), candidate func(ctx context.Context, ev catalog.CatalogRevisionEvent) error,
|
||||
registered func(reg catalog.Registration), revised func(ev catalog.CatalogRevisionEvent) (int, error), logf func(string, ...any)) (*runnerViews, error) {
|
||||
registered func(reg catalog.Registration, gone bool), revised func(ev catalog.CatalogRevisionEvent) (int, error), logf func(string, ...any)) (*runnerViews, error) {
|
||||
findings, err := findingWriter(ctx, cred, conn, js, findingsState, logf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -158,9 +158,10 @@ func startViews(ctx context.Context, js jetstream.JetStream, conn *nats.Conn, cr
|
||||
regs, _, err := meshcatalogclient.WireRegistrationsProcess(reader, call, func(reg catalog.Registration, gone bool) {
|
||||
if !gone {
|
||||
cv.Registered(reg)
|
||||
// A pipeline of the module started before this registration gets its steps from it (A-327).
|
||||
registered(reg)
|
||||
}
|
||||
// A pipeline of the module started before this registration gets its steps from it (A-327); a module the view no
|
||||
// longer names has its finding pipeline-failed cleared (design 47 H2 H-A-605 (2)).
|
||||
registered(reg, gone)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -150,3 +150,23 @@ func moduleNames(movers []seat.Mover) []string {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// HeldBehind are the movers of p, sorted, that the failed mover module holds back: those whose own steps held and that await
|
||||
// it, directly or through others, or sit in the tier group of one that does (H-A-625 (2)).
|
||||
func HeldBehind(p seat.Pipeline, module string, entries map[string]catalog.CatalogEntry) []string {
|
||||
failed := failedMovers(p)
|
||||
var left []string
|
||||
for _, m := range p.Movers {
|
||||
if !slices.Contains(failed, m.Module) && ownStepsHeld(p, m.Module) {
|
||||
left = append(left, m.Module)
|
||||
}
|
||||
}
|
||||
var out []string
|
||||
for m, by := range tiedTo(p, left, failed, entries) {
|
||||
if slices.Contains(by, module) {
|
||||
out = append(out, m)
|
||||
}
|
||||
}
|
||||
slices.Sort(out)
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ type Failures struct {
|
||||
Author func(repository, commit string) (string, error)
|
||||
Now func() time.Time
|
||||
Logf func(string, ...any)
|
||||
// Behind names the movers of p that a failed mover holds back, for the finding's words (H-A-625 (2)); nil names none.
|
||||
Behind func(p seat.Pipeline, module string) []string
|
||||
}
|
||||
|
||||
func (f *Failures) logf(format string, args ...any) {
|
||||
@@ -126,6 +128,11 @@ func (f *Failures) write(ctx context.Context, p seat.Pipeline, m seat.Mover) {
|
||||
if why != "" {
|
||||
explanation += " " + why
|
||||
}
|
||||
if f.Behind != nil {
|
||||
if held := f.Behind(p, m.Module); len(held) > 0 {
|
||||
explanation += fmt.Sprintf(" The movers %s are held behind it, in the state unfinished; runner_unfinished_place places them.", strings.Join(held, ", "))
|
||||
}
|
||||
}
|
||||
id := findingID(m.Module, p.Branch)
|
||||
err := f.Findings.Write(ctx, condseat.Finding{Scope: mcc.ScopeDelivery, ID: id, Kind: PipelineFailedKind, Severity: condseat.FindingSeverityWarning,
|
||||
Summary: fmt.Sprintf("%s on %s in %s: %s", m.Module, p.Branch, p.Pipeline, strings.Join(names, ", ")),
|
||||
@@ -154,3 +161,20 @@ func (f *Failures) author(m seat.Mover) (string, string) {
|
||||
}
|
||||
return "forge:" + account, ""
|
||||
}
|
||||
|
||||
// ModuleGone clears every finding pipeline-failed of module, on any branch, when the registrations view no longer names the
|
||||
// module, as the indexer frees its failed record (design 47 H2 H-A-605 (2)).
|
||||
func (f *Failures) ModuleGone(module string) {
|
||||
if f == nil || f.Findings == nil {
|
||||
return
|
||||
}
|
||||
prefix := findingID(module, "")
|
||||
for _, h := range f.Findings.Held() {
|
||||
if h.Scope != mcc.ScopeDelivery || h.Kind != PipelineFailedKind || !strings.HasPrefix(h.ID, prefix) {
|
||||
continue
|
||||
}
|
||||
if err := f.Findings.Clear(context.Background(), mcc.ScopeDelivery, h.ID, PipelineFailedKind, module+" is no longer registered"); err != nil {
|
||||
f.logf("the finding %s %s is not cleared: %v", PipelineFailedKind, h.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
condseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
nodebuildgo "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
||||
)
|
||||
@@ -157,3 +158,29 @@ func TestEachFailingMoverIsAFindingAndItsNextPassedPipelineClearsIt(t *testing.T
|
||||
t.Fatalf("findings %v, want app's alone after lib's pipeline passed", f.held)
|
||||
}
|
||||
}
|
||||
|
||||
// design 47 H2 H-A-605 (2), H-A-625 (2) (AC-P7, AC-P7b): a module the registrations view no longer names has its finding
|
||||
// pipeline-failed cleared, on any branch; the finding names the movers held behind the failed one and runner_unfinished_place.
|
||||
func TestAFailedFindingNamesTheMoversHeldBehindAndGoesWithTheRegistration(t *testing.T) {
|
||||
f := newHeld()
|
||||
entries := map[string]catalog.CatalogEntry{}
|
||||
edgeInto(entries, "gitea", "engine", 1)
|
||||
p := seat.Pipeline{Pipeline: "main.5", Branch: "main", Revision: 5,
|
||||
Movers: []seat.Mover{{Module: "engine", Commit: "c1"}, {Module: "gitea"}},
|
||||
Steps: []seat.StepResult{{Module: "engine", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeFailed},
|
||||
{Module: "gitea", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeNotAsked}}}
|
||||
fl := &Failures{Findings: f, Observer: "runner", Behind: func(p seat.Pipeline, m string) []string { return HeldBehind(p, m, entries) }}
|
||||
fl.StepEnded(nil, p, p.Steps[0])
|
||||
got := f.held["delivery.engine.main.pipeline-failed"]
|
||||
if !strings.Contains(got.Explanation, "gitea are held behind it") || !strings.Contains(got.Explanation, "runner_unfinished_place") {
|
||||
t.Fatalf("the finding says %q, want gitea held behind it and runner_unfinished_place", got.Explanation)
|
||||
}
|
||||
fl.Findings.(*heldFindings).held["delivery.engineer.main.pipeline-failed"] = condseat.Finding{Scope: "delivery", ID: "engineer.main", Kind: PipelineFailedKind}
|
||||
fl.ModuleGone("engine")
|
||||
if _, ok := f.held["delivery.engine.main.pipeline-failed"]; ok {
|
||||
t.Errorf("engine left the registrations and its finding is held")
|
||||
}
|
||||
if _, ok := f.held["delivery.engineer.main.pipeline-failed"]; !ok {
|
||||
t.Errorf("the finding of engineer, another module, was cleared")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user