mesh-delivery-pipeline: a carried, placed, reopened or rerun mover reads its entry at the head's revision
Builds: design 47 H2 H-A-763 (3); H-A-608, H-A-761
This commit is contained in:
@@ -209,13 +209,8 @@ func (v Verbs) ownFailedPipelines(branch, key string, movers []seat.Mover, headE
|
||||
}
|
||||
at := slices.IndexFunc(out, func(o ownPipeline) bool { return o.from.Pipeline == best.Pipeline })
|
||||
if at < 0 {
|
||||
entries := headEntries
|
||||
if s.Revision != nil {
|
||||
if h, err := s.Revision(branch, best.Revision); err == nil && h.Entries != nil {
|
||||
entries = h.Entries
|
||||
}
|
||||
}
|
||||
out = append(out, ownPipeline{from: best, entries: entries})
|
||||
// Its movers are read at the head's revision, whose entries are the newest (design 47 H2 H-A-763 (3)).
|
||||
out = append(out, ownPipeline{from: best, entries: headEntries})
|
||||
at = len(out) - 1
|
||||
}
|
||||
out[at].group = appendNew(out[at].group, v.closedGroup(best, m.Module, out[at].entries)...)
|
||||
@@ -396,53 +391,24 @@ func (v Verbs) planUnfinished(key string) (handPlan, error) {
|
||||
if err != nil || !Moves(from, module) {
|
||||
return handPlan{}, fmt.Errorf("its pipeline %s is not read or moves %s no more", e.Pipeline, module)
|
||||
}
|
||||
if s.Revision == nil && v.View == nil {
|
||||
if v.View == nil {
|
||||
return handPlan{}, errors.New("the runner reads no catalog revision")
|
||||
}
|
||||
// The entry is read at its kept revision, else at the head's when the entry there has the same fingerprint (design 47 H2 H-A-608).
|
||||
readAt := func(rev int64) (Half, error) {
|
||||
if s.Revision != nil {
|
||||
h, err := s.Revision(branch, rev)
|
||||
if err != nil {
|
||||
return Half{}, fmt.Errorf("the revision %d of %s is not read: %w", rev, branch, err)
|
||||
}
|
||||
return h, nil
|
||||
}
|
||||
if h, ok := v.View(branch); ok && h.Revision == rev {
|
||||
return h, nil
|
||||
}
|
||||
return Half{}, fmt.Errorf("the revision %d of %s is not held", rev, branch)
|
||||
}
|
||||
// The entry is read at the head's revision, which holds the module at the key's fingerprint (design 47 H2 H-A-763 (3), H-A-761);
|
||||
// the kept revision H-A-608 names stays the revision the record pins, and is only said.
|
||||
kept := s.Unfinished.keptRevision(e, module)
|
||||
half, rerr := readAt(kept)
|
||||
entry, has := half.Entries[module]
|
||||
if rerr != nil || !has || entry.Fp != e.Fingerprint || half.Source <= 0 {
|
||||
looked := fmt.Sprintf("its kept revision %d holds it at %q", kept, entry.Fp)
|
||||
if rerr != nil {
|
||||
looked = rerr.Error()
|
||||
}
|
||||
head, hok := Half{}, false
|
||||
if v.View != nil {
|
||||
head, hok = v.View(branch)
|
||||
}
|
||||
he, hhas := head.Entries[module]
|
||||
if !hok || !hhas || he.Fp != e.Fingerprint || head.Source <= 0 {
|
||||
return handPlan{}, fmt.Errorf("%s at fingerprint %s is read at neither revision: %s; the head's revision %d of %s holds it at %q", module, e.Fingerprint, looked, head.Revision, branch, he.Fp)
|
||||
}
|
||||
half = head
|
||||
}
|
||||
// H-A-761: the key goes on only when the head's revision holds its module at the key's fingerprint; otherwise it is dropped and said.
|
||||
if head, ok := v.View(branch); !ok || head.Entries[module].Fp != e.Fingerprint {
|
||||
he := head.Entries[module]
|
||||
why := fmt.Sprintf("the head's revision %d of %s holds it at %q, not at the key's %q; its entry was read at revision %d", head.Revision, branch, he.Fp, e.Fingerprint, kept)
|
||||
head, hok := v.View(branch)
|
||||
if he := head.Entries[module]; !hok || he.Fp != e.Fingerprint {
|
||||
why := fmt.Sprintf("the head's revision %d of %s holds it at %q, not at the key's %q; its kept revision %d", head.Revision, branch, he.Fp, e.Fingerprint, kept)
|
||||
s.Unfinished.dropMoved(key, module, e.Fingerprint, why)
|
||||
return handPlan{}, fmt.Errorf("%s is no longer unfinished at fingerprint %s: %s", module, e.Fingerprint, why)
|
||||
}
|
||||
if head.Source <= 0 {
|
||||
return handPlan{}, fmt.Errorf("%s at fingerprint %s is read at the head's revision %d of %s, which has no source", module, e.Fingerprint, head.Revision, branch)
|
||||
}
|
||||
half := head
|
||||
group := v.closedGroup(from, module, half.Entries)
|
||||
plan := handPlan{from: from, group: group, entries: half.Entries}
|
||||
if head, ok := v.View(branch); ok && head.Entries != nil {
|
||||
plan.entries = head.Entries
|
||||
}
|
||||
for _, g := range group {
|
||||
mv, _ := MoverOf(from, g)
|
||||
plan.movers = append(plan.movers, mv)
|
||||
|
||||
@@ -150,6 +150,27 @@ func TestASameSourceRepinKeepsTheMoverInItsPipeline(t *testing.T) {
|
||||
if last.Step.Fingerprint != "src2:ab" || last.Step.Fetch.Packages["git.novox.be/novox/x/go"] != "v0.1.1" {
|
||||
t.Errorf("a held step asked = %+v", last.Step)
|
||||
}
|
||||
// design 47 H2 H-A-763 (3): a rerun of the kept mover's step reads its entry at the head's revision when that holds the mover
|
||||
// at the same fingerprint, so its build is asked with the head's newer pins; the kept revision stays in the id.
|
||||
_, _, repinnedEntries, _ := repinFixture()
|
||||
headApp := repinnedEntries["app"]
|
||||
headApp.Packages = map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.27", "git.novox.be/novox/x/go": "v0.1.1"}
|
||||
headEntries := map[string]catalog.CatalogEntry{}
|
||||
for k, e := range repinnedEntries {
|
||||
headEntries[k] = e
|
||||
}
|
||||
headEntries["app"] = headApp
|
||||
head := Half{Revision: 13, Source: 41, Entries: headEntries}
|
||||
rv := Verbs{Starter: s, View: func(string) (Half, bool) { return head, true }, Hearer: h}
|
||||
cur, _, _ := store.Get(key)
|
||||
unit := stepNamed(cur, "app:program", "unit")
|
||||
a, err := rv.askOf(cur, unit, "op@shanks", time.Unix(100, 0))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if b, ok := a.Ask.(nodebuildgo.StepAsk); !ok || b.Step.Fetch.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.27" {
|
||||
t.Errorf("the rerun with the head holding app at its fingerprint asked %+v, want mesh-sdk pinned to the head's v0.1.27", a.Ask)
|
||||
}
|
||||
// A revision of a new source starts its own pipeline and moves the mover out (H-A-223).
|
||||
if n, err := s.Revised(ev(12), read); n != 1 || err != nil {
|
||||
t.Fatalf("a new source's revision started %d (%v)", n, err)
|
||||
|
||||
@@ -573,8 +573,8 @@ func TestTakenInStartsOnlyItsEntries(t *testing.T) {
|
||||
}, Logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) },
|
||||
Entries: func(_ string, r int64) (map[string]catalog.CatalogEntry, bool) { e, ok := held[r]; return e, ok }}
|
||||
got := cu.Carry("main", 20, map[string]catalog.CatalogEntry{"back": {Commit: "c20", Fp: "src2:b1"}, "old": {Commit: "c20", Fp: "src2:o1"}, "newer": {Commit: "c20", Fp: "src2:x2"}}, nil)
|
||||
if len(got) != 2 || got[0].Module != "back" || got[0].Commit != "c20" || got[1].Module != "old" || got[1].Commit != "c3" {
|
||||
t.Errorf("the carry = %+v, want back read at the head's revision (its kept revision 2 gone) and old at its kept revision 3, the head holding it at the same fingerprint, and newer not carried at x1", got)
|
||||
if len(got) != 2 || got[0].Module != "back" || got[0].Commit != "c20" || got[1].Module != "old" || got[1].Commit != "c20" {
|
||||
t.Errorf("the carry = %+v, want back and old read at the head's revision (H-A-763 (3): old's kept revision 3 still holds it, the head's entry is read), and newer not carried at x1", got)
|
||||
}
|
||||
if j := strings.Join(said, "\n"); !strings.Contains(j, "far is no longer unfinished at fingerprint src2:f1") || !strings.Contains(j, "kept revision 2 is gone") || !strings.Contains(j, "head's revision 20") ||
|
||||
!strings.Contains(j, "newer is no longer unfinished at fingerprint src2:x1") || !strings.Contains(j, `holds it at "src2:x2", not at the key's "src2:x1"`) || cu.Store.(memUnfinished)["main.newer"] != "" {
|
||||
|
||||
@@ -454,8 +454,8 @@ func (u *Unfinished) keptRevision(e UnfinishedEntry, module string) int64 {
|
||||
|
||||
// entryOf reads module's entry for the carry (design 47 H2 H-A-608, H-A-761): the module goes on only when the head's revision's
|
||||
// entry (entries) holds the key's fingerprint, so an older fingerprint is never delivered after a newer one; its contents are
|
||||
// read at its kept revision when that is still read and holds it at the key's fingerprint, else at the head's. Neither says why,
|
||||
// naming both fingerprints and each revision looked at.
|
||||
// the head's entry's, whose pins are the newest (design 47 H2 H-A-763 (3), replacing H-A-761's reading at the kept revision,
|
||||
// which stays the revision the record pins, H-A-608). Else it says why, naming both fingerprints and each revision looked at.
|
||||
func (u *Unfinished) entryOf(branch string, head int64, entries map[string]catalog.CatalogEntry, module string, e UnfinishedEntry) (catalog.CatalogEntry, string, bool) {
|
||||
hentry, ok := entries[module]
|
||||
if !ok || hentry.Fp != e.Fingerprint {
|
||||
@@ -469,13 +469,6 @@ func (u *Unfinished) entryOf(branch string, head int64, entries map[string]catal
|
||||
}
|
||||
return catalog.CatalogEntry{}, fmt.Sprintf("%sthe head's revision %d of %s holds it at %q, not at the key's %q, so a newer revision moved it or its entry is gone (H-A-761)", kept, head, branch, hentry.Fp, e.Fingerprint), false
|
||||
}
|
||||
if kept := u.keptRevision(e, module); kept > 0 && kept != head && u.Entries != nil {
|
||||
if kents, ok := u.Entries(branch, kept); ok {
|
||||
if entry, ok := kents[module]; ok && entry.Fp == e.Fingerprint {
|
||||
return entry, "", true
|
||||
}
|
||||
}
|
||||
}
|
||||
return hentry, "", true
|
||||
}
|
||||
|
||||
|
||||
@@ -708,9 +708,10 @@ func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time
|
||||
} else {
|
||||
return nil, fmt.Errorf("the catalog half of %s is not held yet: the step is asked when it is", p.Branch)
|
||||
}
|
||||
// A kept mover's step is the one placed from the revision it is kept at, under its kept ids (H-A-286).
|
||||
// A kept mover's step is placed under its kept ids (H-A-286), from the head's entry when that holds the mover at its
|
||||
// fingerprint, so its build is asked with the newest pins (design 47 H2 H-A-763 (3)); else from the revision it is kept at.
|
||||
entries, rev := half.Entries, v.keptOf(p.Pipeline)[m.Module]
|
||||
if rev > 0 {
|
||||
if rev > 0 && (p.Run != "" || half.Entries[m.Module].Fp != m.Fingerprint) {
|
||||
var err error
|
||||
if entries, err = v.Starter.keptEntries(p.Branch, rev); err != nil {
|
||||
return nil, fmt.Errorf("revision %d of %s, which %s is kept at, is not read (%v): the step is asked when it is", rev, p.Branch, m.Module, err)
|
||||
|
||||
Reference in New Issue
Block a user