diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go index 7fafd036..ce7458a1 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/named_test.go @@ -100,8 +100,8 @@ func TestTheTrunkIsTheDirectoriesTheForgeListsTrees(t *testing.T) { // 1900/AC3 switch { case row.wanted: heardPipelineWanted(context.Background(), ix, m, t.Logf) - if ix.wanted != "main.12" { - t.Errorf("%s: freed the releases below %q, want main.12", row.name, ix.wanted) + if ix.wanted != "main.12 tier-late" { + t.Errorf("%s: was handed %q, want main.12 tier-late", row.name, ix.wanted) } case row.ended: heardPipelineEnded(context.Background(), ix, m, t.Logf) @@ -164,8 +164,8 @@ func (f *fakeRuns) HeardPins(context.Context, *meshpipelinerunner.PipelineStarte return nil } -func (f *fakeRuns) HeardPipelineWanted(_ context.Context, branch string, source int64) error { - f.wanted = fmt.Sprintf("%s.%d", branch, source) +func (f *fakeRuns) HeardPipelineWanted(_ context.Context, branch string, source int64, outcome string) error { + f.wanted = fmt.Sprintf("%s.%d %s", branch, source, outcome) return f.err } diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/runs.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/runs.go index 033be1c4..fdbf67aa 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/runs.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/runs.go @@ -21,7 +21,7 @@ type runTaker interface { StartRun(ctx context.Context, e meshpipelinerunner.RunStarted) error EndRunPipeline(ctx context.Context, e meshpipelinerunner.PipelineEnded) error HeardPins(ctx context.Context, started *meshpipelinerunner.PipelineStarted, ended *meshpipelinerunner.PipelineEnded) error - HeardPipelineWanted(ctx context.Context, branch string, source int64) error + HeardPipelineWanted(ctx context.Context, branch string, source int64, outcome string) error JudgePins(ctx context.Context) } @@ -99,7 +99,7 @@ func heardPipelineWanted(ctx context.Context, ix runTaker, m delivered, logf fun _ = m.Term() return } - err := ix.HeardPipelineWanted(ctx, e.Branch, e.Source) + err := ix.HeardPipelineWanted(ctx, e.Branch, e.Source, e.Outcome) settleRun(m, err, "pipeline-wanted of "+e.Pipeline, logf) if err == nil { ix.JudgePins(ctx) diff --git a/modules/mesh-delivery-indexer/internal/index/pins.go b/modules/mesh-delivery-indexer/internal/index/pins.go index e9111d80..33816fa8 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins.go +++ b/modules/mesh-delivery-indexer/internal/index/pins.go @@ -14,6 +14,7 @@ import ( mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/keys" ) @@ -112,16 +113,21 @@ func ReleaseRecord(branch, module string) string { return "release." + keys.EscapeName(branch) + "." + keys.EscapeName(module) } -// HeardPipelineWanted applies one pipeline-wanted of the seat mesh-wants, said once when a pipeline's wants are written to the end, -// tier-late included (design 47 H §751, H-A-168, H-A-170, H-A-173): a module whose release record the pipeline's own kept -// revision holds released its newer version there, and that is the want everywhere, so the module's record is freed from -// every revision of the branch below it. A mover the revision holds no release of (superseded, no version released, a -// tier-late later tier) keeps its older release's revision. A pipeline whose revision is not kept frees nothing and says so; -// one applied twice changes nothing. -func (ix *Indexer) HeardPipelineWanted(ctx context.Context, branch string, source int64) error { +// HeardPipelineWanted applies one pipeline-wanted of the seat mesh-wants, said when a pipeline's wants are written to the end +// (design 47 H §751, H-A-168, H-A-170, H-A-173, H-A-174). Outcome running: a module whose release record the pipeline's own +// kept revision holds released its newer version there, and that is the want everywhere, so the module's record is freed from +// every revision of the branch below it; a mover the revision holds no release of (superseded, no version released) keeps its +// older release's revision. Outcome tier-late frees nothing: its later tiers' wants are not written, though their release +// records are held, and the same pipeline's later running frees them. A pipeline whose revision is not kept frees nothing and +// says so; one applied twice changes nothing. +func (ix *Indexer) HeardPipelineWanted(ctx context.Context, branch string, source int64, outcome string) error { if ix.Pins == nil || ix.Revisions == nil { return errors.New("the indexer keeps no state " + PinsState) } + if outcome != meshwants.PipelineWantedOutcomeRunning { + ix.logf("pins: pipeline-wanted of %s %d is %s: it frees no release until its wants are written everywhere (H-A-174)", branch, source, outcome) + return nil + } name, err := revisionOfSource(ctx, ix.Revisions, branch, source) if err != nil { ix.logf("pins: pipeline-wanted of %s %d frees no release: its revision is not kept: %v", branch, source, err) diff --git a/modules/mesh-delivery-indexer/internal/index/pins_test.go b/modules/mesh-delivery-indexer/internal/index/pins_test.go index 24ac07f4..4a255ebd 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pins_test.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" ) // Design 47 H §749 (G §579, A-169, A-171): the indexer pins a revision on a pipeline-started that names it and frees it on its @@ -94,7 +95,8 @@ func TestTheIndexerRemovesARevisionOnlyWhenNoRecordPinsItAndItIsNotCurrent(t *te } // H-A-168, H-A-170, H-A-173: a passed pipeline's release keeps its revision past a later failed pipeline; a passed one whose // mover released no version pins nothing and its pipeline-wanted frees nothing; the next one that released a version frees - // the older release on its pipeline-wanted (its wants written to the end), and the revision goes. + // the older release on its pipeline-wanted running (its wants written to the end), not on a tier-late one (H-A-174), and the + // revision goes. mover := []meshcatalog.TakeInEntry{{Module: "reader", Commit: "c", Fingerprint: "f", Repository: "novox/r"}} take := func(source int64) { t.Helper() @@ -113,9 +115,9 @@ func TestTheIndexerRemovesARevisionOnlyWhenNoRecordPinsItAndItIsNotCurrent(t *te } ix.JudgePins(ctx) } - wanted := func(source int64) { + wanted := func(source int64, outcome string) { t.Helper() - if err := ix.HeardPipelineWanted(ctx, "main", source); err != nil { + if err := ix.HeardPipelineWanted(ctx, "main", source, outcome); err != nil { t.Fatal(err) } ix.JudgePins(ctx) @@ -127,13 +129,15 @@ func TestTheIndexerRemovesARevisionOnlyWhenNoRecordPinsItAndItIsNotCurrent(t *te want("a passed release past a later failed pipeline", "main.10", "main.11") take(12) end(12, runner.PipelineEndedOutcomePassed, "") - wanted(12) + wanted(12, meshwants.PipelineWantedOutcomeRunning) want("a passed pipeline releasing no version frees no older release", "main.10", "main.12") take(13) end(13, runner.PipelineEndedOutcomePassed, "0.1.13") want("two releases, the unreleased one between them gone", "main.10", "main.13") - wanted(13) - wanted(13) // heard twice: changes nothing more + wanted(13, meshwants.PipelineWantedOutcomeTierLate) // H-A-174: its later tiers' wants are not written, so it frees nothing + want("a tier-late pipeline-wanted", "main.10", "main.13") + wanted(13, meshwants.PipelineWantedOutcomeRunning) + wanted(13, meshwants.PipelineWantedOutcomeRunning) // heard twice: changes nothing more want("the newer release written everywhere", "main.13") if v, _, _, _ := ix.Pins.Get(ctx, "main.13"); !slices.Equal(mustRecords(t, v), []string{ReleaseRecord("main", "reader")}) { t.Errorf("the pin of main.13 holds %s, want its release alone", v)