B4 (2) other-bytes by fingerprint: an other-bytes answer for the publish's own fingerprint ends as published with the held digest
Builds: design 47 H2 H-A-738 (1)
This commit is contained in:
@@ -269,6 +269,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
}
|
||||
reserved.r.MovedFrom = reserved.movedFrom
|
||||
republish.Unstored = reserved.unstoredAgain
|
||||
republish.AsHeld = reserved.sayPublished // an artifact held for this very build is published as held (H-A-738 (1))
|
||||
reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
||||
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
|
||||
}
|
||||
|
||||
@@ -180,6 +180,9 @@ type Republisher struct {
|
||||
// Unstored is told the first artifact of a reservation a holder refused as not stored, with the reservation as it stood: the
|
||||
// builder builds the key again itself (design 47 H2 H-A-662); nil is told none.
|
||||
Unstored func(ctx context.Context, v ReservedVersion, ref, words string)
|
||||
// AsHeld is told each artifact a holder answered `other-bytes` for the publish's own fingerprint, newly marked published with the held
|
||||
// digest (design 47 H2 H-A-738 (1)): the builder says package-published of it; nil says none.
|
||||
AsHeld func(ctx context.Context, m Marked, digest string)
|
||||
// Ended ends the publish item of a version that never publishes, its reservation withdrawn or taken over (H-A-290 (2));
|
||||
// nil ends none.
|
||||
Ended func(ctx context.Context, module, version string)
|
||||
@@ -768,7 +771,7 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
||||
return SendFate{Ended: "none of its artifacts is left to send: each is published or refused as not stored"}
|
||||
}
|
||||
var failed []string
|
||||
sent, again := 0, false
|
||||
sent, held, again := 0, 0, false
|
||||
for _, ref := range refs {
|
||||
seat, name, kind, ok := publishTarget(e, q.Module, ref)
|
||||
if !ok {
|
||||
@@ -783,6 +786,25 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
||||
continue
|
||||
}
|
||||
var other *OtherBytes
|
||||
if errors.As(err, &other) && other.Fingerprint != "" && other.Fingerprint == v.Fingerprint {
|
||||
// The holder keeps this very build at the version, with the digest of an earlier run of it: the publish is answered as
|
||||
// published with the held digest, nothing stored (H-A-738 (1)).
|
||||
marked, _, merr := r.Reserved.MarkHeld(bound, q.Module, v.Version, []HeldArtifact{{Ref: ref, Seat: other.Seat, Name: other.Name,
|
||||
Version: other.Version, Digest: other.Digest, Fingerprint: other.Fingerprint}})
|
||||
if merr != nil {
|
||||
r.say(ctx, v, ref+": "+merr.Error())
|
||||
failed = append(failed, ref+": "+merr.Error())
|
||||
continue
|
||||
}
|
||||
r.say(ctx, v, fmt.Sprintf("%s %s: %s holds it for this build with the digest %s, built %s: published as held, nothing stored", ref, q.Version, other.Seat, other.Digest, q.Artifacts[ref]))
|
||||
for _, m := range marked {
|
||||
if r.AsHeld != nil {
|
||||
r.AsHeld(ctx, m, other.Digest)
|
||||
}
|
||||
}
|
||||
held++
|
||||
continue
|
||||
}
|
||||
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).
|
||||
@@ -813,6 +835,8 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
||||
switch {
|
||||
case len(failed) > 0:
|
||||
return SendFate{Failed: strings.Join(failed, "; ")}
|
||||
case sent == 0 && held > 0:
|
||||
return SendFate{Ended: "each artifact left is published as the holder holds it for this build"}
|
||||
case sent == 0:
|
||||
return SendFate{Ended: "each artifact left was refused as not stored"}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,19 @@ func TestRepublish(t *testing.T) {
|
||||
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("a version held with other bytes for the publish's own fingerprint ends as published with the held digest", func(t *testing.T) {
|
||||
// design 47 H2 H-A-738 (1): equal fingerprints answer as published, nothing stored, the held digest on the reservation
|
||||
b := newRepublishBed(t)
|
||||
v := b.reserve(t, "m")
|
||||
var said []string
|
||||
b.AsHeld = func(_ context.Context, m Marked, digest string) { said = append(said, m.Artifact+" "+digest) }
|
||||
b.other = &OtherBytes{Seat: SeatArtifacts, Name: "m/prog", Version: v.Version, Digest: "sha256:zz", Fingerprint: v.Fingerprint}
|
||||
f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now))
|
||||
cur, _, _ := b.Reserved.At(ctx, ReservedKey("m", "0.1"))
|
||||
if f.Ended == "" || f.Failed != "" || f.Sent || len(b.ended) != 0 || !cur.Published["m:prog"] || cur.Artifacts["m:prog"] != "sha256:zz" || fmt.Sprint(said) != "[m:prog sha256:zz]" {
|
||||
t.Errorf("%+v, ended %v, published %v, digest %q, said %v: want published with the held digest, said once, no refusal", f, b.ended, cur.Published, cur.Artifacts["m:prog"], said)
|
||||
}
|
||||
})
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user