diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/handplace.go b/modules/mesh-delivery-pipeline/internal/pipeline/handplace.go index 252e7db16..0f41dbd09 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/handplace.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/handplace.go @@ -310,6 +310,7 @@ func (v Verbs) reopenGroup(caller string, from seat.Pipeline, group []string, ad cur.Movers = Tiers(append(cur.Movers, add...), entries, s.logf) } for _, m := range group { + adoptHead(&cur, m, entries) // the group's movers take their commit from the head's entries (H-A-768) if len(failedSteps(cur, m)) == 0 { cur.Steps = slices.DeleteFunc(slices.Clone(cur.Steps), func(st seat.StepResult) bool { return st.Module == m }) // The steps placed again take ask ids of their own: an id is made from the pipeline's start and its end count, which the diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go index fb9e1a7b4..d9895e439 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go @@ -432,6 +432,9 @@ func TestAMoverReopenedIsAskedWithTheHeadsPins(t *testing.T) { pin := func(v string) catalog.CatalogEntry { e := entries["app"] e.Fp, e.Packages, e.Commit, e.Repository = "src2:ab", map[string]string{sdk: v}, "c1", "o/app" + if v == "v0.1.27" { // design 47 H2 H-A-768: the head's entry holds the same fingerprint at a newer merge commit + e.Commit, e.Repository = "c2", "o/app-moved" + } return e } keptHalf := Half{Revision: 11, Source: 41, Entries: map[string]catalog.CatalogEntry{"app": pin("v0.1.26"), "mesh-build-go": entries["mesh-build-go"]}} @@ -489,16 +492,24 @@ func TestAMoverReopenedIsAskedWithTheHeadsPins(t *testing.T) { if len(asks.asks) == before { t.Fatalf("%s: nothing was asked", how) } - want := "v0.1.27" + want, wantCommit, wantRepo := "v0.1.27", "c2", "o/app-moved" if how != "start" && how != "place-unfinished" { - want = "v0.1.26" + want, wantCommit, wantRepo = "v0.1.26", "c1", "o/app" } seen := 0 for _, ask := range asks.asks[before:] { + if b, ok := ask.(builds.StepRun); ok { // the build ask names the entry's commit, as the builder's check of the entry needs + if len(b.Entries) != 1 || b.Entries[0].Commit != wantCommit { + t.Errorf("%s: the build asked %+v, want the entry's commit %s", how, b.Entries, wantCommit) + } + } if b, ok := ask.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Fetch.Packages != nil { if seen++; b.Step.Fetch.Packages[sdk] != want { t.Errorf("%s: asked %+v, want mesh-sdk pinned to %s", how, b.Step, want) } + if b.Step.Commit != wantCommit || b.Step.Fetch.Commit != wantCommit || b.Step.Fetch.Repository != wantRepo { + t.Errorf("%s: asked at commit %s (fetch %s of %s), want the commit %s of %s the entry holds", how, b.Step.Commit, b.Step.Fetch.Commit, b.Step.Fetch.Repository, wantCommit, wantRepo) + } } } if seen == 0 { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index f3644fb75..c632dd53b 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -130,6 +130,25 @@ func MoverOf(p seat.Pipeline, module string) (seat.Mover, bool) { return seat.Mover{}, false } +// adoptHead sets the commit and repository of p's mover of module, when its entry in entries holds the mover's fingerprint, to +// that entry's, so a mover that goes on is asked, and its step ends are matched, at the commit the head's entry names: a same +// fingerprint at a newer commit is the same build (design 47 H2 H-A-768, H-A-530). A mover whose entry holds another fingerprint +// is left as it is. +func adoptHead(p *seat.Pipeline, module string, entries map[string]catalog.CatalogEntry) { + e, ok := entries[module] + for i, m := range p.Movers { + if m.Module != module || !ok || e.Fp != m.Fingerprint { + continue + } + if e.Commit != "" { + p.Movers[i].Commit = e.Commit + } + if e.Repository != "" { + p.Movers[i].Repository = e.Repository + } + } +} + // Moves says whether p moves module. func Moves(p seat.Pipeline, module string) bool { _, ok := MoverOf(p, module) @@ -511,6 +530,10 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog } // A mover a same-source re-pin kept is placed from the revision it is kept at, its ids its own (H-A-286). entries := all + if p.EndCount > 0 { // a mover of an ended pipeline that goes on takes its commit from the head's entry (H-A-768) + adoptHead(p, m.Module, all) + m = p.Movers[i] + } // A mover of a pipeline that ended and goes on again reads the head's entry when it holds the mover at its fingerprint // (design 47 H2 H-A-764 (1), H-A-763 (3)); its ids still mix in the kept revision. if rev := kept[m.Module]; rev > 0 && !(p.EndCount > 0 && all[m.Module].Fp == m.Fingerprint) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go index b1e84f8f3..89b49c5d1 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go @@ -397,6 +397,11 @@ func (v Verbs) rerun(caller string, in seat.RerunInput, reopens bool) (seat.Reru return -1, fmt.Errorf("the %s step of %s is running: it is not asked again", in.Step, p.Pipeline) } if s.Seat != "" { + if p.Run == "" && v.View != nil { // the record's commit becomes the head entry's before the ask is made (H-A-768) + if h, ok := v.View(p.Branch); ok { + adoptHead(p, s.Module, h.Entries) + } + } if ask, err = v.askOf(*p, *s, caller, now); err != nil { return -1, err } @@ -676,6 +681,12 @@ func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time if v.Starter == nil || v.Starter.Registration == nil || v.Starter.Steps == nil || (v.View == nil && p.Run == "") { return nil, errors.New("the runner cannot ask a step: it holds no registration or no ask") } + if atHead && p.Run == "" && v.View != nil { + if h, ok := v.View(p.Branch); ok { // its commit and repository are the head's entry's too (design 47 H2 H-A-768) + p.Movers = slices.Clone(p.Movers) + adoptHead(&p, s.Module, h.Entries) + } + } m, ok := MoverOf(p, s.Module) if !ok { return nil, fmt.Errorf("%s moves no module %q", p.Pipeline, s.Module)