Catalog versions: a floor read is a kept call asked until it answers, one module at a time, and the indexer holds no timer
A-490i corrects A-490h: the growing-pause timer is gone (floorpause.go and the guard's exemption removed; ADR 0437 §8 stands). Each module's floor is read on its own (FloorModules, FillFloor); a read is a kept call through mesh-sdk's form, asked again at once when the form gives up, so it has no bound; the first unanswered try starts the module's clock and the finding call-unanswered is written five minutes later and cleared on answer. The integration test leaves the forge unserved until a delay, and the fill follows with no restart and no revision. Builds: design 47 G §412, A-490c, A-490d, A-490e, A-490f, A-490g, A-490h, A-490i Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -23,10 +23,10 @@ import (
|
||||
// seat git and the package holders stood in. A module of the trunk with a Go package and no version in `versions` stays unfilled
|
||||
// while the forge does not answer, and is filled from the highest of its tags and the holder's versions once the forge answers,
|
||||
// on the growing pause (5 s) with no restart and no catalog revision. The finding after five minutes is in the unit tests
|
||||
// (the five minutes are not waited for here).
|
||||
// (the five minutes are not waited for here); the kept call asks again by itself, with no restart and no new revision.
|
||||
func TestIndexerFillsTheFloorOfAModuleWithTags(t *testing.T) {
|
||||
const pkg = "git.novox.be/novox/mesh-delivery/modules/" + testIndexer
|
||||
var forgeUp atomic.Bool
|
||||
var serveTags func()
|
||||
var prefix atomic.Value
|
||||
js, ctx, _, _ := startIndexer(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) {
|
||||
for _, bucket := range []string{index.Bucket(testIndexer, index.VersionsState), index.Bucket(testIndexer, index.HeardState)} {
|
||||
@@ -58,16 +58,15 @@ func TestIndexerFillsTheFloorOfAModuleWithTags(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
serve("mesh.seat.git.tool.tags", func(m *nats.Msg) {
|
||||
var in git.TagsInput
|
||||
_ = json.Unmarshal(m.Data, &in)
|
||||
prefix.Store(in.Prefix)
|
||||
if !forgeUp.Load() {
|
||||
reply(m, map[string]any{"error": "the forge does not answer"})
|
||||
return
|
||||
}
|
||||
reply(m, map[string]any{"result": git.TagsAnswer{Repository: in.Repository, Tags: []string{in.Prefix + "0.4.2", in.Prefix + "0.4.10", "unrelated"}}})
|
||||
})
|
||||
// the forge answers no one until the test lets it (nobody serves the verb: a transport fault, which the kept call asks again)
|
||||
serveTags = func() {
|
||||
serve("mesh.seat.git.tool.tags", func(m *nats.Msg) {
|
||||
var in git.TagsInput
|
||||
_ = json.Unmarshal(m.Data, &in)
|
||||
prefix.Store(in.Prefix)
|
||||
reply(m, map[string]any{"result": git.TagsAnswer{Repository: in.Repository, Tags: []string{in.Prefix + "0.4.2", in.Prefix + "0.4.10", "unrelated"}}})
|
||||
})
|
||||
}
|
||||
// the package's name is read from the revision's own files (§676): its go.mod
|
||||
serve("mesh.seat.git.tool.file", func(m *nats.Msg) {
|
||||
var in git.FileInput
|
||||
@@ -90,7 +89,7 @@ func TestIndexerFillsTheFloorOfAModuleWithTags(t *testing.T) {
|
||||
if keys, _ := versions.Keys(ctx); len(keys) != 0 {
|
||||
t.Fatalf("versions holds %v while the forge does not answer, want nothing", keys)
|
||||
}
|
||||
forgeUp.Store(true)
|
||||
serveTags()
|
||||
var got []string
|
||||
for deadline := time.Now().Add(30 * time.Second); time.Now().Before(deadline); time.Sleep(100 * time.Millisecond) {
|
||||
if got, _ = versions.Keys(ctx); len(got) > 0 {
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"mesh-delivery-indexer/internal/index"
|
||||
)
|
||||
|
||||
// Design 47 G A-490h (as A-487a's backoff): an unanswered floor read is asked again on a growing pause, 5 s, 15 s, 30 s, 1, 2 and
|
||||
// then 5 minutes (never past the alarm five minutes after the first), until it answers; an answer starts the pauses again.
|
||||
func TestAnUnansweredFloorReadIsAskedAgainOnAGrowingPause(t *testing.T) {
|
||||
var pauses []time.Duration
|
||||
var next func()
|
||||
f := &versionsFill{ix: &index.Indexer{}, ctx: context.Background(), logf: func(string, ...any) {},
|
||||
floor: index.FloorSources{Tags: func(context.Context, string, string) ([]string, error) { return nil, nil }},
|
||||
after: func(d time.Duration, fn func()) func() bool {
|
||||
pauses = append(pauses, d)
|
||||
next = fn
|
||||
return func() bool { return true }
|
||||
}}
|
||||
f.run() // the indexer keeps no catalog graph: the floor read fails as an unanswered one does
|
||||
for i := 0; i < 6 && next != nil; i++ {
|
||||
fn := next
|
||||
next = nil
|
||||
fn()
|
||||
}
|
||||
want := []time.Duration{5 * time.Second, 15 * time.Second, 30 * time.Second, time.Minute, 2 * time.Minute}
|
||||
if len(pauses) != 7 {
|
||||
t.Fatalf("the pauses %v, want 7 asks again", pauses)
|
||||
}
|
||||
for i, d := range want {
|
||||
if pauses[i] != d {
|
||||
t.Errorf("pause %d is %v, want %v", i, pauses[i], d)
|
||||
}
|
||||
}
|
||||
for _, d := range pauses[5:] {
|
||||
if d > 5*time.Minute || d < 4*time.Minute {
|
||||
t.Errorf("a late pause is %v, want the 5-minute pause clamped to the alarm's time", d)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
// afterPause runs f once after d: the pause between two asks of an unanswered floor read (design 47 G A-490h, as A-487a has a
|
||||
// node-engine ask again after a growing pause). It is the indexer's one timer, kept in this file alone: the guard
|
||||
// TestServesNoRequestSubjectAndHoldsNoTicker (ADR 0437 §8) names it.
|
||||
func afterPause(d time.Duration, f func()) (stop func() bool) { return time.AfterFunc(d, f).Stop }
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
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/git"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
@@ -194,76 +192,41 @@ func versionsVia(call openCaller, inView func(ctx context.Context, module string
|
||||
// versionsFill is the first fill of the versions in the background (design 47 G §372): started at the start and at each
|
||||
// catalog revision kept, until it is made; one runs at a time, and a fill that fails is said and made again at the next.
|
||||
type versionsFill struct {
|
||||
ix *index.Indexer
|
||||
ctx context.Context
|
||||
ask index.VersionsAsker
|
||||
floor index.FloorSources // what the floor reads (A-490g); a nil reader fills none
|
||||
logf func(string, ...any)
|
||||
pauses []time.Duration // the growing pauses between asks of an unanswered floor read; nil is floorPauses
|
||||
after func(d time.Duration, f func()) (stop func() bool) // the timer (afterPause) unless a test sets it
|
||||
|
||||
mu sync.Mutex
|
||||
retry int // how many unanswered floor reads in a row
|
||||
since time.Time // when the first of them was asked
|
||||
pending func() bool
|
||||
ix *index.Indexer
|
||||
ctx context.Context
|
||||
ask index.VersionsAsker
|
||||
floor index.FloorSources // what the floor reads (A-490g); a nil reader fills none
|
||||
logf func(string, ...any)
|
||||
}
|
||||
|
||||
// floorPauses are the pauses between asks of an unanswered floor read (A-490h), as a node-engine asks a missing trunk build again
|
||||
// (A-487a): 5 s, 15 s, 30 s, 1, 2 and then 5 minutes; the first answer starts them again.
|
||||
var floorPauses = []time.Duration{5 * time.Second, 15 * time.Second, 30 * time.Second, time.Minute, 2 * time.Minute, 5 * time.Minute}
|
||||
|
||||
func (f *versionsFill) kick() {
|
||||
go func() {
|
||||
if err := f.ix.FillVersions(f.ctx, f.ask); err != nil {
|
||||
f.logf("versions: the first fill waits: %v", err)
|
||||
}
|
||||
}()
|
||||
go f.run()
|
||||
go f.fillFloors()
|
||||
}
|
||||
|
||||
// run makes the floor, not waiting for the builder's half: a builder_versions unanswered holds that half for its bound, and the
|
||||
// floor's own reads answer by themselves.
|
||||
func (f *versionsFill) run() {
|
||||
// The floor, per module the versions hold none of, at every start and every revision and again on a growing pause while a
|
||||
// read is unanswered (A-490d, A-490f, A-490h): the builder's half is done once; this half is not.
|
||||
// fillFloors fills the floor of each module the versions hold none of, each on its own so that one unanswered read holds no other
|
||||
// module's (A-490d, A-490f, A-490i): at every start and every revision, not waiting for the builder's half. A read is a kept call
|
||||
// asked again until it answers, and the indexer holds no timer of its own (ADR 0437 §8).
|
||||
func (f *versionsFill) fillFloors() {
|
||||
if f.floor.Tags == nil && f.floor.Holder == nil {
|
||||
return
|
||||
}
|
||||
err := f.ix.FillTagFloors(f.ctx, f.floor)
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
if err == nil {
|
||||
f.retry, f.since = 0, time.Time{}
|
||||
modules, err := f.ix.FloorModules(f.ctx)
|
||||
if err != nil {
|
||||
f.logf("versions: the floor waits: %v", err)
|
||||
return
|
||||
}
|
||||
f.logf("versions: the floor waits: %v", err)
|
||||
if f.pending != nil || f.ctx.Err() != nil {
|
||||
return // an ask again is set already
|
||||
for _, m := range modules {
|
||||
go func() {
|
||||
if err := f.ix.FillFloor(f.ctx, m, f.floor); err != nil {
|
||||
f.logf("versions: the floor of %s waits for the next start or revision: %v", m, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
pauses := floorPauses
|
||||
if f.pauses != nil {
|
||||
pauses = f.pauses
|
||||
}
|
||||
pause := pauses[min(f.retry, len(pauses)-1)]
|
||||
f.retry++
|
||||
now := time.Now()
|
||||
if f.since.IsZero() {
|
||||
f.since = now
|
||||
}
|
||||
// the alarm is five minutes after the first unanswered read: never pause past it before it is raised
|
||||
if left := f.since.Add(mcc.CallUnansweredAfter).Sub(now); left > 0 && pause > left {
|
||||
pause = left
|
||||
}
|
||||
after := f.after
|
||||
if after == nil {
|
||||
after = afterPause
|
||||
}
|
||||
f.pending = after(pause, func() {
|
||||
f.mu.Lock()
|
||||
f.pending = nil
|
||||
f.mu.Unlock()
|
||||
f.run()
|
||||
})
|
||||
}
|
||||
|
||||
// afterRevision runs the fill's kick after each catalog revision kept, once the fill is set.
|
||||
|
||||
@@ -174,7 +174,7 @@ type Indexer struct {
|
||||
previews map[string]meshdeliverychecker.PreviewsByRepositoryHeadTrunkValue // by previews key (previews.go)
|
||||
toolchains map[string]map[string]nodebuildgo.Toolchain // language, then node (toolchains.go)
|
||||
buildModules map[string]BuildModule // by language: the build modules whose toolchains are taken in (buildmodules.go)
|
||||
tagFilling atomic.Bool // a FillTagFloors runs (tag_floor.go): one at a time
|
||||
floors sync.Map // the modules whose floor FillFloor reads now (tag_floor.go), one fill each
|
||||
versionsFilling atomic.Bool // a FillVersions runs (versions_fill.go)
|
||||
stepsSince map[string]time.Time // by build seat: since when its steps is unanswered (seed_steps.go)
|
||||
tried map[string]bool // repository, commit and directory a registered module's manifest was tried at (registered.go)
|
||||
|
||||
@@ -5,11 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
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"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
)
|
||||
|
||||
@@ -24,8 +26,6 @@ import (
|
||||
// unanswered five minutes after the first (A-490h).
|
||||
const FloorCall = "mesh-catalog.versions-floor"
|
||||
|
||||
var floorSince = "call-since." + keys.EscapeName(FloorCall)
|
||||
|
||||
// TagsReader reads every tag of a repository that starts with prefix, all pages (the seat git's verb tags).
|
||||
type TagsReader func(ctx context.Context, repository, prefix string) ([]string, error)
|
||||
|
||||
@@ -59,106 +59,157 @@ func tagPrefixOf(repository string, a meshcatalog.Artifact) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// FillTagFloors fills the version of every module of the newest trunk revision that holds none from the highest version its
|
||||
// packages have (A-490g). A read the forge or a holder does not answer fills no module and is returned: the finding
|
||||
// call-unanswered is written five minutes after the first unanswered read and cleared when a read answers (A-490h); the
|
||||
// caller asks again on a growing pause. The floor entry holds no artifact and no digest (A-351), so the builder numbers
|
||||
// above it and a package-published heard later at its version is recorded as its release.
|
||||
func (ix *Indexer) FillTagFloors(ctx context.Context, src FloorSources) error {
|
||||
// FloorModules are the modules of the newest trunk revision the versions hold none of and that name a package a floor can be read
|
||||
// of; each is filled by its own FillFloor, so one unanswered read holds no other module's floor (A-490i).
|
||||
func (ix *Indexer) FloorModules(ctx context.Context) ([]string, error) {
|
||||
if ix.Versions == nil || ix.Revisions == nil {
|
||||
return errors.New("the state versions or the catalog graph is not kept here")
|
||||
return nil, errors.New("the state versions or the catalog graph is not kept here")
|
||||
}
|
||||
if !ix.tagFilling.CompareAndSwap(false, true) {
|
||||
_, entries, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, errors.New("the indexer keeps no trunk revision yet: the floor waits for its first")
|
||||
}
|
||||
var out []string
|
||||
for _, e := range entries {
|
||||
if !slices.ContainsFunc(e.Artifacts, func(a meshcatalog.Artifact) bool {
|
||||
return a.Package != nil && (a.Package.Ecosystem == EcosystemGo || a.Package.Ecosystem == EcosystemNpm)
|
||||
}) {
|
||||
continue
|
||||
}
|
||||
if have, err := ModuleVersions(ctx, ix.Versions, e.Module); err != nil {
|
||||
return nil, err
|
||||
} else if len(have) == 0 {
|
||||
out = append(out, e.Module)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// FillFloor fills one module's floor, the highest version among its packages' tags and holders' versions (A-490g). Its reads are
|
||||
// kept calls made through mesh-sdk's form, which asks again through every transport fault; a read it gives up on (its own
|
||||
// pause spent) is asked again at once, never given up, so the read has no bound (A-490i). The first unanswered try starts the
|
||||
// module's clock: five minutes later the finding call-unanswered is written, and cleared when a read answers. A read the
|
||||
// callee answered with a failure ends the fill, left for the next start or revision. One fill of a module runs at a time.
|
||||
func (ix *Indexer) FillFloor(ctx context.Context, module string, src FloorSources) error {
|
||||
if _, running := ix.floors.LoadOrStore(module, true); running {
|
||||
return nil
|
||||
}
|
||||
defer ix.tagFilling.Store(false)
|
||||
defer ix.floors.Delete(module)
|
||||
for ctx.Err() == nil {
|
||||
entry, found, err := ix.newestEntry(ctx, module)
|
||||
if err != nil || !found {
|
||||
return err
|
||||
}
|
||||
if have, err := ModuleVersions(ctx, ix.Versions, module); err != nil || len(have) > 0 {
|
||||
return err
|
||||
}
|
||||
top, err := ix.floorOf(ctx, entry, src)
|
||||
if err == nil {
|
||||
ix.floorAnswered(ctx, module)
|
||||
return ix.keepFloor(ctx, module, top)
|
||||
}
|
||||
if !busretry.Undelivered(err) && !busretry.TimedOut(err) {
|
||||
return err
|
||||
}
|
||||
ix.floorUnanswered(ctx, module, err)
|
||||
}
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func (ix *Indexer) newestEntry(ctx context.Context, module string) (meshcatalog.CatalogEntry, bool, error) {
|
||||
_, entries, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
|
||||
if err != nil || !found {
|
||||
return meshcatalog.CatalogEntry{}, false, err
|
||||
}
|
||||
for _, e := range entries {
|
||||
if e.Module == module {
|
||||
return e, true, nil
|
||||
}
|
||||
}
|
||||
return meshcatalog.CatalogEntry{}, false, nil
|
||||
}
|
||||
|
||||
// floorOf reads the highest version of the entry's packages; "" when none is held.
|
||||
func (ix *Indexer) floorOf(ctx context.Context, e meshcatalog.CatalogEntry, src FloorSources) (string, error) {
|
||||
top := ""
|
||||
take := func(vs []string, prefix string) {
|
||||
for _, t := range vs {
|
||||
if !strings.HasPrefix(t, prefix) {
|
||||
continue
|
||||
}
|
||||
if v := strings.TrimPrefix(t, prefix); versionOK(v) && (top == "" || compareVersions(v, top) > 0) {
|
||||
top = v
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, a := range e.Artifacts {
|
||||
if a.Package == nil {
|
||||
continue
|
||||
}
|
||||
if prefix, ok := tagPrefixOf(e.Repository, a); ok && src.Tags != nil {
|
||||
tags, err := src.Tags(ctx, e.Repository, prefix)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("the tags of %s: %w", e.Repository, err)
|
||||
}
|
||||
take(tags, prefix)
|
||||
}
|
||||
if (a.Package.Ecosystem == EcosystemGo || a.Package.Ecosystem == EcosystemNpm) && src.Holder != nil {
|
||||
vs, err := src.Holder(ctx, a.Package.Ecosystem, a.Package.Name)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("the versions of %s %s: %w", a.Package.Ecosystem, a.Package.Name, err)
|
||||
}
|
||||
take(vs, "")
|
||||
}
|
||||
}
|
||||
return top, nil
|
||||
}
|
||||
|
||||
func (ix *Indexer) keepFloor(ctx context.Context, module, top string) error {
|
||||
if top == "" {
|
||||
return nil
|
||||
}
|
||||
now := ix.now().UTC()
|
||||
data, err := json.Marshal(meshcatalog.VersionEntry{V: int64(keys.Version), Module: module, Version: top, At: &now})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !found {
|
||||
return errors.New("the indexer keeps no trunk revision yet: the floor waits for its first")
|
||||
}
|
||||
var unanswered error
|
||||
for _, e := range entries {
|
||||
have, err := ModuleVersions(ctx, ix.Versions, e.Module)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(have) > 0 {
|
||||
continue
|
||||
}
|
||||
top := ""
|
||||
take := func(vs []string, prefix string) {
|
||||
for _, t := range vs {
|
||||
if !strings.HasPrefix(t, prefix) {
|
||||
continue
|
||||
}
|
||||
if v := strings.TrimPrefix(t, prefix); versionOK(v) && (top == "" || compareVersions(v, top) > 0) {
|
||||
top = v
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, a := range e.Artifacts {
|
||||
if a.Package == nil {
|
||||
continue
|
||||
}
|
||||
if prefix, ok := tagPrefixOf(e.Repository, a); ok && src.Tags != nil {
|
||||
tags, err := src.Tags(ctx, e.Repository, prefix)
|
||||
if err != nil {
|
||||
unanswered = fmt.Errorf("the tags of %s: %w", e.Repository, err)
|
||||
break
|
||||
}
|
||||
take(tags, prefix)
|
||||
}
|
||||
if (a.Package.Ecosystem == EcosystemGo || a.Package.Ecosystem == EcosystemNpm) && src.Holder != nil {
|
||||
vs, err := src.Holder(ctx, a.Package.Ecosystem, a.Package.Name)
|
||||
if err != nil {
|
||||
unanswered = fmt.Errorf("the versions of %s %s: %w", a.Package.Ecosystem, a.Package.Name, err)
|
||||
break
|
||||
}
|
||||
take(vs, "")
|
||||
}
|
||||
}
|
||||
if unanswered != nil {
|
||||
break
|
||||
}
|
||||
if top == "" {
|
||||
continue
|
||||
}
|
||||
now := ix.now().UTC()
|
||||
data, err := json.Marshal(meshcatalog.VersionEntry{V: int64(keys.Version), Module: e.Module, Version: top, At: &now})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ix.Versions.Create(ctx, meshcatalog.VersionsByModuleVersionKey(e.Module, top), data); err != nil && !errors.Is(err, ErrConflict) {
|
||||
return fmt.Errorf("the floor %s %s is not kept: %w", e.Module, top, err)
|
||||
}
|
||||
ix.logf("versions: %s has none, filled with %s, the highest of its packages' tags and holders' versions", e.Module, top)
|
||||
}
|
||||
if unanswered != nil {
|
||||
now := ix.now()
|
||||
since := ix.unansweredSince(ctx, floorSince, now)
|
||||
if ix.Findings != nil && now.Sub(since) >= mcc.CallUnansweredAfter {
|
||||
at := since.UTC().Format(time.RFC3339)
|
||||
f := ix.observed(mcc.ScopeCall, FloorCall, mcc.KindCallUnanswered,
|
||||
fmt.Sprintf("the floor of the catalog's versions is unanswered since %s", at),
|
||||
"A call whose answer is kept is not answered",
|
||||
fmt.Sprintf("The floor of the catalog's versions reads the forge's tags and the package holders' versions; a read is not answered since %s (%v), so a module with none is not filled.", at, unanswered),
|
||||
"indexer."+mcc.KindCallUnanswered)
|
||||
if err := ix.Findings.Write(ctx, f); err != nil {
|
||||
ix.logf("floor: the finding %s is not written: %v", FloorCall, err)
|
||||
}
|
||||
}
|
||||
return unanswered
|
||||
}
|
||||
ix.answered(ctx, floorSince)
|
||||
if ix.Findings != nil {
|
||||
if err := ix.clearFinding(ctx, mcc.ScopeCall, FloorCall, mcc.KindCallUnanswered, "the floor's reads answer"); err != nil {
|
||||
ix.logf("floor: the finding %s is not cleared: %v", FloorCall, err)
|
||||
}
|
||||
if err := ix.Versions.Create(ctx, meshcatalog.VersionsByModuleVersionKey(module, top), data); err != nil && !errors.Is(err, ErrConflict) {
|
||||
return fmt.Errorf("the floor %s %s is not kept: %w", module, top, err)
|
||||
}
|
||||
ix.logf("versions: %s has none, filled with %s, the highest of its packages' tags and holders' versions", module, top)
|
||||
return nil
|
||||
}
|
||||
|
||||
func floorKey(module string) string { return FloorCall + "." + module }
|
||||
|
||||
// floorUnanswered writes call-unanswered once the module's floor read is unanswered five minutes (the time kept in the own state).
|
||||
func (ix *Indexer) floorUnanswered(ctx context.Context, module string, cause error) {
|
||||
now := ix.now()
|
||||
since := ix.unansweredSince(ctx, "call-since."+keys.EscapeName(floorKey(module)), now)
|
||||
if ix.Findings == nil || now.Sub(since) < mcc.CallUnansweredAfter {
|
||||
return
|
||||
}
|
||||
at := since.UTC().Format(time.RFC3339)
|
||||
f := ix.observed(mcc.ScopeCall, floorKey(module), mcc.KindCallUnanswered,
|
||||
fmt.Sprintf("the floor of %s's versions is unanswered since %s", module, at),
|
||||
"A call whose answer is kept is not answered",
|
||||
fmt.Sprintf("The floor of %s's versions reads the forge's tags and the package holders' versions; a read is not answered since %s (%v), so it has no version.", module, at, cause),
|
||||
"indexer."+mcc.KindCallUnanswered)
|
||||
if err := ix.Findings.Write(ctx, f); err != nil {
|
||||
ix.logf("floor: the finding %s is not written: %v", floorKey(module), err)
|
||||
}
|
||||
}
|
||||
|
||||
func (ix *Indexer) floorAnswered(ctx context.Context, module string) {
|
||||
ix.answered(ctx, "call-since."+keys.EscapeName(floorKey(module)))
|
||||
if ix.Findings != nil {
|
||||
if err := ix.clearFinding(ctx, mcc.ScopeCall, floorKey(module), mcc.KindCallUnanswered, "the floor's reads answer"); err != nil {
|
||||
ix.logf("floor: the finding %s is not cleared: %v", floorKey(module), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func versionOK(v string) bool { _, ok := versionParts(v); return ok }
|
||||
|
||||
@@ -562,47 +562,49 @@ func TestTheTagFloorFillsAModuleWithNoVersionFromItsGoTags(t *testing.T) {
|
||||
if err := ix.Versions.Create(ctx, meshcatalog.VersionsByModuleVersionKey("held", "0.2.0"), []byte(`{"v":1,"module":"held","version":"0.2.0"}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
up := false
|
||||
tries := 0
|
||||
var asked []string
|
||||
read := func(_ context.Context, repo, prefix string) ([]string, error) {
|
||||
asked = append(asked, repo+" "+prefix)
|
||||
if !up {
|
||||
return nil, errors.New("no responders")
|
||||
}
|
||||
switch repo + " " + prefix {
|
||||
case "novox/mesh-sdk go/v":
|
||||
if repo == "novox/mesh-sdk" {
|
||||
// the forge does not answer the sdk's tags for six minutes, a minute at a time: the fill asks again, never gives up
|
||||
tries++
|
||||
now = now.Add(time.Minute)
|
||||
if tries == 5 && len(w.Held()) != 0 {
|
||||
t.Error("the finding is written before five minutes from the first unanswered try")
|
||||
}
|
||||
if tries <= 6 {
|
||||
return nil, errors.New("no responders available for request")
|
||||
}
|
||||
if len(w.Held()) != 1 || w.Held()[0].ID != FloorCall+".mesh-sdk" {
|
||||
t.Errorf("the findings after six minutes: %+v", w.Held())
|
||||
}
|
||||
return []string{"go/v0.1.9", "go/v0.1.16", "go/v0.1.12", "go/vnext"}, nil
|
||||
case "novox/root v":
|
||||
}
|
||||
if repo == "novox/root" {
|
||||
return []string{"v1.2.3", "vendor-x"}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
holder := func(_ context.Context, eco, name string) ([]string, error) {
|
||||
if !up {
|
||||
return nil, errors.New("no responders")
|
||||
}
|
||||
if eco == "npm" && name == "@novox/mesh-sdk" {
|
||||
return []string{"0.1.18", "0.1.17"}, nil // A-490g: the npm holder is above the Go tags
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
src := FloorSources{Tags: read, Holder: holder}
|
||||
if err := ix.FillTagFloors(ctx, src); err == nil {
|
||||
t.Fatal("tags not answered filled")
|
||||
modules, err := ix.FloorModules(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(w.Held()) != 0 {
|
||||
t.Fatal("a call unanswered for no time wrote its finding")
|
||||
if !slices.Equal(modules, []string{"mesh-sdk", "root"}) {
|
||||
t.Fatalf("the modules with a floor to read: %v (held has a version, image no package)", modules)
|
||||
}
|
||||
now = now.Add(5 * time.Minute)
|
||||
_ = ix.FillTagFloors(ctx, src)
|
||||
if h := w.Held(); len(h) != 1 || h[0].ID != FloorCall {
|
||||
t.Fatalf("the findings after five minutes: %+v", h)
|
||||
// each module's floor is read on its own: root is filled whatever the sdk's read waits for
|
||||
if err := ix.FillFloor(ctx, "root", src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, _ := ModuleVersions(ctx, ix.Versions, "mesh-sdk"); len(v) != 0 {
|
||||
t.Fatalf("filled while the forge was down: %+v", v)
|
||||
}
|
||||
up = true
|
||||
if err := ix.FillTagFloors(ctx, src); err != nil {
|
||||
if err := ix.FillFloor(ctx, "mesh-sdk", src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(w.Held()) != 0 {
|
||||
@@ -645,7 +647,7 @@ func TestAFloorEntryIsReplacedByThePublishHeardAtItsVersion(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
src := FloorSources{Tags: func(context.Context, string, string) ([]string, error) { return []string{"v0.3.0"}, nil }}
|
||||
if err := ix.FillTagFloors(ctx, src); err != nil {
|
||||
if err := ix.FillFloor(ctx, "mod", src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ix.HearPackagePublished(ctx, meshbuilds.PackagePublished{Module: "mod", Artifact: "mod:go", Version: "0.3.0", Digest: "sha256:aa", Branch: "main", Source: 5}); err != nil {
|
||||
|
||||
@@ -393,10 +393,6 @@ func TestServesNoRequestSubjectAndHoldsNoTicker(t *testing.T) { // 1238/AC9 (ADR
|
||||
if f == "Subscribe(" && strings.HasSuffix(path, "seatlist.go") {
|
||||
continue
|
||||
}
|
||||
// The one timer is the growing pause of an unanswered floor read (A-490h), in floorpause.go.
|
||||
if f == "time.AfterFunc" && strings.HasSuffix(path, "floorpause.go") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(string(src), f) {
|
||||
t.Errorf("%s holds %s: the indexer serves no request subject and holds no timer", path, f)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user