P2 held-step-said: the held step keeps held-at; wait-held, wait-ended and stands carry the stalled-bound and clock-from = held-at
Builds: design 47 H2 H-A-599, H-A-736 (1), H-A-738 (2)
This commit is contained in:
@@ -176,7 +176,7 @@ func main() {
|
||||
}
|
||||
fill := StoresFill(func(n string) (*stdio.StateInfo, error) { return stdio.State(n).Info() },
|
||||
func(n string) (*stdio.LogInfo, error) { return stdio.Log(n).Info() }, time.Now)
|
||||
r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill}
|
||||
r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill, StalledBound: stalledBound}
|
||||
tools := append(Tools(r), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...)
|
||||
tools = append(tools, UnloggedTools(stdio.State(seat.StatePipelines), stdio.Log(seat.StateStepLog), meshhandactsclient.Recorder{Ask: stdio.Ask},
|
||||
func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] "+f+"\n", a...) })...)
|
||||
|
||||
@@ -172,6 +172,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hearer.StalledBound = stalledBound // the held step's wait is timed by it (H-A-738 (2))
|
||||
logger.Printf("health: a running pipeline with nothing open and nothing newly placed, or a step whose ask is untaken, is named after %s (%s)", stalledBound, pipeline.StalledBoundSetting)
|
||||
// Its asking half (§22, §24): a pipeline's steps are placed from the module's registration and each build seat is asked
|
||||
// for its step.
|
||||
|
||||
@@ -208,6 +208,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
Movers: slices.Clone(movers[:2]), Steps: []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), step("b", seat.StepResultOutcomeRunning, "x2")}}, rev: 1}}
|
||||
var put []Asked
|
||||
var journal []string
|
||||
var waitBodies []seat.Wait
|
||||
var waits []string // the waits said, by event and what they wait on (H-A-563)
|
||||
var started []seat.StepEvent
|
||||
view := r.view
|
||||
@@ -220,11 +221,12 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
if strings.Contains(subject, seat.EventWaitEnded) {
|
||||
ev = seat.EventWaitEnded
|
||||
}
|
||||
waitBodies = append(waitBodies, w)
|
||||
waits = append(waits, ev+" "+w.Step+" "+w.On+" "+w.Module)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline",
|
||||
h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline", StalledBound: time.Minute,
|
||||
View: func(string) (Half, bool) {
|
||||
return Half{Revision: view, Source: view, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true
|
||||
},
|
||||
@@ -269,6 +271,9 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
len(put) != 0 || p.Outcome != seat.PipelineOutcomeRunning {
|
||||
t.Fatalf("superseded %v, a's build %+v, put %+v; want the build waiting on the revision view for revision 120, nothing asked", p.Superseded, s, put)
|
||||
}
|
||||
if s := p.Steps[0]; s.HeldAt == nil || !s.HeldAt.Equal(t0) {
|
||||
t.Errorf("the held step keeps held-at %v, want %v", s.HeldAt, t0)
|
||||
}
|
||||
if want := []string{seat.EventWaitHeld + " build revision view a"}; !slices.Equal(waits, want) {
|
||||
t.Errorf("waits said %q, want %q", waits, want)
|
||||
}
|
||||
@@ -281,12 +286,18 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
|
||||
if moved := h.RevisionHeld("main"); !slices.Equal(moved, []string{"main.117"}) {
|
||||
t.Errorf("at revision 120 the view moved %v, want main.117", moved)
|
||||
}
|
||||
if p, _, _ := store.Get("main.117"); !left(p) || p.Steps[0].On != "" || p.Outcome != seat.PipelineOutcomeRunning {
|
||||
if p, _, _ := store.Get("main.117"); !left(p) || p.Steps[0].On != "" || p.Steps[0].HeldAt != nil || p.Outcome != seat.PipelineOutcomeRunning {
|
||||
t.Errorf("after the view held 120: superseded %v, a's build %+v, pipeline %s; want a left, b still running", p.Superseded, p.Steps[0], p.Outcome)
|
||||
}
|
||||
if want := []string{seat.EventWaitHeld + " build revision view a", seat.EventWaitEnded + " build revision view a"}; !slices.Equal(waits, want) {
|
||||
t.Errorf("waits said %q, want %q", waits, want)
|
||||
}
|
||||
// H-A-599, H-A-738 (2): each carries the runner's stalled-bound and the time the step was held; none outlives the hold.
|
||||
for _, w := range waitBodies {
|
||||
if w.Bound != "1m0s" || w.ClockFrom == nil || !w.ClockFrom.Equal(t0) {
|
||||
t.Errorf("a wait said with bound %q and clock-from %v, want 1m0s and %v", w.Bound, w.ClockFrom, t0)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ type Reads struct {
|
||||
// Fill is each of the runner's stores' fill now, pipelines, kept and step-log, read through the bundle's calls
|
||||
// (the state's `mesh/state.info`, the object store's and the log's fill; design 47 G §366, §623, A-214); nil says none.
|
||||
Fill func() ([]seat.Fill, error)
|
||||
// StalledBound is the runner's setting stalled-bound, the bound of a held step's wait (H-A-599, H-A-738 (2)).
|
||||
StalledBound time.Duration
|
||||
}
|
||||
|
||||
// fills is the stores' fill, or an error saying it could not be read: an answer never leaves it out unsaid.
|
||||
@@ -345,9 +347,13 @@ func (r Reads) Stands() (seat.StandsAnswer, error) {
|
||||
continue
|
||||
}
|
||||
m, _ := MoverOf(p, s.Module)
|
||||
out = append(out, seat.Wait{Pipeline: p.Pipeline, Module: m.Module, Branch: p.Branch, Commit: m.Commit,
|
||||
w := seat.Wait{Pipeline: p.Pipeline, Module: m.Module, Branch: p.Branch, Commit: m.Commit,
|
||||
Run: p.Run, Source: p.Source, Revision: p.Revision, Fingerprint: m.Fingerprint, Step: s.Step,
|
||||
Artifact: s.Artifact, On: s.On, Since: *s.Started, V: 1, Ask: askOfWait(s), Shared: sharedOfWait(s)})
|
||||
Artifact: s.Artifact, On: s.On, Since: *s.Started, V: 1, Ask: askOfWait(s), Shared: sharedOfWait(s)}
|
||||
if s.On == seat.WaitOnRevisionView && s.HeldAt != nil { // the held step's wait is timed from its hold (H-A-599, H-A-738 (2))
|
||||
w.Bound, w.ClockFrom = boundOf(r.StalledBound), s.HeldAt
|
||||
}
|
||||
out = append(out, w)
|
||||
}
|
||||
}
|
||||
sort.SliceStable(out, func(i, j int) bool { return out[i].Since.Before(out[j].Since) })
|
||||
|
||||
@@ -384,3 +384,32 @@ func TestAPipelineIsReadInParts(t *testing.T) {
|
||||
t.Fatalf("words %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 H2 H-A-599, H-A-738 (2): a held step stands with the runner's stalled-bound and the time it was held, so the watchman's
|
||||
// seed from stands times it as the wait-held did, also after a restart.
|
||||
func TestStandsNamesTheBoundAndClockOfAHeldStep(t *testing.T) {
|
||||
f := newRunFixture()
|
||||
p := f.start(t, 4, 9)
|
||||
held := time.Date(2026, 11, 25, 12, 0, 0, 0, time.UTC)
|
||||
pl := f.pipeline(p)
|
||||
for i := range pl.Steps {
|
||||
if pl.Steps[i].Step == "unit" && pl.Steps[i].Artifact == "app:program" {
|
||||
pl.Steps[i].Outcome, pl.Steps[i].On, pl.Steps[i].Revision, pl.Steps[i].HeldAt = seat.StepResultOutcomeWaiting, seat.WaitOnRevisionView, 12, &held
|
||||
}
|
||||
}
|
||||
pipes := memKept{}
|
||||
put(t, pipes, p.Pipeline, pl)
|
||||
a, err := Reads{Pipelines: pipes, Kept: memKept{}, StalledBound: time.Minute}.Stands()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, w := range a.Stands {
|
||||
if w.Artifact == "app:program" && w.Step == "unit" {
|
||||
if w.Bound != "1m0s" || w.ClockFrom == nil || !w.ClockFrom.Equal(held) {
|
||||
t.Errorf("the held step stands with bound %q and clock-from %v, want 1m0s and %v", w.Bound, w.ClockFrom, held)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Error("the held step does not stand")
|
||||
}
|
||||
|
||||
@@ -157,6 +157,8 @@ type Hearer struct {
|
||||
// Asker publishes an approval step's ask (§37); Name is the runner's own name, the asker a warrant names.
|
||||
Asker Asker
|
||||
Name string
|
||||
// StalledBound is the runner's setting stalled-bound (§790): the bound of a held step's wait, given at the start (H-A-738 (2)).
|
||||
StalledBound time.Duration
|
||||
// Where reads the router's record of one of the runner's asks, as operatorchannelclient.Client.Where does: its state and
|
||||
// its warrant (design 47 G A-89, §700).
|
||||
Where func(ask string) (string, *oc.Warrant, error)
|
||||
@@ -391,6 +393,8 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
|
||||
case superseding > own && !h.viewHolds(p.Branch, superseding):
|
||||
old := s.Ask
|
||||
s.Outcome, s.On, s.Revision, s.Node, s.Why = seat.StepResultOutcomeWaiting, seat.WaitOnRevisionView, superseding, node, ev.Said
|
||||
held := h.now()
|
||||
s.HeldAt = &held // when the step was held: the clock of its wait (H-A-599, H-A-738 (2))
|
||||
if _, err := h.Store.Update(ev.Pipeline, p, rev); errors.Is(err, ErrChanged) {
|
||||
continue
|
||||
} else if err != nil {
|
||||
@@ -411,6 +415,7 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
|
||||
ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the builder on %s ended it superseded: a superseded end without its revision (%s)", node, ev.Said)
|
||||
}
|
||||
s.Outcome, s.Node, s.Why, s.Rerun, s.By, s.Ended = ev.Outcome, node, ev.Said, ev.Rerun, ev.By, &now
|
||||
s.HeldAt = nil // the hold ends with the step (H-A-738 (2))
|
||||
if len(shared) > 0 {
|
||||
s.Shared = shared
|
||||
}
|
||||
@@ -761,6 +766,7 @@ func (h *Hearer) say(event string, p seat.Pipeline, step *seat.StepResult) error
|
||||
w.Module, w.Commit, w.Fingerprint, w.Step, w.Ask = m.Module, m.Commit, m.Fingerprint, step.Step, step.Ask
|
||||
if step.On == seat.WaitOnRevisionView { // a build waiting for the revision that superseded it (H-A-563)
|
||||
w.On = step.On
|
||||
w.Bound, w.ClockFrom = boundOf(h.StalledBound), step.HeldAt // timed from its hold by the stalled bound (H-A-599, H-A-736 (1))
|
||||
}
|
||||
}
|
||||
return h.Say(runnerclient.RevisionSubject(event, p.Branch, subjectRevision(p)), w)
|
||||
@@ -1128,3 +1134,11 @@ func sameValidate(p *seat.Pipeline, i int, now time.Time) []int {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// boundOf is a bound as a wait names it, a Go duration such as 5m0s; empty for none.
|
||||
func boundOf(d time.Duration) string {
|
||||
if d <= 0 {
|
||||
return ""
|
||||
}
|
||||
return d.String()
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ func supersedeStep(p *seat.Pipeline, st *seat.StepResult, why string, now time.T
|
||||
drop = append(drop, *st) // its own ask on a build node: the seat's drop cancels it
|
||||
}
|
||||
st.Outcome, st.Why, st.Ended = seat.StepResultOutcomeSuperseded, why, &now
|
||||
st.HeldAt = nil
|
||||
p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now))
|
||||
return leave, drop
|
||||
}
|
||||
@@ -405,7 +406,7 @@ func (h *Hearer) revisionHeldOne(key string, held int64) bool {
|
||||
waited = append(waited, *st) // its wait-ended is said as it was held (H-A-563)
|
||||
}
|
||||
why := fmt.Sprintf("superseded: its build was superseded and its mover left for the newer revision's pipeline, revision %d now held (H-A-508, H-A-562): %s", held, whys[st.Module])
|
||||
st.On, st.Revision = "", 0
|
||||
st.On, st.Revision, st.HeldAt = "", 0, nil
|
||||
l, d := supersedeStep(&p, st, why, now)
|
||||
leave, drop = append(leave, l...), append(drop, d...)
|
||||
ended = append(ended, i)
|
||||
|
||||
Reference in New Issue
Block a user