diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go index f53a17617..034e6b461 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go @@ -62,6 +62,11 @@ func sendVia(call keptCaller) func(ctx context.Context, p versions.Publish) erro if err := json.Unmarshal(raw, &a); err != nil { return fmt.Errorf("%s answered what is no publish answer: %w", p.Seat, err) } + // A version held with other bytes is answered, never failed (design 47 H2 H-A-729); it is read before the transfer, which is + // absent exactly then (H-A-732). + if a.OtherBytes != nil { + return &versions.OtherBytes{Seat: p.Seat, Name: p.Name, Version: p.Version, Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } if len(a.Lacks) > 0 { return fmt.Errorf("%s%s holds %d of the parts of %s %s", versions.NotStoredWords, p.Seat, len(a.Lacks), p.Name, p.Version) } diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index 2610d9694..ef16d4f81 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -137,6 +137,21 @@ type Acted struct { Sequence uint64 `json:"sequence"` } +// OtherBytes is a holder's answer to a publish of a version it holds with other bytes (design 47 H2 H-A-589 (1), H-A-729): the +// digest, and the fingerprint it keeps for the version, empty where none is kept. It is an error of Send, which the publish item +// ends at, never as a refusal asked again: the build again of the fingerprint then takes the next free number (H-A-590 (1)). +type OtherBytes struct { + Seat, Name, Version, Digest, Fingerprint string +} + +func (o *OtherBytes) Error() string { + w := fmt.Sprintf("%s holds %s %s with other bytes: digest %s", o.Seat, o.Name, o.Version, o.Digest) + if o.Fingerprint != "" { + w += ", fingerprint " + o.Fingerprint + } + return w +} + // Publish is one artifact's publish again: what the registry seat's publish takes, without parts. type Publish struct { Seat, Kind, Name, Version, Digest, Fingerprint, Commit, Transfer string @@ -767,6 +782,15 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate sent++ continue } + var other *OtherBytes + if errors.As(err, &other) { + // A version the holder holds with other bytes is never published as it stands (ADR 0605 ยง4): the item ends at once, spending + // no try; the next build of the fingerprint withdraws the number and takes the next free one (H-A-590 (1), H-A-729). + words := fmt.Sprintf("%s %s: %s; built %s, so the number is held for another build and is not published again", ref, q.Version, other, q.Artifacts[ref]) + r.say(ctx, v, words) + r.end(ctx, q.Module, q.Version, words) + return SendFate{Ended: words} + } r.logf("publish again: %s %s: %s refused by %s: %v", q.Module, q.Version, ref, seat, err) words := err.Error() if strings.Contains(words, strings.TrimSuffix(NotStoredWords, ": ")) { diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 420572730..a89f02ca0 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -29,7 +29,8 @@ type republishBed struct { sent []Publish said []string ended []string - refuse string // the words Send fails with, empty for none + refuse string // the words Send fails with, empty for none + other *OtherBytes // the holder's answer of a version held with other bytes (H-A-729) // holders are the registry seats' holders the seat-holders view names (design 47 G A-416). holders map[string][]string // puts are the items the work queue took; window deduplicates by message id; full refuses every put; held keeps the puts @@ -58,6 +59,9 @@ func newRepublishBed(t *testing.T) *republishBed { b.mu.Lock() defer b.mu.Unlock() b.sent = append(b.sent, p) + if b.other != nil { + return b.other + } if b.refuse != "" { return errors.New(b.refuse) } @@ -184,6 +188,16 @@ func TestRepublish(t *testing.T) { t.Errorf("the reservation's upstream is %v, missing %v; want m:up filled once and not missing", cur.Upstream, cur.Missing()) } }) + t.Run("a version held with other bytes ends the item at once, no try spent", func(t *testing.T) { + // design 47 H2 H-A-590 (2), H-A-729: never asked again as it stands; the next build of the fingerprint takes another number + b := newRepublishBed(t) + v := b.reserve(t, "m") + b.other = &OtherBytes{Seat: SeatArtifacts, Name: "m/prog", Version: v.Version, Digest: "sha256:zz", Fingerprint: "src2:other"} + f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + if f.Ended == "" || f.Failed != "" || f.Sent || len(b.sent) != 1 || fmt.Sprint(b.ended) != "[m "+v.Version+"]" || !strings.Contains(f.Ended, "sha256:zz") { + t.Errorf("%+v, sent %d, ended %v: want the item ended at once naming the other digest, and no failure to try again", f, len(b.sent), b.ended) + } + }) t.Run("the first artifact refused as not stored starts the build again once", func(t *testing.T) { // design 47 H2 H-A-662, H-A-703: one start per reservation, whatever number of its artifacts are refused b := newRepublishBed(t)