runner: a build ended superseded moves its mover out, never a failure
A build step the builder ends superseded is taken as the mover moved to the newer revision's pipeline, by the path a newer pipeline taking a mover already has: its other open steps end superseded, the mover is kept in the pipeline's superseded, and the pipeline is judged by its other movers. Any other seat's end naming superseded stays refused as an outcome the runner does not know. Builds: design 47 H2 H-A-508 (and its addendum)
This commit is contained in:
@@ -53,6 +53,25 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
h.SupersedeRunning(seat.Pipeline{Pipeline: "main.120", Branch: "main", Revision: 120, Movers: []seat.Mover{
|
||||
{Module: "a", Commit: "c2", Fingerprint: "src2:a2"}, {Module: "b", Commit: "c2", Fingerprint: "src2:b2"}, {Module: "c", Commit: "c2", Fingerprint: "src2:c2"}}})
|
||||
}, seat.PipelineOutcomeSuperseded},
|
||||
// H-A-508: a build the builder ended superseded moves its mover out as a newer pipeline taking it does: its other open
|
||||
// steps end superseded, it is kept in superseded, and the pipeline passes by its other movers, never failed.
|
||||
{"its last open step, a build, ends superseded (H-A-508)",
|
||||
[]seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), {Module: "a", Artifact: "program", Step: seat.StepResultStepUnit,
|
||||
Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeWaiting, Seat: "node-build-go"},
|
||||
step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")},
|
||||
func(t *testing.T, h *Hearer) {
|
||||
bs := stepSeatOf(t, builds.Seat)
|
||||
end := StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "build",
|
||||
Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2, the newest entry heard on its first branch"}
|
||||
if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, _, _ := h.Store.Get("main.117")
|
||||
if !slices.Equal(p.Superseded, []string{"a"}) || p.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !strings.Contains(p.Steps[0].Why, "src2:a2") ||
|
||||
p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded {
|
||||
t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:2])
|
||||
}
|
||||
}, seat.PipelineOutcomePassed},
|
||||
{"its last open step ends could not run on the silent bound (H-A-243)",
|
||||
[]seat.StepResult{step("a", seat.StepResultOutcomeRunning, "mwql5pio3390aa"), step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")},
|
||||
func(t *testing.T, h *Hearer) {
|
||||
|
||||
@@ -298,7 +298,7 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh
|
||||
h.logf("the step-ended of ask %s is ignored: its test run %s ended before it (%s)", ev.ID, run, p.Steps[i].Why)
|
||||
}
|
||||
return p, nil
|
||||
case !endOutcome(ev.Outcome):
|
||||
case !endOutcome(ev.Outcome) && !supersededBuild(p.Steps[i], ev.Outcome):
|
||||
return p, fmt.Errorf("%w: ask %s ended %q, not an outcome of step-ended", ErrRefused, ev.ID, ev.Outcome)
|
||||
}
|
||||
now := h.now()
|
||||
@@ -344,6 +344,26 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh
|
||||
readers = append(readers, endPinHeld(&p, *s, pins, now)...)
|
||||
askHeld = stepPassed(*s) && heldOn(p, s.Module)
|
||||
}
|
||||
// A build ended superseded moves its mover to the newer revision's pipeline, as a newer pipeline taking it does
|
||||
// (H-A-508, H-A-223): its other open steps end superseded, it is kept in the pipeline's superseded, and the pipeline
|
||||
// is judged by its other movers alone; never a failure.
|
||||
var leave, drop []seat.StepResult
|
||||
left := s.Step == seat.StepResultStepBuild && s.Outcome == seat.StepResultOutcomeSuperseded
|
||||
if left {
|
||||
why := "superseded: its build was superseded and its mover left for the newer revision's pipeline (H-A-508): " + s.Why
|
||||
for j := range p.Steps {
|
||||
st := &p.Steps[j]
|
||||
if j == i || st.Module != s.Module || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) {
|
||||
continue
|
||||
}
|
||||
l, d := supersedeStep(&p, st, why, now)
|
||||
leave, drop = append(leave, l...), append(drop, d...)
|
||||
readers = append(readers, j)
|
||||
}
|
||||
if !slices.Contains(p.Superseded, s.Module) {
|
||||
p.Superseded = append(p.Superseded, s.Module)
|
||||
}
|
||||
}
|
||||
if s.Step == seat.StepResultStepValidate {
|
||||
readers = append(readers, sameValidate(&p, i, now)...)
|
||||
var notAsked []int
|
||||
@@ -364,9 +384,14 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh
|
||||
// A build that passes, a rerun's among them, places again the steps that ended not asked on it (H-A-406): its
|
||||
// dependents need no hand rerun.
|
||||
var again []string
|
||||
if s.Step == seat.StepResultStepBuild && stepPassed(*s) {
|
||||
if s.Step == seat.StepResultStepBuild && (stepPassed(*s) || left) {
|
||||
// A mover that left is no dependency of the movers that stay (H-A-361): theirs ended not asked on it are placed again.
|
||||
named := readerNames(p, readers)
|
||||
if again = takeOutNotAsked(&p, s.Module); len(again) > 0 {
|
||||
release = true
|
||||
// The steps taken out shift the indexes: the step and its readers are found again by their names.
|
||||
i = stepOfAsk(p, ev.ID)
|
||||
s, readers = &p.Steps[i], readerIndexes(p, named)
|
||||
}
|
||||
}
|
||||
ended := h.endPipeline(&p, now, wr)
|
||||
@@ -393,6 +418,11 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh
|
||||
}
|
||||
}
|
||||
h.Failures.StepEnded(h.Store, p, *s)
|
||||
if left {
|
||||
h.logf("%s: %s's build ended superseded, so it leaves for the newer revision's pipeline, %d of its other steps ended superseded (H-A-508): %s",
|
||||
ev.Pipeline, s.Module, len(readers), s.Why)
|
||||
h.leaveSteps(ev.Pipeline, leave, drop, "the mover %s left "+ev.Pipeline+" for the newer revision's pipeline", "superseded: its build was superseded (H-A-508)")
|
||||
}
|
||||
if err := h.say(seat.EventStepEnded, p, s); err != nil {
|
||||
return p, fmt.Errorf("pipeline %s's %s is written but not said: %w", ev.Pipeline, seat.EventStepEnded, err)
|
||||
}
|
||||
@@ -767,6 +797,32 @@ func phasesOf(p seat.Pipeline) *seat.PipelineEndedPhases {
|
||||
return ph
|
||||
}
|
||||
|
||||
// supersededBuild says whether o is the outcome superseded of a build step of the seat mesh-builds, the one seat whose end
|
||||
// names it (H-A-508): another seat's end naming it is refused as any outcome the runner does not know.
|
||||
func supersededBuild(st seat.StepResult, o string) bool {
|
||||
return o == builds.StepEndedOutcomeSuperseded && st.Seat == builds.Seat && st.Step == seat.StepResultStepBuild
|
||||
}
|
||||
|
||||
// readerNames are the steps of p at the indexes readers, by module, artifact and step.
|
||||
func readerNames(p seat.Pipeline, readers []int) []string {
|
||||
out := make([]string, 0, len(readers))
|
||||
for _, j := range readers {
|
||||
out = append(out, p.Steps[j].Module+"\x00"+p.Steps[j].Artifact+"\x00"+p.Steps[j].Step)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// readerIndexes are the indexes in p of the steps named, as readerNames names them.
|
||||
func readerIndexes(p seat.Pipeline, names []string) []int {
|
||||
var out []int
|
||||
for j, st := range p.Steps {
|
||||
if slices.Contains(names, st.Module+"\x00"+st.Artifact+"\x00"+st.Step) {
|
||||
out = append(out, j)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func endOutcome(o string) bool {
|
||||
switch o {
|
||||
case nodebuildgo.StepEndedOutcomePassed, nodebuildgo.StepEndedOutcomeFailed, nodebuildgo.StepEndedOutcomeNothingToRun,
|
||||
|
||||
Reference in New Issue
Block a user