H-A-506 corrected runner: a shared run's ask is dropped only by its last reader
A cancel or an end leaves each shared test run its steps read, and the run's ask is dropped only when the leaving pipeline was its last reader, never while another open pipeline still reads it; its own asks of no shared run and its mesh-wants asks are dropped at once. A step asked again (a rerun, a declined step of no test run) deletes its earlier ask's key: one key per ask, gone once the ask is no longer open. Builds: design 47 H2 H-A-506 corrected, H-A-506 addendum
This commit is contained in:
@@ -53,10 +53,19 @@ func TestAnAsksBoundCountsFromThePullAndEndsItsStep(t *testing.T) {
|
||||
}
|
||||
p.Steps[stepIndex(p, "lint", "app:program")].Outcome = seat.StepResultOutcomeFailed
|
||||
store.Update(pkey, p, rev)
|
||||
old := p.Steps[stepIndex(p, "lint", "app:program")].Ask
|
||||
_ = v.Hearer.Clock.MarkAsk(old, AskMark{Pipeline: pkey, Module: "app", Step: "lint"})
|
||||
r, err := v.Rerun("operator", seat.RerunInput{Pipeline: pkey, Step: "lint", Artifact: "app:program", Why: "retry"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The step asked again keeps one ask key, its new ask's: the earlier one is deleted (H-A-506 addendum).
|
||||
if _, had, _ := v.Hearer.Clock.AskOf(old); had {
|
||||
t.Errorf("the ask key of the earlier ask %s outlives the rerun", old)
|
||||
}
|
||||
if m, ok, _ := v.Hearer.Clock.AskOf(r.Result.Ask); !ok || m.Pipeline != pkey || m.Step != "lint" {
|
||||
t.Errorf("the rerun's ask key = %+v, %v; want it naming %s's lint step", m, ok, pkey)
|
||||
}
|
||||
ask, key := r.Result.Ask, AskBoundKey(nodebuildgo.Seat, r.Result.Ask)
|
||||
if want := []string{key + " 10m0s"}; !slices.Equal(armed, want) || len(asks.ids) != 1 {
|
||||
t.Fatalf("armed %v asking %v, want %v before one ask", armed, asks.ids, want)
|
||||
|
||||
@@ -99,6 +99,9 @@ func (h *Hearer) putDeclined(key, old string, s seat.StepResult, a Asked, ev Ste
|
||||
break
|
||||
}
|
||||
}
|
||||
if a.Run == "" {
|
||||
unmarkAsk(h.Clock, old, h.logf) // one key per ask, gone once the ask is no longer open (H-A-506 addendum)
|
||||
}
|
||||
h.logf("%s: the %s step of %s was declined on %s (%s): asked again as %s, not on %s (H-A-445)", key, s.Step,
|
||||
strings.TrimSpace(s.Module+" "+s.Artifact), ev.Node, ev.Said, a.ID, strings.Join(s.NotOn, ", "))
|
||||
return h.PutAgain(key, a)
|
||||
|
||||
@@ -34,8 +34,8 @@ func openAtEnd(steps []seat.StepResult) []seat.StepResult {
|
||||
}
|
||||
|
||||
// DropOpen takes the steps of pipeline key that its end took while asked (openAtEnd) off the seats (design 47 H2
|
||||
// H-A-506): a step reading a test run leaves it (leaveRun, whose last reader's leave drops the run's ask), and every own
|
||||
// ask still open, a shared test run's and a mesh-wants step's alike, is dropped through its seat's drop, so its holder
|
||||
// H-A-506 as corrected): a step reading a test run leaves it (leaveRun), the run's ask dropped only by its last reader's
|
||||
// leave; every other own ask still open, a mesh-wants step's included, is dropped through its seat's drop, so its holder
|
||||
// refuses it unrun and no build capacity goes to an ended pipeline. Each drop and each refusal is said in one journal line
|
||||
// per ask; a drop that is not answered fails nothing. The leaves are written before it answers; the drops are asked beside
|
||||
// the path that ended the pipeline (Aside), since a seat with no holder answers a kept call only at its bound, so a cancel
|
||||
@@ -45,10 +45,12 @@ func (h *Hearer) DropOpen(key string, steps []seat.StepResult, why string) {
|
||||
var drops []seat.StepResult
|
||||
for _, st := range steps {
|
||||
if sharedRun(st) != "" && st.Seat != wants.Seat {
|
||||
// A shared test run's ask is dropped only by its last reader's leave, never while another pipeline reads it
|
||||
// (H-A-506 corrected).
|
||||
if dropped := h.leaveRun(key, st, why); dropped != "" {
|
||||
done[dropped] = true
|
||||
h.logf("%s: the ask %s of %s's %s on %s is dropped with its test run, no reader left (H-A-506)", key, dropped, st.Module, st.Step, st.Seat)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !open(st) || st.Ask == "" || done[st.Ask] || !dropSeat(st.Seat) {
|
||||
continue
|
||||
|
||||
@@ -369,28 +369,26 @@ func TestATestRunsEndMovesEveryReaderAndIsCountedOnce(t *testing.T) {
|
||||
t.Errorf("%s's unit ends journaled %d times in %q, want once per artifact", key, n, f.logged)
|
||||
}
|
||||
}
|
||||
// a, cancelled, leaves the lint run to b's readers, and drops every ask of its own still open, the lint run's it asked
|
||||
// among them (H-A-506); b, cancelled after, leaves none: the run ends, no reader left, its ask not dropped twice.
|
||||
// Two pipelines read one lint run: a, cancelled, leaves it to b's readers and its ask is not dropped, while a's own
|
||||
// asks of no shared run are; b, cancelled after, is the last reader: the run ends, no reader left, and its ask is
|
||||
// dropped once (H-A-506 corrected).
|
||||
lint := stepNamed(a, "app:program", "lint")
|
||||
v := Verbs{Hearer: f.h, Acts: &actLog{}}
|
||||
if _, err := v.Cancel("operator", seat.CancelInput{Pipeline: a.Pipeline, Why: "not needed"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r, _, _ := f.runs.Get(lint.Shared[0].Run); r.Ended != nil || len(r.Readers) != 2 || !slices.Contains(f.drops, "node-build-go "+lint.Ask) {
|
||||
t.Fatalf("after a left the lint run = %+v, drops %v; want it running for b's two readers, a's lint ask dropped", r, f.drops)
|
||||
if r, _, _ := f.runs.Get(lint.Shared[0].Run); r.Ended != nil || len(r.Readers) != 2 || slices.Contains(f.drops, "node-build-go "+lint.Ask) || len(f.drops) == 0 {
|
||||
t.Fatalf("after a left the lint run = %+v, drops %v; want it running for b's two readers, its ask kept, a's own asks dropped", r, f.drops)
|
||||
}
|
||||
n := len(f.drops)
|
||||
if _, err := v.Cancel("operator", seat.CancelInput{Pipeline: b.Pipeline, Why: "not needed"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r, _, _ := f.runs.Get(lint.Shared[0].Run); r.Outcome != seat.StepResultOutcomeCouldNotRun || r.Said != NoReaderLeft || len(f.drops) <= n {
|
||||
t.Errorf("after the last reader left the lint run = %+v, drops %v; want it ended, no reader left", r, f.drops)
|
||||
if r, _, _ := f.runs.Get(lint.Shared[0].Run); r.Outcome != seat.StepResultOutcomeCouldNotRun || r.Said != NoReaderLeft {
|
||||
t.Errorf("after the last reader left the lint run = %+v; want it ended, no reader left", r)
|
||||
}
|
||||
seen := map[string]int{}
|
||||
for _, d := range f.drops[n:] {
|
||||
if seen[d]++; seen[d] > 1 {
|
||||
t.Errorf("b's cancel dropped %s twice: %v", d, f.drops[n:])
|
||||
}
|
||||
if got := countLines(f.drops[n:], lint.Ask); got != 1 {
|
||||
t.Errorf("b's cancel dropped %v, want the lint run's ask %s once", f.drops[n:], lint.Ask)
|
||||
}
|
||||
// A composition step's end keeps the runs mesh-wants names, as they came (A-468d).
|
||||
c := newRunFixture()
|
||||
|
||||
@@ -366,10 +366,11 @@ func (v Verbs) rerun(caller string, in seat.RerunInput, reopens bool) (seat.Reru
|
||||
}
|
||||
}
|
||||
var ask *Asked
|
||||
var replaced string
|
||||
p, _, err := v.change(in.Pipeline, seat.EventStepStarted, func() error {
|
||||
return v.record(seat.VerbRerun, fmt.Sprintf("asked the %s step of %s again", in.Step, in.Pipeline), in.Why)
|
||||
}, func(p *seat.Pipeline, now time.Time) (int, error) {
|
||||
ask = nil
|
||||
ask, replaced = nil, ""
|
||||
switch p.Outcome {
|
||||
case seat.PipelineOutcomeCancelled, seat.PipelineOutcomeSuperseded:
|
||||
return -1, fmt.Errorf("the pipeline %s is %s: a step of it is not asked again", p.Pipeline, p.Outcome)
|
||||
@@ -388,6 +389,7 @@ func (v Verbs) rerun(caller string, in seat.RerunInput, reopens bool) (seat.Reru
|
||||
}
|
||||
}
|
||||
oldAsk := s.Ask
|
||||
replaced = oldAsk
|
||||
*s = seat.StepResult{Step: s.Step, Module: s.Module, Artifact: s.Artifact, Status: s.Status, Fingerprint: s.Fingerprint, Seat: s.Seat,
|
||||
Outcome: seat.StepResultOutcomeWaiting, By: caller, Rerun: true}
|
||||
if ask != nil {
|
||||
@@ -414,6 +416,9 @@ func (v Verbs) rerun(caller string, in seat.RerunInput, reopens bool) (seat.Reru
|
||||
return seat.RerunAnswer{}, err
|
||||
}
|
||||
v.sayReopened(p, reopens)
|
||||
if ask == nil || replaced != ask.ID {
|
||||
unmarkAsk(v.Hearer.Clock, replaced, v.Hearer.logf) // one key per ask, gone once the ask is no longer open (H-A-506 addendum)
|
||||
}
|
||||
if ask != nil {
|
||||
v.Starter.carry(in.Pipeline, []Asked{*ask})
|
||||
if err := askAll(v.Starter.Steps, in.Pipeline, []Asked{*ask}, func(commit string) bool { return v.Starter.recovered(in.Pipeline, commit) }, v.Starter.armAsk(in.Pipeline), v.Starter.logf); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user