Builder: remove the setting republish-max-versions, which nothing reads since A-457a
Builds: design 47 G A-457a
This commit is contained in:
@@ -234,15 +234,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
acts := versions.Acts{Numberer: numberer, DropReserved: reserved.dropped, Reconsider: b.Reconsider}
|
||||
// A reserved version left unpublished is published again, by the builder on an event or by a person's tool (design 47 G
|
||||
// §588): its states publish-queue and acted, bound once the bus holds them.
|
||||
republishMax, err := republishMaxOf(getenv("MESH_BUILDER_REPUBLISH_MAX_FILE"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
queueKV := process.AwaitBucket(ctx, js, conn, own.queue, "no version is published again on an event or by builder_publish_again", logger.Printf)
|
||||
actedKV := process.AwaitBucket(ctx, js, conn, own.acted, "no version is published again on an event or by builder_publish_again", logger.Printf)
|
||||
republish := &versions.Republisher{Reserved: reserved.r, Queue: awaitedQueue{awaitedReserved{awaitedVersions{b: queueKV, bucket: own.queue}}},
|
||||
Entry: entryVia(calls.Call), Send: sendVia(calls.Call),
|
||||
Unreleased: reserved.unreleasedWords, Max: republishMax, Logf: logger.Printf,
|
||||
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
|
||||
Holders: holders} // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a)
|
||||
publishSet, err := publishSettingsOf(getenv)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,12 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
@@ -76,30 +71,6 @@ func publishBody(p versions.Publish) gopackageregistry.PublishInput {
|
||||
return gopackageregistry.PublishInput{Commit: p.Commit, Digest: p.Digest, Fingerprint: p.Fingerprint, Kind: p.Kind, Name: p.Name, Transfer: p.Transfer, Version: p.Version}
|
||||
}
|
||||
|
||||
// republishMaxOf reads the setting republish-max-versions from the file the manifest declares (design 47 G §633, A-71's
|
||||
// form): no file or an empty one is the default; a content that is no positive number is an error naming the file.
|
||||
func republishMaxOf(path string) (int, error) {
|
||||
if path == "" {
|
||||
return versions.DefaultRepublishMax, nil
|
||||
}
|
||||
raw, err := os.ReadFile(path)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return versions.DefaultRepublishMax, nil
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
v := strings.TrimSpace(string(raw))
|
||||
if v == "" {
|
||||
return versions.DefaultRepublishMax, nil
|
||||
}
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil || n < 1 {
|
||||
return 0, fmt.Errorf("%s holds %q, which is not a number of versions", path, v)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// republishing starts the publish again once both its states are bound: the queue is taken up again (design 47 G §588). A version's
|
||||
// publish is asked when its build ends and at the start (A-457a), never waited on a running or manifest-reads-changed.
|
||||
type republishing struct {
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -59,18 +57,6 @@ func TestRepublishSend(t *testing.T) {
|
||||
t.Errorf("%s: asked %q, error %v, want %q", name, asked, err, c.want)
|
||||
}
|
||||
}
|
||||
dir := t.TempDir()
|
||||
for content, want := range map[string]int{"": 50, "7": 7} {
|
||||
path := filepath.Join(dir, "max")
|
||||
_ = os.WriteFile(path, []byte(content), 0o600)
|
||||
if got, err := republishMaxOf(path); err != nil || got != want {
|
||||
t.Errorf("republishMaxOf(%q) = %d, %v, want %d", content, got, err, want)
|
||||
}
|
||||
}
|
||||
_ = os.WriteFile(filepath.Join(dir, "bad"), []byte("0"), 0o600)
|
||||
if _, err := republishMaxOf(filepath.Join(dir, "bad")); err == nil {
|
||||
t.Error("a setting of 0 is accepted")
|
||||
}
|
||||
if _, _, err := build.NewRepublish("", "0.1.3", "why", "me", versionsNow()); err == nil {
|
||||
t.Error("a version with no module is accepted")
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ const (
|
||||
ActedMiB = 1
|
||||
// PublishQueueTool is builder_publish_queue.
|
||||
PublishQueueTool = "builder_publish_queue"
|
||||
// DefaultRepublishMax is the setting republish-max-versions unless set (§633).
|
||||
DefaultRepublishMax = 50
|
||||
// QueueFull is what version-unreleased says of a version the queue's cap refused.
|
||||
QueueFull = "queue full"
|
||||
// NotStoredWords opens what a refused artifact is said as.
|
||||
@@ -110,10 +108,8 @@ type Republisher struct {
|
||||
Send func(ctx context.Context, p Publish) error
|
||||
// Unreleased says version-unreleased about a version with the holder's words.
|
||||
Unreleased func(ctx context.Context, v ReservedVersion, why string)
|
||||
// Max is the setting republish-max-versions: the most versions one event queues.
|
||||
Max int
|
||||
Now func() time.Time
|
||||
Logf func(string, ...any)
|
||||
Now func() time.Time
|
||||
Logf func(string, ...any)
|
||||
// Go starts the sending of a holder's queue; nil starts a goroutine.
|
||||
Go func(func())
|
||||
// Holders answers a registry seat's holders: the catalog's SeatHolders, the part's one holder function that its FollowSeat
|
||||
|
||||
@@ -33,11 +33,11 @@ type republishBed struct {
|
||||
holders map[string][]string
|
||||
}
|
||||
|
||||
func newRepublishBed(t *testing.T, max int) *republishBed {
|
||||
func newRepublishBed(t *testing.T) *republishBed {
|
||||
t.Helper()
|
||||
b := &republishBed{reserved: &reserveMem{mem: newMem()}, queue: &queueMem{reserveMem: &reserveMem{mem: newMem()}}, now: time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)}
|
||||
res := &Reserver{Store: b.reserved, Now: func() time.Time { return b.now }, ReleasedOf: func(context.Context, string) ([]string, error) { return nil, nil }}
|
||||
b.Republisher = &Republisher{Reserved: res, Queue: b.queue, Max: max, Now: func() time.Time { return b.now }, Go: func(f func()) { f() },
|
||||
b.Republisher = &Republisher{Reserved: res, Queue: b.queue, Now: func() time.Time { return b.now }, Go: func(f func()) { f() },
|
||||
Entry: func(_ context.Context, fp string) (meshcatalog.CatalogEntry, error) {
|
||||
if fp == "src2:holder" {
|
||||
return meshcatalog.CatalogEntry{Serves: []string{SeatArtifacts + ".publish", SeatArtifacts + ".versions"}}, nil
|
||||
@@ -86,7 +86,7 @@ func (b *republishBed) reserve(t *testing.T, module string) ReservedVersion {
|
||||
func TestRepublish(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
t.Run("a done build is published as a digest with no parts, to its seat's holder", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
v := b.reserve(t, "m")
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
if v.Fingerprint != "src2:m" {
|
||||
@@ -105,7 +105,7 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("an entry that cannot be read stops neither the other versions nor the drain", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
b.reserve(t, "m1")
|
||||
b.reserve(t, "m2") // newest: queued before m1's entry is met
|
||||
entry := b.Entry
|
||||
@@ -124,7 +124,7 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("an artifact no store holds is said once and not tried again", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
b.reserve(t, "m")
|
||||
b.refuse = "oci-artifact-registry's publish of m/prog: not stored: no blob sha256:aa"
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
@@ -135,7 +135,7 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("a refusal in other words is said each time", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
b.reserve(t, "m")
|
||||
b.refuse = "the holder is full"
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
@@ -146,7 +146,7 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("a queue past its cap says queue full", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
b.reserve(t, "m")
|
||||
b.queue.bytes = PublishQueueMiB << 20
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
@@ -156,7 +156,7 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
})
|
||||
t.Run("a restart sends the queued again, a begun one anew", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b := newRepublishBed(t)
|
||||
v := b.reserve(t, "m")
|
||||
raw, _ := json.Marshal(QueuedPublish{V: 1, Holder: "oci", Module: "m", Version: v.Version, Artifacts: map[string]string{"m:prog": "sha256:aa"}, Queued: b.now, Begun: true})
|
||||
if _, err := b.queue.Create(ctx, QueueKey("oci", "m", v.Version), raw); err != nil {
|
||||
@@ -169,7 +169,7 @@ func TestRepublish(t *testing.T) {
|
||||
t.Run("after a fresh start the tool queues at the seat's holder, no running heard", func(t *testing.T) {
|
||||
// Design 47 G A-416, A-416a: the holder is the one the seat-holders view names from the start, not one learnt from a
|
||||
// running heard since; a seat with no holder queues nothing.
|
||||
b := newRepublishBed(t, 1)
|
||||
b := newRepublishBed(t)
|
||||
b.reserve(t, "m1")
|
||||
b.reserve(t, "m2")
|
||||
if q, err := b.Republish(ctx, "", ""); err != nil || len(q) != 0 {
|
||||
|
||||
@@ -185,9 +185,9 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
|
||||
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
||||
}
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 6 || m.Config["republish-max-versions"].Default != float64(50) ||
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 5 ||
|
||||
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(8) {
|
||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, republish-max-versions of 50 and the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
||||
}
|
||||
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
||||
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
||||
@@ -240,7 +240,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
||||
t.Errorf("process = %v", p)
|
||||
}
|
||||
env, _ := p["env"].(map[string]any)
|
||||
if len(env) != 7 || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_REPUBLISH_MAX_FILE"] != "${dir:state}/republish-max-versions" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||
if len(env) != 6 || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
||||
}
|
||||
for k, v := range env {
|
||||
|
||||
@@ -147,14 +147,6 @@
|
||||
"trusted": false,
|
||||
"default": 60
|
||||
},
|
||||
"republish-max-versions": {
|
||||
"type": "number",
|
||||
"description": "kept for the module's setting file; no longer read: the publish is tried per version by the builder's publish items (design 47 G section 588, A-457a).",
|
||||
"minimum": 1,
|
||||
"maximum": 10000,
|
||||
"trusted": false,
|
||||
"default": 50
|
||||
},
|
||||
"publish-pause": {
|
||||
"type": "number",
|
||||
"description": "seconds before a version's second publish try, doubled per try up to publish-pause-max (design 47 G A-457a).",
|
||||
@@ -231,14 +223,6 @@
|
||||
"mode": "0600",
|
||||
"content": "${config:toolchain-wait-minutes}"
|
||||
},
|
||||
{
|
||||
"id": "republish-max",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/republish-max-versions",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:republish-max-versions}"
|
||||
},
|
||||
{
|
||||
"id": "publish-pause",
|
||||
"type": "file",
|
||||
@@ -285,7 +269,6 @@
|
||||
"env": {
|
||||
"MESH_BROKER_FILE": "${dir:state}/broker",
|
||||
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
||||
"MESH_BUILDER_REPUBLISH_MAX_FILE": "${dir:state}/republish-max-versions",
|
||||
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
||||
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
||||
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
||||
|
||||
Reference in New Issue
Block a user