Builder: a version's publish is a publish item of the re-ask state, tried with a growing pause until its release (A-457a)
Asked when the build ends and at the start, deleted by the release, ended loudly after publish-tries tries and readable in builder_publish_queue; settings publish-pause, publish-pause-max, publish-tries. The publish no longer waits on running or manifest-reads-changed. Builds: design 47 G A-457, A-457a, §588
This commit is contained in:
@@ -434,7 +434,7 @@ func main() {
|
||||
Newest: newestVia(stdio.Ask), Steps: r}))
|
||||
tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
qs, as := stdio.State(versions.PublishQueueState), stdio.State(versions.ActedState)
|
||||
tools = append(tools, republishTools(readerOf(qs), readerOf(as), buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
tools = append(tools, republishTools(readerOf(qs), readerOf(as), readerOf(reasks), buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||
ws := stdio.State(build.WaitsState)
|
||||
wr := versions.Reader{Keys: ws.Keys, Get: func(key string) (json.RawMessage, bool, error) {
|
||||
e, err := ws.Get(key)
|
||||
|
||||
@@ -28,7 +28,7 @@ func readerOf(s stdio.KeptState) versions.Reader {
|
||||
// republishTools are builder_publish_again and builder_publish_queue (design 47 G §588). The publish again is a hand act:
|
||||
// it is recorded in the hand-act log first, then written to reasks for the builder, which owns the queue, to answer
|
||||
// with the versions it queued.
|
||||
func republishTools(queue, acted versions.Reader, ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||
func republishTools(queue, acted, reasks versions.Reader, ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
||||
return []stdio.Tool{
|
||||
{Name: versions.PublishAgainTool, Description: versions.PublishAgainDescription,
|
||||
@@ -60,6 +60,6 @@ func republishTools(queue, acted versions.Reader, ask queueAsker, now func() tim
|
||||
}},
|
||||
{Name: versions.PublishQueueTool, Description: versions.PublishQueueDescription,
|
||||
Input: map[string]any{"type": "object", "properties": map[string]any{}},
|
||||
Run: func(map[string]any) (any, error) { return versions.AnswerQueue(queue, acted) }},
|
||||
Run: func(map[string]any) (any, error) { return versions.AnswerQueue(queue, acted, reasks) }},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,12 +241,34 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
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}}},
|
||||
Acted: awaitedReserved{awaitedVersions{b: actedKV, bucket: own.acted}}, Entry: entryVia(calls.Call), Send: sendVia(calls.Call),
|
||||
Entry: entryVia(calls.Call), Send: sendVia(calls.Call),
|
||||
Unreleased: reserved.unreleasedWords, Max: republishMax, 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 {
|
||||
return err
|
||||
}
|
||||
reasksKV := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.ReAsksState), "builder_ask_again is not heard; an ask that can no longer be answered is still asked again by itself", logger.Printf)
|
||||
// A version's publish is the builder's own work until its release is written (design 47 G A-457a): an item of the re-ask state.
|
||||
items := &publishItems{reasks: reasksKV.KV, set: publishSet, now: time.Now, logf: logger.Printf,
|
||||
reserved: func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error) {
|
||||
return reserved.r.Of(ctx, module, version)
|
||||
},
|
||||
republish: republish.Republish, endedWith: reserved.unreleased,
|
||||
allDone: func(ctx context.Context) ([]versions.ReservedVersion, error) {
|
||||
all, err := reserved.r.All(ctx)
|
||||
var out []versions.ReservedVersion
|
||||
for _, v := range all {
|
||||
if !v.BuiltAt.IsZero() && len(v.Missing()) > 0 {
|
||||
out = append(out, v)
|
||||
}
|
||||
}
|
||||
return out, err
|
||||
}}
|
||||
reserved.built, reserved.released = items.Ask, items.Done
|
||||
reasksKV.Ready(func(jetstream.KeyValue) { items.AskAllDone(ctx) })
|
||||
reserved.r.Releases = awaitedReserved{awaitedVersions{b: actedKV, bucket: own.acted}} // the record of the releases it saw (design 47 G A-456a)
|
||||
acts.Republish = republish.Republish
|
||||
reserved.publishAtEnd = republish.Ended
|
||||
// builder_reserve_done: a done trunk build that reserved none is given a version, and its publish queued as publish again does.
|
||||
acts.ReserveDone = reserveDoneAct(b.ReserveDone, republish.Republish, logger.Printf)
|
||||
again := &republishing{rp: republish}
|
||||
@@ -390,9 +412,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// And the four registry seats' published, refused and removed (DLV-B4), which move a numbered version.
|
||||
seatHeard := seatHearer{n: numberer, b: b, logf: logger.Printf, pub: pubs, res: reserved}
|
||||
events := func(m jetstream.Msg) {
|
||||
if again.heard(ctx, m, logger.Printf) { // the publish again's own subjects, left for the bus to give again when its state cannot take them
|
||||
return
|
||||
}
|
||||
if decided.heard(m) { // the operator's answer to an ask about a key (§568)
|
||||
return
|
||||
}
|
||||
@@ -465,8 +484,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// A person asks a key's build again with builder_ask_again, which writes the reasks state (issue 1945): watched, as
|
||||
// every other input. The builder asks again by itself without it.
|
||||
// A state not on the bus yet at this start is watched once it appears (issue 1790).
|
||||
process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.ReAsksState), "builder_ask_again is not heard; an ask that can no longer be answered is still asked again by itself", logger.Printf).Ready(func(kv jetstream.KeyValue) {
|
||||
eachReAsk := func(e jetstream.KeyValueEntry) { reAsked(ctx, b, acts, kv, e, logger.Printf) }
|
||||
reasksKV.Ready(func(kv jetstream.KeyValue) {
|
||||
eachReAsk := func(e jetstream.KeyValueEntry) { reAsked(ctx, b, acts, items, kv, e, logger.Printf) }
|
||||
if rw, err := settle(ctx, kv, eachReAsk); err != nil {
|
||||
process.NotWatched(logger.Printf, builds.StateBucket(cred.Module, build.ReAsksState), err, "builder_ask_again is not heard until the builder starts again")
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
)
|
||||
|
||||
// **A version's publish is the builder's own work until its release is written** (design 47 G A-457a, §588): each reservation of a
|
||||
// done build is a publish item in the builder's re-ask state, the mechanism builder_reserve_done and publish again use. It is
|
||||
// asked when the build ends and at the builder's start; each try queues the publish and writes the item again with one more try
|
||||
// and a longer pause; the release deletes it; after its tries it ends loudly and stays readable in builder_publish_queue.
|
||||
|
||||
// publishSettings are the settings publish-pause, publish-pause-max and publish-tries.
|
||||
type publishSettings struct {
|
||||
Pause, PauseMax time.Duration
|
||||
Tries int
|
||||
}
|
||||
|
||||
// defaultPublishSettings are the settings' defaults: 30 s, 30 min and 8 tries.
|
||||
var defaultPublishSettings = publishSettings{Pause: 30 * time.Second, PauseMax: 30 * time.Minute, Tries: 8}
|
||||
|
||||
// pauseAfter is the pause after the try-th try: the setting doubled per try, up to the maximum.
|
||||
func (s publishSettings) pauseAfter(try int) time.Duration {
|
||||
d := s.Pause
|
||||
for i := 1; i < try && d < s.PauseMax; i++ {
|
||||
d *= 2
|
||||
}
|
||||
return min(d, s.PauseMax)
|
||||
}
|
||||
|
||||
// publishItems asks, tries and ends the publish items.
|
||||
type publishItems struct {
|
||||
reasks func() jetstream.KeyValue // the re-ask state, nil until it is bound
|
||||
reserved func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error)
|
||||
republish func(ctx context.Context, module, version string) ([]string, error)
|
||||
endedWith func(ctx context.Context, v versions.ReservedVersion, why string) // raises the finding version-unreleased
|
||||
allDone func(ctx context.Context) ([]versions.ReservedVersion, error)
|
||||
set publishSettings
|
||||
now func() time.Time
|
||||
after func(time.Duration) <-chan time.Time
|
||||
logf func(string, ...any)
|
||||
}
|
||||
|
||||
func (p *publishItems) wait(ctx context.Context, d time.Duration) bool {
|
||||
if d <= 0 {
|
||||
return ctx.Err() == nil
|
||||
}
|
||||
after := p.after
|
||||
if after == nil {
|
||||
after = time.After
|
||||
}
|
||||
select {
|
||||
case <-after(d):
|
||||
return true
|
||||
case <-ctx.Done():
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Ask writes the publish item of a version whose build is done, when none stands: its first try is now.
|
||||
func (p *publishItems) Ask(ctx context.Context, module, version string) error {
|
||||
kv := p.reasks()
|
||||
if kv == nil {
|
||||
return errors.New("the re-ask state is not on the bus yet")
|
||||
}
|
||||
raw, err := json.Marshal(build.ReAsk{V: 1, Why: "the build ended with its version unreleased", By: "the builder", At: p.now().UTC(), Mode: build.ModePublish, Module: module, Version: version, NextTry: p.now().UTC()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := kv.Create(ctx, versions.PublishItemKey(module, version), raw); err != nil && !errors.Is(err, jetstream.ErrKeyExists) {
|
||||
return fmt.Errorf("the publish item of %s %s cannot be written: %w", module, version, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AskAllDone asks the publish item of every reservation whose build is done and that has no release: at the builder's start, so
|
||||
// what stood before this change moves too.
|
||||
func (p *publishItems) AskAllDone(ctx context.Context) {
|
||||
vs, err := p.allDone(ctx)
|
||||
if err != nil {
|
||||
p.logf("the reservations of done builds are not asked to publish at the start: %v", err)
|
||||
return
|
||||
}
|
||||
for _, v := range vs {
|
||||
if err := p.Ask(ctx, v.Module, v.Version); err != nil {
|
||||
p.logf("%v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done deletes a version's publish item: its release is written.
|
||||
func (p *publishItems) Done(ctx context.Context, module, version string) {
|
||||
kv := p.reasks()
|
||||
if kv == nil {
|
||||
return
|
||||
}
|
||||
if err := kv.Delete(ctx, versions.PublishItemKey(module, version)); err != nil && !errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||
p.logf("the publish item of %s %s is not deleted: %v", module, version, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Try waits for the item's next try, then, while the version is still reserved, queues its publish and writes the item again with
|
||||
// one more try and the pause after it; once the tries are spent it ends the item loudly. A version no longer reserved (released or
|
||||
// dropped) has its item deleted.
|
||||
func (p *publishItems) Try(ctx context.Context, kv jetstream.KeyValue, e jetstream.KeyValueEntry, r build.ReAsk) {
|
||||
if !p.wait(ctx, r.NextTry.Sub(p.now())) {
|
||||
return
|
||||
}
|
||||
cur, err := kv.Get(ctx, e.Key())
|
||||
if err != nil || cur.Revision() != e.Revision() {
|
||||
return // deleted by the release, or written again
|
||||
}
|
||||
v, held, err := p.reserved(ctx, r.Module, r.Version)
|
||||
if err != nil {
|
||||
p.logf("%s %s: its reservation cannot be read, the publish item waits: %v", r.Module, r.Version, err)
|
||||
return
|
||||
}
|
||||
if !held || len(v.Missing()) == 0 {
|
||||
_ = kv.Delete(ctx, e.Key())
|
||||
return
|
||||
}
|
||||
if r.Tries >= p.set.Tries {
|
||||
r.Answer = fmt.Sprintf("the publish of %s %s was tried %d times and the version is not released; builder_publish_again tries it again", r.Module, r.Version, r.Tries)
|
||||
r.Answered = p.now().UTC()
|
||||
p.logf("%s: %s", e.Key(), r.Answer)
|
||||
if p.endedWith != nil {
|
||||
p.endedWith(ctx, v, "the publish ended after "+fmt.Sprint(r.Tries)+" tries")
|
||||
}
|
||||
} else {
|
||||
r.Tries++
|
||||
if _, err := p.republish(ctx, r.Module, r.Version); err != nil {
|
||||
p.logf("%s %s: try %d queued no publish: %v", r.Module, r.Version, r.Tries, err)
|
||||
}
|
||||
r.NextTry = p.now().UTC().Add(p.set.pauseAfter(r.Tries))
|
||||
}
|
||||
data, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if _, err := kv.Update(ctx, e.Key(), data, e.Revision()); err != nil && !errors.Is(err, jetstream.ErrKeyExists) && !errors.Is(err, jetstream.ErrKeyRevisionMismatch) {
|
||||
p.logf("%s: the publish item could not be written: %v", e.Key(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// numberFile reads a setting's number from the file the manifest declares: no file or an empty one is def; a content that is no
|
||||
// number of at least one is an error naming the file.
|
||||
func numberFile(path string, def int) (int, error) {
|
||||
if path == "" {
|
||||
return def, nil
|
||||
}
|
||||
raw, err := os.ReadFile(path)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return def, nil
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
v := strings.TrimSpace(string(raw))
|
||||
if v == "" {
|
||||
return def, nil
|
||||
}
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil || n < 1 {
|
||||
return 0, fmt.Errorf("%s holds %q, which is not a number of at least one", path, v)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// publishSettingsOf reads publish-pause (seconds), publish-pause-max (minutes) and publish-tries from their files.
|
||||
func publishSettingsOf(getenv func(string) string) (publishSettings, error) {
|
||||
s := defaultPublishSettings
|
||||
pause, err := numberFile(getenv("MESH_BUILDER_PUBLISH_PAUSE_FILE"), int(s.Pause/time.Second))
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
pmax, err := numberFile(getenv("MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE"), int(s.PauseMax/time.Minute))
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
tries, err := numberFile(getenv("MESH_BUILDER_PUBLISH_TRIES_FILE"), s.Tries)
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
return publishSettings{Pause: time.Duration(pause) * time.Second, PauseMax: time.Duration(pmax) * time.Minute, Tries: tries}, nil
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"mesh-delivery-builder/internal/build"
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
)
|
||||
|
||||
// itemKV is the re-ask state in memory: one revision per key.
|
||||
type itemKV struct {
|
||||
jetstream.KeyValue
|
||||
vals map[string][]byte
|
||||
revs map[string]uint64
|
||||
rev uint64
|
||||
}
|
||||
|
||||
type itemEntry struct {
|
||||
jetstream.KeyValueEntry
|
||||
key string
|
||||
value []byte
|
||||
rev uint64
|
||||
}
|
||||
|
||||
func (e itemEntry) Key() string { return e.key }
|
||||
func (e itemEntry) Value() []byte { return e.value }
|
||||
func (e itemEntry) Revision() uint64 { return e.rev }
|
||||
func (e itemEntry) Operation() jetstream.KeyValueOp { return jetstream.KeyValuePut }
|
||||
|
||||
func (k *itemKV) entry(key string) jetstream.KeyValueEntry {
|
||||
return itemEntry{key: key, value: k.vals[key], rev: k.revs[key]}
|
||||
}
|
||||
func (k *itemKV) Get(_ context.Context, key string) (jetstream.KeyValueEntry, error) {
|
||||
if _, ok := k.vals[key]; !ok {
|
||||
return nil, jetstream.ErrKeyNotFound
|
||||
}
|
||||
return k.entry(key), nil
|
||||
}
|
||||
func (k *itemKV) Create(_ context.Context, key string, v []byte, _ ...jetstream.KVCreateOpt) (uint64, error) {
|
||||
if _, ok := k.vals[key]; ok {
|
||||
return 0, jetstream.ErrKeyExists
|
||||
}
|
||||
k.rev++
|
||||
k.vals[key], k.revs[key] = v, k.rev
|
||||
return k.rev, nil
|
||||
}
|
||||
func (k *itemKV) Update(_ context.Context, key string, v []byte, rev uint64) (uint64, error) {
|
||||
if k.revs[key] != rev {
|
||||
return 0, jetstream.ErrKeyExists
|
||||
}
|
||||
k.rev++
|
||||
k.vals[key], k.revs[key] = v, k.rev
|
||||
return k.rev, nil
|
||||
}
|
||||
func (k *itemKV) Delete(_ context.Context, key string, _ ...jetstream.KVDeleteOpt) error {
|
||||
delete(k.vals, key)
|
||||
return nil
|
||||
}
|
||||
|
||||
func decodeItem(t *testing.T, raw []byte) build.ReAsk {
|
||||
t.Helper()
|
||||
r, err := build.DecodeReAsk(raw)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// TestAPublishItemIsTriedWithAGrowingPauseAndEndsLoudly: design 47 G A-457a — a version's publish item is asked once, each try queues
|
||||
// the publish and writes the item again with one more try and the pause doubled up to its maximum, the release deletes it, and
|
||||
// after the setting's tries it ends with its words, raises the condition and stays; a version no longer reserved has it deleted.
|
||||
func TestAPublishItemIsTriedWithAGrowingPauseAndEndsLoudly(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
kv := &itemKV{vals: map[string][]byte{}, revs: map[string]uint64{}}
|
||||
now := time.Date(2026, 11, 17, 1, 0, 0, 0, time.UTC)
|
||||
var waited []time.Duration
|
||||
var queued, ended []string
|
||||
reserved := true
|
||||
v := versions.ReservedVersion{Module: "m", Version: "0.1.2", Artifacts: map[string]string{"m:a": "sha256:a"}, BuiltAt: now}
|
||||
p := &publishItems{reasks: func() jetstream.KeyValue { return kv }, set: publishSettings{Pause: 30 * time.Second, PauseMax: 2 * time.Minute, Tries: 4},
|
||||
now: func() time.Time { return now }, logf: t.Logf,
|
||||
after: func(d time.Duration) <-chan time.Time {
|
||||
waited = append(waited, d)
|
||||
now = now.Add(d)
|
||||
c := make(chan time.Time, 1)
|
||||
c <- now
|
||||
return c
|
||||
},
|
||||
reserved: func(context.Context, string, string) (versions.ReservedVersion, bool, error) { return v, reserved, nil },
|
||||
republish: func(_ context.Context, m, ver string) ([]string, error) {
|
||||
queued = append(queued, m+" "+ver)
|
||||
return nil, errors.New("no holder")
|
||||
},
|
||||
endedWith: func(_ context.Context, v versions.ReservedVersion, why string) {
|
||||
ended = append(ended, v.Version+": "+why)
|
||||
}}
|
||||
key := versions.PublishItemKey("m", "0.1.2")
|
||||
if err := p.Ask(ctx, "m", "0.1.2"); err != nil || p.Ask(ctx, "m", "0.1.2") != nil || len(kv.vals) != 1 {
|
||||
t.Fatalf("asked: %v, %d items, want one item however often it is asked", err, len(kv.vals))
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
e, _ := kv.Get(ctx, key)
|
||||
p.Try(ctx, kv, e, decodeItem(t, e.Value()))
|
||||
}
|
||||
got := decodeItem(t, kv.vals[key])
|
||||
if len(queued) != 4 || got.Tries != 4 || got.Answer == "" || got.Answered.IsZero() || len(ended) != 1 || !strings.Contains(ended[0], "4 tries") {
|
||||
t.Fatalf("queued %v, item %+v, ended %v: want four tries, then the end said with its words and the condition", queued, got, ended)
|
||||
}
|
||||
if want := []time.Duration{30 * time.Second, time.Minute, 2 * time.Minute, 2 * time.Minute}; len(waited) != len(want) || waited[0] != want[0] || waited[1] != want[1] || waited[2] != want[2] || waited[3] != want[3] {
|
||||
t.Errorf("pauses before the tries and the end = %v, want %v (doubled, capped)", waited, want)
|
||||
}
|
||||
// At the start every reservation of a done build with no release is asked, one item each.
|
||||
kv.vals, kv.revs = map[string][]byte{}, map[string]uint64{}
|
||||
p.allDone = func(context.Context) ([]versions.ReservedVersion, error) {
|
||||
return []versions.ReservedVersion{v, {Module: "n", Version: "0.2.0"}}, nil
|
||||
}
|
||||
p.AskAllDone(ctx)
|
||||
if len(kv.vals) != 2 {
|
||||
t.Errorf("the start asked %d items, want one per done unreleased reservation", len(kv.vals))
|
||||
}
|
||||
// A released version's item is deleted; a version no longer reserved has it deleted at its next try.
|
||||
p.Done(ctx, "m", "0.1.2")
|
||||
p.Done(ctx, "n", "0.2.0")
|
||||
if len(kv.vals) != 0 {
|
||||
t.Errorf("the release left %v", kv.vals)
|
||||
}
|
||||
_ = p.Ask(ctx, "m", "0.1.2")
|
||||
reserved = false
|
||||
e, _ := kv.Get(ctx, key)
|
||||
p.Try(ctx, kv, e, decodeItem(t, e.Value()))
|
||||
if len(kv.vals) != 0 {
|
||||
t.Errorf("a dropped reservation left its item %v", kv.vals)
|
||||
}
|
||||
}
|
||||
|
||||
// TestThePublishSettingsAreReadFromTheirFiles: design 47 G A-457a — the three settings, 30 s, 30 min and 8 tries unless set, and a
|
||||
// content that is no number is refused naming its file.
|
||||
func TestThePublishSettingsAreReadFromTheirFiles(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
write := func(name, v string) string {
|
||||
p := filepath.Join(dir, name)
|
||||
if err := os.WriteFile(p, []byte(v), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
env := map[string]string{}
|
||||
got, err := publishSettingsOf(func(k string) string { return env[k] })
|
||||
if err != nil || got != defaultPublishSettings || got.Pause != 30*time.Second || got.PauseMax != 30*time.Minute || got.Tries != 8 {
|
||||
t.Fatalf("defaults = %+v (%v)", got, err)
|
||||
}
|
||||
env["MESH_BUILDER_PUBLISH_PAUSE_FILE"], env["MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE"], env["MESH_BUILDER_PUBLISH_TRIES_FILE"] = write("p", "5\n"), write("m", "2"), write("t", "3")
|
||||
if got, err = publishSettingsOf(func(k string) string { return env[k] }); err != nil || got != (publishSettings{5 * time.Second, 2 * time.Minute, 3}) {
|
||||
t.Errorf("set = %+v (%v)", got, err)
|
||||
}
|
||||
env["MESH_BUILDER_PUBLISH_TRIES_FILE"] = write("bad", "many")
|
||||
if _, err = publishSettingsOf(func(k string) string { return env[k] }); err == nil || !strings.Contains(err.Error(), "bad") {
|
||||
t.Errorf("a content that is no number: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ const buildAgainBound = 15 * time.Second
|
||||
// reAsked answers one value of the reasks state (the tool builder_ask_again, issue 1945): a value not yet answered asks the
|
||||
// key's waiting lanes again and is written back, by compare-and-set at its revision, with what the builder did. A value
|
||||
// answered already (this builder's own write) or deleted is left.
|
||||
func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, kv jetstream.KeyValue, e jetstream.KeyValueEntry, logf func(string, ...any)) {
|
||||
func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publishItems, kv jetstream.KeyValue, e jetstream.KeyValueEntry, logf func(string, ...any)) {
|
||||
if e.Operation() != jetstream.KeyValuePut {
|
||||
return
|
||||
}
|
||||
@@ -45,6 +45,13 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, kv jetstream
|
||||
if r.Answer != "" {
|
||||
return
|
||||
}
|
||||
if r.Mode == build.ModePublish {
|
||||
// A version's publish item (design 47 G A-457a): its try waits for its pause, so it is made beside the watch.
|
||||
if items != nil {
|
||||
go items.Try(ctx, kv, e, r)
|
||||
}
|
||||
return
|
||||
}
|
||||
if r.Mode == build.ModeBuild {
|
||||
// The answer comes when the claim and the asks are written, so it is made beside the watch, not in it.
|
||||
go builtAgain(ctx, b, kv, e, r, logf)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
"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/meshcatalog"
|
||||
|
||||
@@ -101,8 +100,8 @@ func republishMaxOf(path string) (int, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// republishing starts the publish again once both its states are bound: the queue is taken up again and the last running
|
||||
// of every node's module is read (§556), acted on where its sequence is newer than the kept one.
|
||||
// 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 {
|
||||
rp *versions.Republisher
|
||||
ready atomic.Int32
|
||||
@@ -116,32 +115,5 @@ func (g *republishing) bound(ctx context.Context, js jetstream.JetStream, logf f
|
||||
if err := g.rp.Resume(ctx); err != nil {
|
||||
logf("the queued publishes are not taken up again: %v", err)
|
||||
}
|
||||
err := lastPerSubject(ctx, js, nodeengine.StreamRunning, nodeengine.SubjectRunningAll, func(subject string, data []byte, seq uint64) {
|
||||
if _, err := g.rp.Heard(ctx, subject, data, seq); err != nil {
|
||||
logf("the running %s is not acted on at the start: %v", subject, err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
logf("the running of the node-engine seat is not read for the publish again at the start: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// heard hands a message of the events consumer to the publish again: one of its subjects whose state cannot take it is left
|
||||
// for the bus to give again (Nak); every message goes on to the other parts.
|
||||
func (g *republishing) heard(ctx context.Context, m jetstream.Msg, logf func(string, ...any)) (stop bool) {
|
||||
meta, err := m.Metadata()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
handled, err := g.rp.Heard(ctx, m.Subject(), m.Data(), meta.Sequence.Stream)
|
||||
if handled && err != nil {
|
||||
logf("%v; heard again", err)
|
||||
if nakErr := m.Nak(); nakErr != nil {
|
||||
logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr)
|
||||
}
|
||||
givenUp(m, "its event", err, logf)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -40,19 +40,20 @@ func (s awaitedReserved) Delete(ctx context.Context, key string) error {
|
||||
// reservations is the builder's reserving: the Reserver, the fill the catalog said, the bounds of a built reservation's
|
||||
// publish and the findings.
|
||||
type reservations struct {
|
||||
r *versions.Reserver
|
||||
filled atomic.Bool
|
||||
bounds func() jetstream.KeyValue
|
||||
found *findings
|
||||
bound time.Duration
|
||||
wake func(context.Context)
|
||||
logf func(string, ...any)
|
||||
r *versions.Reserver
|
||||
// built asks a done build's publish (design 47 G A-457a), released ends its item; nil are none.
|
||||
built func(ctx context.Context, module, version string) error
|
||||
released func(ctx context.Context, module, version string)
|
||||
filled atomic.Bool
|
||||
bounds func() jetstream.KeyValue
|
||||
found *findings
|
||||
bound time.Duration
|
||||
wake func(context.Context)
|
||||
logf func(string, ...any)
|
||||
// call asks a seat's verb: the git seat's tag (design 47 G §370).
|
||||
call toolCaller
|
||||
// say says package-published on the seat mesh-builds; nil says none.
|
||||
say func(context.Context, meshbuilds.PackagePublished) error
|
||||
// publishAtEnd asks the tagged publish of a reservation whose build has ended (design 47 G A-473); nil asks none.
|
||||
publishAtEnd func(ctx context.Context, module, version string) ([]string, error)
|
||||
}
|
||||
|
||||
// newReservations makes the reserving over store; the released versions of a module are asked of the seat mesh-catalog's
|
||||
@@ -121,6 +122,11 @@ func (rv *reservations) Built(ctx context.Context, module, version string, diges
|
||||
return err
|
||||
}
|
||||
rv.arm(ctx, cur)
|
||||
if rv.built != nil && len(cur.Missing()) > 0 {
|
||||
if err := rv.built(ctx, module, version); err != nil {
|
||||
rv.logf("%v", err)
|
||||
}
|
||||
}
|
||||
// A published heard before the digests were recorded marks its artifact now, said as one heard after (design 47 G A-415).
|
||||
marked, unmatched, err := rv.r.Kept(ctx, module, version)
|
||||
if err != nil {
|
||||
@@ -132,12 +138,6 @@ func (rv *reservations) Built(ctx context.Context, module, version string, diges
|
||||
for _, m := range marked {
|
||||
rv.sayPublished(ctx, m, m.Reserved.Artifacts[m.Artifact])
|
||||
}
|
||||
// The build's end asks the tagged publish itself, at the holder of each artifact's registry seat (design 47 G A-473).
|
||||
if rv.publishAtEnd != nil {
|
||||
if _, err := rv.publishAtEnd(ctx, module, version); err != nil {
|
||||
rv.logf("the publish of %s %s is not asked at the build's end: %v", module, version, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -238,6 +238,9 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
||||
for _, k := range gone {
|
||||
rv.dropBound(ctx, k)
|
||||
}
|
||||
if rv.released != nil {
|
||||
rv.released(ctx, ev.Module, ev.Version)
|
||||
}
|
||||
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
||||
default:
|
||||
return false
|
||||
|
||||
@@ -91,6 +91,9 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
||||
}
|
||||
rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, call, func() jetstream.KeyValue { return bounds }, found,
|
||||
func(context.Context) { woke++ }, t.Logf)
|
||||
var items []string // design 47 G A-457a: the end of a build asks its publish, the release ends it
|
||||
rv.built = func(_ context.Context, m, v string) error { items = append(items, "asked "+m+" "+v); return nil }
|
||||
rv.released = func(_ context.Context, m, v string) { items = append(items, "ended "+m+" "+v) }
|
||||
if _, err := rv.Reserve(ctx, "m", "1.4", []string{"m:a"}, versions.Source{}); err == nil || rv.Filled() {
|
||||
t.Fatalf("a version was reserved before versions-filled (%v)", err)
|
||||
}
|
||||
@@ -104,16 +107,13 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
||||
if err != nil || res.Version != "1.4.3" {
|
||||
t.Fatalf("reserved %q (%v), want 1.4.3 after the catalog's 1.4.2", res.Version, err)
|
||||
}
|
||||
var asked []string
|
||||
rv.publishAtEnd = func(_ context.Context, module, version string) ([]string, error) {
|
||||
asked = append(asked, module+" "+version)
|
||||
return nil, nil
|
||||
}
|
||||
items = nil
|
||||
if err := rv.Built(ctx, "m", "1.4.3", map[string]string{"m:a": "sha256:a", "m:b": "sha256:b"}, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(asked) != 1 || asked[0] != "m 1.4.3" {
|
||||
t.Fatalf("the build's end asked the publish of %v, want m 1.4.3 once (A-473)", asked)
|
||||
// The build's end asks the publish item once, the one mechanism (design 47 G A-457a, A-473).
|
||||
if len(items) != 1 || items[0] != "asked m 1.4.3" {
|
||||
t.Fatalf("the build's end asked %v, want the publish item of m 1.4.3 once (A-457a, A-473)", items)
|
||||
}
|
||||
boundKey := versions.ReservedBoundKey("m", "1.4")
|
||||
if !bounds.keys[boundKey] {
|
||||
@@ -138,6 +138,9 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
||||
if !rv.heard(ctx, released) || !released.acked {
|
||||
t.Fatalf("version-released was not taken in (acked %v)", released.acked)
|
||||
}
|
||||
if strings.Join(items, ", ") != "asked m 1.4.3, ended m 1.4.3" {
|
||||
t.Errorf("publish items %v, want the build's end to ask the publish and the release to end it", items)
|
||||
}
|
||||
if all, _ := rv.r.All(ctx); len(all) != 0 || bounds.keys[boundKey] || len(st.vals) != 0 {
|
||||
t.Errorf("after version-released: reservations %v, bounds %v, findings %v; want none", all, bounds.keys, st.vals)
|
||||
}
|
||||
@@ -353,7 +356,7 @@ func TestAReserveDoneIsAnsweredWithTheVersionAndItsQueuedPublish(t *testing.T) {
|
||||
}
|
||||
kv := &ansKV{wrote: make(chan []byte, 1)}
|
||||
// reAsked sends a reserve-done to the version acts (b is not asked), and the answer is written back to the key.
|
||||
reAsked(ctx, nil, acts, kv, ansEntry{key: "reserve-done." + c.module, value: value}, logf)
|
||||
reAsked(ctx, nil, acts, nil, kv, ansEntry{key: "reserve-done." + c.module, value: value}, logf)
|
||||
var wrote []byte
|
||||
select {
|
||||
case wrote = <-kv.wrote:
|
||||
|
||||
@@ -61,8 +61,15 @@ type ReAsk struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Queued []string `json:"queued,omitempty"`
|
||||
// Tries and NextTry are a ModePublish value's (design 47 G A-457a): the publishes tried so far, and when the next is.
|
||||
Tries int `json:"tries,omitempty"`
|
||||
NextTry time.Time `json:"next-try,omitzero"`
|
||||
}
|
||||
|
||||
// ModePublish is the Mode of a reasks value that is a version's publish item (design 47 G A-457a): Module and Version name it,
|
||||
// Tries and NextTry say where it stands; it is written by the builder itself, when a build ends and at its start.
|
||||
const ModePublish = "publish"
|
||||
|
||||
// ModeRepublish is the Mode of a reasks value of builder_publish_again (design 47 G §588): Module and Version, each
|
||||
// optional, name what to publish again; the builder answers with the versions it queued (Queued).
|
||||
const ModeRepublish = "republish"
|
||||
|
||||
@@ -5,22 +5,20 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
// **A reserved version left unpublished is published again by the builder, on an event or by a person's tool** (design 47
|
||||
// G §588, ADR 0674): on the node-engine seat's `running` of a module whose catalog graph entry claims the registry seat
|
||||
// of the missing artifacts' kind, and on its `manifest-reads-changed` with `why` `returned`, at each registry seat's holder
|
||||
// the seat-holders view names (A-416, A-416a: known from the start, not from the running heard). Each message is acted on once, by its stream sequence (state `acted`); each holder has one queue of versions,
|
||||
// kept in the state `publish-queue`, sent one at a time. A send is the registry seat's `publish` with the digest and no
|
||||
// parts (A-73): the holder takes the bytes from the artifact store by digest, and refuses what no store holds.
|
||||
// **A reserved version of a done build is published by the builder until its release is written** (design 47 G §588, A-457a): the
|
||||
// publish is an item of the builder's re-ask state, asked when the build ends and at its start, tried with a growing pause and
|
||||
// ended loudly after its tries; each registry seat's holder, as the seat-holders view names it (A-416, A-416a), has one queue of
|
||||
// versions, kept in the state `publish-queue`, sent one at a time. A send is the registry seat's `publish` with the digest and no
|
||||
// parts (A-73): the holder takes the bytes from the artifact store by digest, and refuses what no store holds. Nothing waits on a
|
||||
// node-engine `running` or `manifest-reads-changed` any more.
|
||||
|
||||
const (
|
||||
// PublishQueueState is the builder's old state section of the queues, capped at PublishQueueMiB.
|
||||
@@ -106,7 +104,6 @@ type Publish struct {
|
||||
type Republisher struct {
|
||||
Reserved *Reserver
|
||||
Queue QueueStore
|
||||
Acted ReserveStore
|
||||
// Entry reads the catalog graph entry of a fingerprint (the seat mesh-catalog's verb entry).
|
||||
Entry func(ctx context.Context, fingerprint string) (meshcatalog.CatalogEntry, error)
|
||||
// Send sends one publish to a registry seat; an error is the holder's refusal or the call's fault, in its words.
|
||||
@@ -159,95 +156,21 @@ func (r *Republisher) logf(f string, a ...any) {
|
||||
// ActedKey is the acted key of a subject.
|
||||
func ActedKey(subject string) string { return EscapeToken(subject) }
|
||||
|
||||
// Heard takes one message of the node-engine seat's running or manifest-reads-changed in, at stream sequence seq: it acts
|
||||
// on it only when its sequence is newer than the one kept for its subject, and keeps it after. A subject that is neither is
|
||||
// not its; an error leaves the message not acted on, so it is read again.
|
||||
func (r *Republisher) Heard(ctx context.Context, subject string, data []byte, seq uint64) (bool, error) {
|
||||
running := strings.HasPrefix(subject, strings.TrimSuffix(nodeengine.SubjectRunningAll, "*.*"))
|
||||
changed := strings.HasPrefix(subject, "mesh.seat.node-engine.event."+nodeengine.EventManifestReadsChanged+".")
|
||||
if !running && !changed {
|
||||
return false, nil
|
||||
}
|
||||
key := ActedKey(subject)
|
||||
raw, rev, found, err := r.Acted.Get(ctx, key)
|
||||
if err != nil {
|
||||
return true, fmt.Errorf("the acted sequence of %s cannot be read: %w", subject, err)
|
||||
}
|
||||
if found {
|
||||
var a Acted
|
||||
if json.Unmarshal(raw, &a) == nil && a.Sequence >= seq {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
if running {
|
||||
err = r.running(ctx, data)
|
||||
} else {
|
||||
err = r.returned(ctx, data)
|
||||
}
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
val, _ := json.Marshal(Acted{Sequence: seq})
|
||||
if found {
|
||||
_, err = r.Acted.Update(ctx, key, val, rev)
|
||||
} else {
|
||||
_, err = r.Acted.Create(ctx, key, val)
|
||||
}
|
||||
if err != nil && !errors.Is(err, ErrConflict) {
|
||||
return true, fmt.Errorf("the acted sequence of %s cannot be kept: %w", subject, err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// registrySeatsOf are the registry seats the module of the catalog entry fingerprint claims, by their publish verb.
|
||||
func (r *Republisher) registrySeatsOf(ctx context.Context, fingerprint string) ([]string, error) {
|
||||
e, err := r.Entry(ctx, fingerprint)
|
||||
// QueueDone queues every reserved version whose build is done and that has an artifact unpublished (design 47 G A-457a): asked at
|
||||
// the builder's start, so what stood before the change moves too, and when a build ends. At most Max versions at once, newest
|
||||
// first; a version queued already is not queued again. It answers the versions queued.
|
||||
func (r *Republisher) QueueDone(ctx context.Context) ([]string, error) {
|
||||
all, err := r.Reserved.All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out []string
|
||||
for _, seat := range RegistrySeats {
|
||||
if slices.Contains(e.Serves, seat+"."+VerbPublish) {
|
||||
out = append(out, seat)
|
||||
var vs []ReservedVersion
|
||||
for _, v := range all {
|
||||
if !v.BuiltAt.IsZero() && len(v.Missing()) > 0 {
|
||||
vs = append(vs, v)
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// running takes a running in: one of a module whose entry claims a registry seat queues the versions waiting on it (§588). It
|
||||
// is not how a holder is known: Holders answers that (design 47 G A-416).
|
||||
func (r *Republisher) running(ctx context.Context, data []byte) error {
|
||||
var ev nodeengine.Running
|
||||
if err := json.Unmarshal(data, &ev); err != nil || ev.Module == "" || ev.Node == "" {
|
||||
r.logf("a running that does not read is not acted on: %v", err)
|
||||
return nil
|
||||
}
|
||||
if ev.Stopped || ev.Fingerprint == "" {
|
||||
return nil
|
||||
}
|
||||
seats, err := r.registrySeatsOf(ctx, ev.Fingerprint)
|
||||
if err != nil {
|
||||
return fmt.Errorf("the catalog entry %s of %s cannot be read: %w", ev.Fingerprint, ev.Module, err)
|
||||
}
|
||||
if len(seats) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err = r.queueEvent(ctx, map[string][]string{ev.Module: seats})
|
||||
return err
|
||||
}
|
||||
|
||||
// heldSeats are the registry seats' holders as Holders answers them: holder module -> the registry seats it holds.
|
||||
func (r *Republisher) heldSeats() map[string][]string {
|
||||
held := map[string][]string{}
|
||||
if r.Holders == nil {
|
||||
return held
|
||||
}
|
||||
for _, seat := range RegistrySeats {
|
||||
for _, h := range r.Holders(seat) {
|
||||
held[h] = append(held[h], seat)
|
||||
}
|
||||
}
|
||||
return held
|
||||
return r.queue(ctx, vs, r.holdersFn, r.Max)
|
||||
}
|
||||
|
||||
// holdersFn answers a seat's holders from Holders.
|
||||
@@ -258,59 +181,12 @@ func (r *Republisher) holdersFn(seat string) []string {
|
||||
return r.Holders(seat)
|
||||
}
|
||||
|
||||
// returned takes a manifest-reads-changed in: only one with why returned acts, for every registry seat's holder Holders
|
||||
// answers (design 47 G A-416a); a version queued at a holder already is not queued again.
|
||||
func (r *Republisher) returned(ctx context.Context, data []byte) error {
|
||||
var ev nodeengine.ManifestReadsChanged
|
||||
if err := json.Unmarshal(data, &ev); err != nil || ev.Node == "" {
|
||||
r.logf("a manifest-reads-changed that does not read is not acted on: %v", err)
|
||||
return nil
|
||||
}
|
||||
if ev.Why != nodeengine.ManifestReadsChangedWhyReturned {
|
||||
return nil
|
||||
}
|
||||
holders := r.heldSeats()
|
||||
if len(holders) == 0 {
|
||||
return nil
|
||||
}
|
||||
_, err := r.queueEvent(ctx, holders)
|
||||
return err
|
||||
}
|
||||
|
||||
// view is a reserved version with the artifacts of it a holder would publish.
|
||||
type view struct {
|
||||
v ReservedVersion
|
||||
arts map[string]meshcatalog.Artifact // reference -> its catalog artifact
|
||||
}
|
||||
|
||||
// queueEvent queues, for each holder (module -> the seats it claims), the unreleased versions whose missing artifacts
|
||||
// that holder's seats take: newest keys first, at most Max versions in all (one key per module and MAJOR.MINOR is the
|
||||
// reservation's own).
|
||||
func (r *Republisher) queueEvent(ctx context.Context, holders map[string][]string) ([]string, error) {
|
||||
over, err := r.Reserved.Overdue(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var vs []ReservedVersion
|
||||
for _, o := range over {
|
||||
if v, ok, err := r.Reserved.Of(ctx, o.Module, o.Version); err == nil && ok {
|
||||
vs = append(vs, v)
|
||||
}
|
||||
}
|
||||
return r.queue(ctx, vs, func(seat string) []string { return holdersOf(holders, seat) }, r.Max)
|
||||
}
|
||||
|
||||
func holdersOf(holders map[string][]string, seat string) []string {
|
||||
var out []string
|
||||
for m, seats := range holders {
|
||||
if slices.Contains(seats, seat) {
|
||||
out = append(out, m)
|
||||
}
|
||||
}
|
||||
sort.Strings(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// queue queues vs newest first, at most max of them (0 is no limit), each artifact to the first holder holdersOf names for
|
||||
// its seat. It answers the versions queued, `<module> <version>`.
|
||||
func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf func(seat string) []string, max int) ([]string, error) {
|
||||
@@ -461,11 +337,34 @@ func (r *Republisher) Ended(ctx context.Context, module, version string) ([]stri
|
||||
type Queued struct {
|
||||
Queue []QueuedPublish `json:"queue"`
|
||||
Acted map[string]uint64 `json:"acted"`
|
||||
// Items are the publish items (design 47 G A-457a), each with its tries and its next try; an item that ended says why.
|
||||
Items []PublishItem `json:"items"`
|
||||
}
|
||||
|
||||
// PublishItemKeyPrefix opens the key of a publish item in the builder's re-ask state.
|
||||
const PublishItemKeyPrefix = "publish."
|
||||
|
||||
// PublishItem is the builder's own record of a version's publish (design 47 G A-457a): a value of the re-ask state, its tries and
|
||||
// its next try. It is asked when the build ends and at the builder's start, rewritten with one more try and a longer pause after
|
||||
// each, and deleted when the version is released; after the setting's number of tries it ends, saying so (Answer), and stays.
|
||||
type PublishItem struct {
|
||||
Module string `json:"module"`
|
||||
Version string `json:"version"`
|
||||
Tries int `json:"tries"`
|
||||
NextTry time.Time `json:"next-try"`
|
||||
Why string `json:"why,omitempty"`
|
||||
Answer string `json:"answer,omitempty"`
|
||||
Answered time.Time `json:"answered,omitzero"`
|
||||
}
|
||||
|
||||
// PublishItemKey is the key of module's version's publish item.
|
||||
func PublishItemKey(module, version string) string {
|
||||
return PublishItemKeyPrefix + EscapeToken(module) + "." + EscapeToken(version)
|
||||
}
|
||||
|
||||
// AnswerQueue is builder_publish_queue over the two sections as the tools bundle reads them.
|
||||
func AnswerQueue(queue, acted Reader) (Queued, error) {
|
||||
out := Queued{Queue: []QueuedPublish{}, Acted: map[string]uint64{}}
|
||||
func AnswerQueue(queue, acted, reasks Reader) (Queued, error) {
|
||||
out := Queued{Queue: []QueuedPublish{}, Acted: map[string]uint64{}, Items: []PublishItem{}}
|
||||
keys, err := queue.Keys()
|
||||
if err != nil {
|
||||
return out, fmt.Errorf("the state %s cannot be listed: %w", PublishQueueState, err)
|
||||
@@ -500,13 +399,32 @@ func AnswerQueue(queue, acted Reader) (Queued, error) {
|
||||
out.Acted[k] = a.Sequence
|
||||
}
|
||||
}
|
||||
rkeys, err := reasks.Keys()
|
||||
if err != nil {
|
||||
return out, fmt.Errorf("the re-ask state cannot be listed: %w", err)
|
||||
}
|
||||
for _, k := range rkeys {
|
||||
if !strings.HasPrefix(k, PublishItemKeyPrefix) {
|
||||
continue
|
||||
}
|
||||
raw, ok, err := reasks.Get(k)
|
||||
if err != nil || !ok {
|
||||
continue
|
||||
}
|
||||
var it PublishItem
|
||||
if json.Unmarshal(raw, &it) == nil {
|
||||
out.Items = append(out.Items, it)
|
||||
}
|
||||
}
|
||||
sort.SliceStable(out.Items, func(i, j int) bool { return out.Items[i].NextTry.Before(out.Items[j].NextTry) })
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PublishQueueDescription is builder_publish_queue's description.
|
||||
const PublishQueueDescription = "The versions the builder will publish again (its state " + PublishQueueState + ", design 47 G section 588): per registry " +
|
||||
"seat holder, in the order they are sent, each with its artifacts' digests, when it was queued and whether its publish has begun; and the " +
|
||||
"keys of the state " + ActedState + ", the last stream sequence the builder acted on for each running and manifest-reads-changed subject. Read-only."
|
||||
"keys of the state " + ActedState + ", the last stream sequence the builder acted on for each subject; and the publish items (design 47 G " +
|
||||
"A-457a), each version's tries and next try, and why one ended after its tries. Read-only."
|
||||
|
||||
// PublishAgainDescription is builder_publish_again's description.
|
||||
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
@@ -26,7 +25,6 @@ type republishBed struct {
|
||||
*Republisher
|
||||
reserved *reserveMem
|
||||
queue *queueMem
|
||||
acted *reserveMem
|
||||
now time.Time
|
||||
sent []Publish
|
||||
said []string
|
||||
@@ -37,9 +35,9 @@ type republishBed struct {
|
||||
|
||||
func newRepublishBed(t *testing.T, max int) *republishBed {
|
||||
t.Helper()
|
||||
b := &republishBed{reserved: &reserveMem{mem: newMem()}, queue: &queueMem{reserveMem: &reserveMem{mem: newMem()}}, acted: &reserveMem{mem: newMem()}, now: time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC)}
|
||||
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, Acted: b.acted, Max: max, Now: func() time.Time { return b.now }, Go: func(f func()) { f() },
|
||||
b.Republisher = &Republisher{Reserved: res, Queue: b.queue, Max: max, 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
|
||||
@@ -82,89 +80,38 @@ func (b *republishBed) reserve(t *testing.T, module string) ReservedVersion {
|
||||
return v
|
||||
}
|
||||
|
||||
func running(node, module, fp string, stopped bool) (string, []byte) {
|
||||
data, _ := json.Marshal(nodeengine.Running{Node: node, Module: module, Fingerprint: fp, Stopped: stopped, At: time.Unix(1, 0)})
|
||||
return nodeengine.SubjectRunning(node, module), data
|
||||
}
|
||||
|
||||
// TestRepublish: design 47 G §588 (A-73, A-76): a reserved version left unpublished is published again, on a registry
|
||||
// holder's running and on its node's returned, once per message by its stream sequence, as a publish by digest with no parts,
|
||||
// at most the setting's number per event, newest first; an artifact no store holds is said once and not tried again.
|
||||
func TestRepublish(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
t.Run("running of a holder, once per sequence", func(t *testing.T) {
|
||||
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)
|
||||
v := b.reserve(t, "m")
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
if v.Fingerprint != "src2:m" {
|
||||
t.Fatalf("the reservation keeps the entry's fingerprint: %q", v.Fingerprint)
|
||||
}
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
for _, seq := range []uint64{5, 4} { // 4 is older than the acted 5: it starts nothing
|
||||
if _, err := b.Heard(ctx, subject, data, seq); err != nil || len(b.sent) != 1 {
|
||||
t.Fatalf("seq %d: sent %d (%v), want 1", seq, len(b.sent), err)
|
||||
}
|
||||
if q, err := b.QueueDone(ctx); err != nil || len(b.sent) != 1 || fmt.Sprint(q) != "[m "+v.Version+"]" {
|
||||
t.Fatalf("queued %v sent %d (%v), want 1", q, len(b.sent), err)
|
||||
}
|
||||
p := b.sent[0]
|
||||
if p.Seat != SeatArtifacts || p.Name != "m/prog" || p.Kind != "bundle" || p.Version != v.Version || p.Digest != "sha256:aa" || p.Fingerprint != "src2:m" ||
|
||||
p.Transfer != "republish-m-"+strings.ReplaceAll(v.Version, ".", "-")+"-prog" || strings.ContainsAny(p.Transfer, "/. *>") {
|
||||
t.Errorf("sent %+v, want the bundle by digest to the oci seat, the Go package left to its own seat's holder", p)
|
||||
}
|
||||
if _, err := b.Heard(ctx, subject, data, 5); err != nil || len(b.sent) != 1 {
|
||||
t.Errorf("the same sequence read again sent %d, want still 1", len(b.sent))
|
||||
}
|
||||
if _, err := b.Heard(ctx, subject, data, 6); err != nil || len(b.sent) != 2 {
|
||||
t.Errorf("a newer sequence sent %d, want 2", len(b.sent))
|
||||
}
|
||||
if keys, _ := b.queue.KeysOf(ctx, AllFilter); len(keys) != 0 {
|
||||
t.Errorf("a key stays in the queue after its outcome: %v", keys)
|
||||
}
|
||||
})
|
||||
t.Run("a build's end queues its version at the holders, without any event (A-473)", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
b.now = b.now.Add(time.Minute)
|
||||
v, err := b.Reserved.Reserve(ctx, "m", "0.1", []string{"m:prog", "m:lib"}, Source{Fingerprint: "src2:m"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := b.Ended(ctx, "m", v.Version); err != nil || len(b.sent) != 0 {
|
||||
t.Fatalf("a build not ended sent %d (%v)", len(b.sent), err)
|
||||
}
|
||||
for ref, d := range map[string]string{"m:prog": "sha256:aa", "m:lib": "sha256:bb"} {
|
||||
if _, err := b.Reserved.Built(ctx, "m", v.Version, ref, d, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if queued, err := b.Ended(ctx, "m", v.Version); err != nil || len(queued) != 1 || len(b.sent) != 1 || b.sent[0].Name != "m/prog" || b.sent[0].Digest != "sha256:aa" {
|
||||
t.Fatalf("the ended build queued %v, sent %+v (%v), want the bundle at the oci holder", queued, b.sent, err)
|
||||
}
|
||||
})
|
||||
t.Run("returned acts at the seat's holder, started does not", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
for i, why := range []string{nodeengine.ManifestReadsChangedWhyStarted, "", nodeengine.ManifestReadsChangedWhyReturned} {
|
||||
ev, _ := json.Marshal(nodeengine.ManifestReadsChanged{Node: "n1", Why: why})
|
||||
handled, err := b.Heard(ctx, nodeengine.SubjectManifestReadsChanged("n1"), ev, uint64(10+i))
|
||||
if !handled || err != nil {
|
||||
t.Fatalf("%q: handled %v, %v", why, handled, err)
|
||||
}
|
||||
if want := map[string]int{"started": 0, "": 0, "returned": 1}[why]; len(b.sent) != want {
|
||||
t.Errorf("why %q: sent %d, want %d", why, len(b.sent), want)
|
||||
}
|
||||
}
|
||||
if handled, _ := b.Heard(ctx, "mesh.seat.node-engine.event.composed.n1", nil, 1); handled {
|
||||
t.Error("a subject that is neither is taken as its own")
|
||||
}
|
||||
})
|
||||
t.Run("the setting limits an event, newest first", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 2)
|
||||
var versions []string
|
||||
for _, m := range []string{"m1", "m2", "m3"} {
|
||||
versions = append(versions, b.reserve(t, m).Module)
|
||||
}
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
if _, err := b.Heard(ctx, subject, data, 1); err != nil {
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
if _, err := b.QueueDone(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(b.sent) != 2 || !strings.HasPrefix(b.sent[0].Name, "m3/") || !strings.HasPrefix(b.sent[1].Name, "m2/") {
|
||||
@@ -182,8 +129,8 @@ func TestRepublish(t *testing.T) {
|
||||
}
|
||||
return entry(ctx, fp)
|
||||
}
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
if _, err := b.Heard(ctx, subject, data, 1); err == nil || !strings.Contains(err.Error(), "src2:m1") {
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
if _, err := b.QueueDone(ctx); err == nil || !strings.Contains(err.Error(), "src2:m1") {
|
||||
t.Errorf("the unreadable entry is not said: %v", err)
|
||||
}
|
||||
if len(b.sent) != 1 || !strings.HasPrefix(b.sent[0].Name, "m2/") {
|
||||
@@ -194,9 +141,9 @@ func TestRepublish(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
b.refuse = "oci-artifact-registry's publish of m/prog: not stored: no blob sha256:aa"
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
_, _ = b.Heard(ctx, subject, data, 1)
|
||||
_, _ = b.Heard(ctx, subject, data, 2)
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
_, _ = b.QueueDone(ctx)
|
||||
_, _ = b.QueueDone(ctx)
|
||||
if len(b.sent) != 1 || len(b.said) != 1 || !strings.Contains(b.said[0], "not stored: ") {
|
||||
t.Errorf("sent %d, said %v: want one try and one saying of not stored", len(b.sent), b.said)
|
||||
}
|
||||
@@ -205,9 +152,9 @@ func TestRepublish(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
b.refuse = "the holder is full"
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
_, _ = b.Heard(ctx, subject, data, 1)
|
||||
_, _ = b.Heard(ctx, subject, data, 2)
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
_, _ = b.QueueDone(ctx)
|
||||
_, _ = b.QueueDone(ctx)
|
||||
if len(b.sent) != 2 || len(b.said) != 2 {
|
||||
t.Errorf("sent %d, said %v: want both events tried and said", len(b.sent), b.said)
|
||||
}
|
||||
@@ -216,8 +163,8 @@ func TestRepublish(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
b.queue.bytes = PublishQueueMiB << 20
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
_, _ = b.Heard(ctx, subject, data, 1)
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
_, _ = b.QueueDone(ctx)
|
||||
if len(b.sent) != 0 || len(b.said) != 1 || !strings.HasSuffix(b.said[0], QueueFull) {
|
||||
t.Errorf("sent %d, said %v, want nothing sent and queue full said", len(b.sent), b.said)
|
||||
}
|
||||
@@ -250,12 +197,16 @@ func TestRepublish(t *testing.T) {
|
||||
if _, err := b.Republish(ctx, "m1", "0.1.9"); err == nil {
|
||||
t.Error("a version no reservation holds is not refused")
|
||||
}
|
||||
subject, data := running("n1", "oci", "src2:holder", false)
|
||||
_, _ = b.Heard(ctx, subject, data, 1)
|
||||
answer, err := AnswerQueue(Reader{Keys: func() ([]string, error) { return nil, nil }}, Reader{Keys: func() ([]string, error) { return b.acted.KeysOf(ctx, AllFilter) },
|
||||
Get: func(k string) (json.RawMessage, bool, error) { v, _, ok, err := b.acted.Get(ctx, k); return v, ok, err }})
|
||||
if err != nil || answer.Acted[ActedKey(subject)] != 1 {
|
||||
t.Errorf("builder_publish_queue acted = %v (%v), want the running's sequence 1", answer.Acted, err)
|
||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||
_, _ = b.QueueDone(ctx)
|
||||
items := Reader{Keys: func() ([]string, error) { return []string{"publish.m.0.1.0", "reserve-done.m.x"}, nil },
|
||||
Get: func(k string) (json.RawMessage, bool, error) {
|
||||
return json.RawMessage(`{"mode":"publish","module":"m","version":"0.1.0","tries":3,"next-try":"2026-11-17T01:00:00Z","why":"w"}`), true, nil
|
||||
}}
|
||||
none := Reader{Keys: func() ([]string, error) { return nil, nil }}
|
||||
answer, err := AnswerQueue(none, none, items)
|
||||
if err != nil || len(answer.Items) != 1 || answer.Items[0].Tries != 3 || answer.Items[0].Version != "0.1.0" {
|
||||
t.Errorf("builder_publish_queue items = %+v (%v), want the one publish item with its tries", answer.Items, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -185,8 +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) != 2 || m.Config["republish-max-versions"].Default != float64(50) {
|
||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60 and republish-max-versions of 50 (design 47 G §588, §633)", m.Config)
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 5 || m.Config["republish-max-versions"].Default != float64(50) ||
|
||||
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)
|
||||
}
|
||||
// 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) {
|
||||
@@ -239,7 +240,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
||||
t.Errorf("process = %v", p)
|
||||
}
|
||||
env, _ := p["env"].(map[string]any)
|
||||
if len(env) != 3 || 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_REPUBLISH_MAX_FILE"] != "${dir:state}/republish-max-versions" || 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 {
|
||||
|
||||
@@ -149,11 +149,35 @@
|
||||
},
|
||||
"republish-max-versions": {
|
||||
"type": "number",
|
||||
"description": "the most versions one event of a registry holder queues to publish again, newest first (design 47 G section 588); the rest wait for the next event or builder_publish_again.",
|
||||
"description": "the most versions one start or one builder_publish_again queues to publish at once, newest first (design 47 G section 588); the rest wait for the next try or builder_publish_again.",
|
||||
"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).",
|
||||
"minimum": 1,
|
||||
"maximum": 3600,
|
||||
"trusted": false,
|
||||
"default": 30
|
||||
},
|
||||
"publish-pause-max": {
|
||||
"type": "number",
|
||||
"description": "minutes, the most a pause between a version's publish tries grows to (design 47 G A-457a).",
|
||||
"minimum": 1,
|
||||
"maximum": 1440,
|
||||
"trusted": false,
|
||||
"default": 30
|
||||
},
|
||||
"publish-tries": {
|
||||
"type": "number",
|
||||
"description": "how many times the builder tries a done build's publish before it ends loudly (log and condition) and leaves it readable in builder_publish_queue (design 47 G A-457a).",
|
||||
"minimum": 1,
|
||||
"maximum": 100,
|
||||
"trusted": false,
|
||||
"default": 8
|
||||
}
|
||||
},
|
||||
"logs": [
|
||||
@@ -207,6 +231,30 @@
|
||||
"mode": "0600",
|
||||
"content": "${config:republish-max-versions}"
|
||||
},
|
||||
{
|
||||
"id": "publish-pause",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/publish-pause",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:publish-pause}"
|
||||
},
|
||||
{
|
||||
"id": "publish-pause-max",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/publish-pause-max",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:publish-pause-max}"
|
||||
},
|
||||
{
|
||||
"id": "publish-tries",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/publish-tries",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:publish-tries}"
|
||||
},
|
||||
{
|
||||
"id": "builder",
|
||||
"type": "process",
|
||||
@@ -221,7 +269,10 @@
|
||||
"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_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"
|
||||
},
|
||||
"user": "mesh-delivery-builder",
|
||||
"health": {
|
||||
|
||||
Reference in New Issue
Block a user