BL11: a build whose published packages cannot be read is refused, naming the unread state
Taken from f051de32 (the old numbering's refusal); the tests of D-B2 to D-B6 it sat on are left out. Builds: design 47 G §55 (and its check line §56, test 70) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -99,6 +99,10 @@ func (b *Builder) number(ctx context.Context, module string, m meshcatalog.Modul
|
||||
b.logf("%s at %s: %v", module, m.Fp2, fmt.Errorf("not numbered, the versions cannot be used: %w", err))
|
||||
return versions.Numbering{}, true
|
||||
}
|
||||
if got.Refused != "" {
|
||||
b.logf("%s at %s: %s", module, m.Fp2, got.Refused)
|
||||
return got, true
|
||||
}
|
||||
if got.Wait != "" {
|
||||
b.logf("%s at %s is not built yet: %s", module, m.Fp2, got.Wait)
|
||||
return got, false
|
||||
|
||||
@@ -539,7 +539,11 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
||||
reserved, hasReserved = b.reserve(ctx, module, m, plan)
|
||||
}
|
||||
var result builds.BuilderBuild
|
||||
if nothing {
|
||||
if numbering.Refused != "" && cl.Build.State != builds.BuildDone {
|
||||
// Refused, naming the state it could not read, and built against no guess (ADR 0666 §15; design 47, test 70): the key
|
||||
// fails with why, and is taken again at the next look.
|
||||
result = failed("%s", numbering.Refused)
|
||||
} else if nothing {
|
||||
// A manifest with no artifact is built by building nothing: its key is done with no artifact, claimed and written as
|
||||
// any other, so the controller has a done key to register it from (issue 1613, ADR 0478 clause 1, ADR 0501 clause 1).
|
||||
result = builds.BuilderBuild{State: builds.BuildDone, Step: "nothing to build: the manifest names no artifact"}
|
||||
|
||||
@@ -495,6 +495,16 @@ func TestATrunkImageCallCarriesPublish(t *testing.T) { // 1705b; design 51 *The
|
||||
if nums.numbered != looks+1 {
|
||||
t.Errorf("a module the builder does not know was looked at")
|
||||
}
|
||||
// D-B5 (ADR 0666 §15; design 47, test 70): a build whose published packages cannot be read is refused, naming the
|
||||
// state: its key fails with why, and nothing is built.
|
||||
unread := newRig(t, imageArt)
|
||||
unread.puller = "ace"
|
||||
unread.b.Numbers = &fakeNumbers{refused: "m/img: refused: the builder's state versions (bucket mesh-delivery-builder_versions) cannot be read"}
|
||||
unread.b.Module(context.Background(), "m", moduleValue(t, "modules/m"))
|
||||
unread.b.Wait()
|
||||
if v := valueOf(t, unread.st, unread.key); v.State != builds.BuildFailed || !strings.Contains(v.Error, "state versions") || len(unread.bm.callsOf("build_image_build")) != 0 {
|
||||
t.Errorf("a build with its versions unread: key %+v, %d builds; want failed naming the state, none built", v, len(unread.bm.callsOf("build_image_build")))
|
||||
}
|
||||
}
|
||||
|
||||
// fakeNumbers is Numbers that answers what it is set to and keeps the digests a done build recorded.
|
||||
@@ -505,13 +515,14 @@ type fakeNumbers struct {
|
||||
built map[string]string
|
||||
tags []string
|
||||
done map[string]string // the done key's digests the last look numbered with
|
||||
refused string // answered as Numbering.Refused
|
||||
}
|
||||
|
||||
func (f *fakeNumbers) Number(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, tag string, done map[string]string) (versions.Numbering, error) {
|
||||
f.tags = append(f.tags, tag)
|
||||
f.done = done
|
||||
f.numbered++
|
||||
return versions.Numbering{Wait: f.wait, Versions: f.versions}, nil
|
||||
return versions.Numbering{Wait: f.wait, Versions: f.versions, Refused: f.refused}, nil
|
||||
}
|
||||
|
||||
func (f *fakeNumbers) Built(_ context.Context, _ string, _ meshcatalog.ModulesByModuleValue, _ Plan, got versions.Numbering, made []builds.BuiltArtifact) error {
|
||||
|
||||
@@ -91,6 +91,9 @@ type Numbering struct {
|
||||
// Names are the names each numbered artifact was numbered under, by artifact (NameOf, or a package's name in its
|
||||
// ecosystem).
|
||||
Names map[string]string
|
||||
// Refused is why the build is refused: a package's published versions could not be read (ADR 0666 §15). Nothing else
|
||||
// is numbered.
|
||||
Refused string
|
||||
}
|
||||
|
||||
// NameOf is the name artifact of module was numbered under in this numbering.
|
||||
@@ -177,6 +180,12 @@ func (n *Numberer) Number(ctx context.Context, c BuildClaim) (Numbering, error)
|
||||
}
|
||||
out.Names[a.Artifact] = name
|
||||
entries, err := n.Versions.Of(ctx, name)
|
||||
if err != nil && kind == KindPackage {
|
||||
// A build that cannot read the published packages refuses, naming the unread state, never building against a
|
||||
// guess (ADR 0666 §15; design 51 *The versions*, line 287).
|
||||
out.Refused = fmt.Sprintf("%s: refused: the builder's state %s (bucket %s) cannot be read, so its published versions are not known: %v", name, State, Bucket, err)
|
||||
return out, nil
|
||||
}
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type mem struct {
|
||||
revs map[string]uint64
|
||||
rev uint64
|
||||
before func()
|
||||
down error // answered by KeysOf: a state that cannot be read
|
||||
}
|
||||
|
||||
func newMem() *mem { return &mem{vals: map[string][]byte{}, revs: map[string]uint64{}} }
|
||||
@@ -63,6 +64,9 @@ func (m *mem) Update(_ context.Context, key string, value []byte, revision uint6
|
||||
func (m *mem) KeysOf(_ context.Context, filter string) ([]string, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if m.down != nil {
|
||||
return nil, m.down
|
||||
}
|
||||
prefix := strings.TrimSuffix(filter, "*")
|
||||
var out []string
|
||||
for k := range m.vals {
|
||||
@@ -472,6 +476,17 @@ func TestTheBuildersVersions(t *testing.T) {
|
||||
if _, err := n.Heard(ctx, SeatArtifacts, HeardPublished, "e4", Outcome{Name: "m/none", Version: "0.1.0"}); err == nil {
|
||||
t.Fatal("a published of a version the builder never numbered is not said")
|
||||
}
|
||||
// D-B5 (ADR 0666 §15, design 51 *The versions* line 287): a package's build whose published versions cannot be read
|
||||
// is refused, naming the state; a bundle's is built as before (ADR 0617 §1), the error said.
|
||||
st := n.Versions.Store.(*mem)
|
||||
st.down = errors.New("nats: no responders available for request")
|
||||
if got, err := n.Number(ctx, pkg); err != nil || !strings.Contains(got.Refused, "state versions (bucket mesh-delivery-builder_versions) cannot be read") || len(got.Versions) != 0 {
|
||||
t.Errorf("a package with its versions unread = %+v, %v; want refused naming the state", got, err)
|
||||
}
|
||||
if got, err := n.Number(ctx, c); err == nil || got.Refused != "" {
|
||||
t.Errorf("a bundle with its versions unread = %+v, %v; want the error, no refusal", got, err)
|
||||
}
|
||||
st.down = nil
|
||||
})
|
||||
t.Run("a package is numbered under its name in its ecosystem", func(t *testing.T) {
|
||||
// design 32: the indexer's packages state names, in each series key, the package's name and the <module>/<artifact>
|
||||
|
||||
Reference in New Issue
Block a user