mesh-delivery-builder: builder_publish_again says a published, unreleased version's package-published again (H-A-773 (1); issues 1984, 1423)
A build whose two package-published deliveries the indexer gave up on (the watchman's 0.1.170) was published and never released, and no tool could release it. builder_publish_again now also takes a reservation whose artifacts are all published but whose version the catalog's verb versions does not hold, and says each artifact's package-published again, so the indexer releases it as at a first delivery; a released one is refused as before. The build's end's ask queues only (Republisher.Queue) and says nothing again. The hook that says a package-published (SayPublished, was AsHeld) answers its fault, so the tool's answer names what it said and refuses what the bus refused. Builds: design 47 H2 H-A-773 (1)
This commit is contained in:
@@ -274,7 +274,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
}
|
}
|
||||||
reserved.r.MovedFrom = reserved.movedFrom
|
reserved.r.MovedFrom = reserved.movedFrom
|
||||||
republish.Unstored = reserved.unstoredAgain
|
republish.Unstored = reserved.unstoredAgain
|
||||||
republish.AsHeld = reserved.sayPublished // an artifact held for this very build is published as held (H-A-738 (1))
|
// An artifact held for this very build is published as held (H-A-738 (1)); a published version the catalog holds no release of is
|
||||||
|
// said again by builder_publish_again (H-A-773 (1)).
|
||||||
|
republish.SayPublished = reserved.sayPublished
|
||||||
reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
||||||
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
|
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
|
||||||
}
|
}
|
||||||
@@ -325,7 +327,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
reserved: func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error) {
|
reserved: func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error) {
|
||||||
return reserved.r.Of(ctx, module, version)
|
return reserved.r.Of(ctx, module, version)
|
||||||
},
|
},
|
||||||
republish: republish.Republish,
|
republish: republish.Queue, // the build's end's ask queues only; builder_publish_again says a published version again (H-A-773 (1))
|
||||||
// A publish is asked again while the registry's record lacks it (H-A-269 (2), H-A-272; H-A-514 addendum: no backlog count).
|
// A publish is asked again while the registry's record lacks it (H-A-269 (2), H-A-272; H-A-514 addendum: no backlog count).
|
||||||
judge: func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
judge: func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
||||||
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
|
return republish.Held(ctx, v, registryVersionsVia(calls.Call))
|
||||||
|
|||||||
+2
-2
@@ -543,14 +543,14 @@ func TestThePublishQueueLosesNoItemAndNeverSendsADroppedItem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
rv.r.MovedFrom = rv.movedFrom
|
rv.r.MovedFrom = rv.movedFrom
|
||||||
republish.Unstored = rv.unstoredAgain
|
republish.Unstored = rv.unstoredAgain
|
||||||
republish.AsHeld = rv.sayPublished
|
republish.SayPublished = rv.sayPublished
|
||||||
rv.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
rv.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) {
|
||||||
return republish.Held(ctx, v, registryVersionsVia(conn.Call))
|
return republish.Held(ctx, v, registryVersionsVia(conn.Call))
|
||||||
}
|
}
|
||||||
rv.r.HeldElsewhere = func(ctx context.Context, module string, skipped []string) {
|
rv.r.HeldElsewhere = func(ctx context.Context, module string, skipped []string) {
|
||||||
rv.heldElsewhere(ctx, module, "the registries hold "+strings.Join(skipped, ", ")+", so the reserve skipped them")
|
rv.heldElsewhere(ctx, module, "the registries hold "+strings.Join(skipped, ", ")+", so the reserve skipped them")
|
||||||
}
|
}
|
||||||
items := &publishItems{now: time.Now, logf: t.Logf, unreleased: republish.Unreleased, republish: republish.Republish,
|
items := &publishItems{now: time.Now, logf: t.Logf, unreleased: republish.Unreleased, republish: republish.Queue,
|
||||||
dropMark: func(context.Context, string, string, string, string) error { return nil },
|
dropMark: func(context.Context, string, string, string, string) error { return nil },
|
||||||
reserved: func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error) {
|
reserved: func(ctx context.Context, module, version string) (versions.ReservedVersion, bool, error) {
|
||||||
return rv.r.Of(ctx, module, version)
|
return rv.r.Of(ctx, module, version)
|
||||||
|
|||||||
@@ -196,9 +196,14 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue
|
|||||||
if acts.Republish == nil {
|
if acts.Republish == nil {
|
||||||
err = errors.New("this builder publishes nothing again")
|
err = errors.New("this builder publishes nothing again")
|
||||||
} else {
|
} else {
|
||||||
r.Queued, err = acts.Republish(ctx, r.Module, r.Version)
|
var said []string
|
||||||
|
r.Queued, said, err = acts.Republish(ctx, r.Module, r.Version)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r.Answer = "queued " + fmt.Sprint(len(r.Queued)) + " versions to publish again: " + strings.Join(r.Queued, ", ") + "; builder_publish_queue shows them"
|
r.Answer = "queued " + fmt.Sprint(len(r.Queued)) + " versions to publish again: " + strings.Join(r.Queued, ", ") + "; builder_publish_queue shows them"
|
||||||
|
if len(said) > 0 {
|
||||||
|
// A published version the catalog holds no release of has its package-published said again (H-A-773 (1)).
|
||||||
|
r.Answer += "; said the package-published again of " + fmt.Sprint(len(said)) + " published versions the catalog holds no release of: " + strings.Join(said, ", ")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if r.Mode == build.ModePublishDrop {
|
} else if r.Mode == build.ModePublishDrop {
|
||||||
|
|||||||
@@ -501,17 +501,19 @@ func (rv *reservations) published(ctx context.Context, o versions.Outcome, inPro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sayPublished says the seat mesh-builds' package-published of an artifact a published marked.
|
// sayPublished says the seat mesh-builds' package-published of an artifact a published marked, and answers why it could not; the
|
||||||
func (rv *reservations) sayPublished(ctx context.Context, m versions.Marked, digest string) {
|
// log says both.
|
||||||
|
func (rv *reservations) sayPublished(ctx context.Context, m versions.Marked, digest string) error {
|
||||||
if rv.say == nil {
|
if rv.say == nil {
|
||||||
rv.logf("package-published of %s at %s not said: no seat to say it on", m.Artifact, m.Reserved.Version)
|
rv.logf("package-published of %s at %s not said: no seat to say it on", m.Artifact, m.Reserved.Version)
|
||||||
return
|
return errors.New("no seat to say it on")
|
||||||
}
|
}
|
||||||
if err := rv.say(ctx, m.PackagePublished(digest, time.Now())); err != nil {
|
if err := rv.say(ctx, m.PackagePublished(digest, time.Now())); err != nil {
|
||||||
rv.logf("the package-published of %s at %s is not said: %v", m.Artifact, m.Reserved.Version, err)
|
rv.logf("the package-published of %s at %s is not said: %v", m.Artifact, m.Reserved.Version, err)
|
||||||
} else {
|
return err
|
||||||
rv.logf("package-published said: %s at %s, digest %s", m.Artifact, m.Reserved.Version, digest)
|
|
||||||
}
|
}
|
||||||
|
rv.logf("package-published said: %s at %s, digest %s", m.Artifact, m.Reserved.Version, digest)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// dropped is builder_reserved_drop (design 47 H2 H-A-592): it names its version, and the reservation of the series is deleted whole
|
// dropped is builder_reserved_drop (design 47 H2 H-A-592): it names its version, and the reservation of the series is deleted whole
|
||||||
|
|||||||
@@ -681,6 +681,31 @@ func (e ansEntry) Revision() uint64 { return 1 }
|
|||||||
func (e ansEntry) Value() []byte { return e.value }
|
func (e ansEntry) Value() []byte { return e.value }
|
||||||
func (e ansEntry) Operation() jetstream.KeyValueOp { return jetstream.KeyValuePut }
|
func (e ansEntry) Operation() jetstream.KeyValueOp { return jetstream.KeyValuePut }
|
||||||
|
|
||||||
|
// TestPublishAgainAnswersTheVersionsItSaidAgain: design 47 H2 H-A-773 (1) — builder_publish_again's answer names, beside the
|
||||||
|
// versions it queued, the published versions the catalog holds no release of whose package-published it said again.
|
||||||
|
func TestPublishAgainAnswersTheVersionsItSaidAgain(t *testing.T) {
|
||||||
|
kv := &ansKV{wrote: make(chan []byte, 1)}
|
||||||
|
r := build.ReAsk{V: 1, Why: "its release was lost", By: "op@node", At: time.Now(), Mode: build.ModeRepublish, Module: "watchman"}
|
||||||
|
raw, _ := json.Marshal(r)
|
||||||
|
acts := versions.Acts{Republish: func(context.Context, string, string) ([]string, []string, error) {
|
||||||
|
return nil, []string{"watchman 0.1.170"}, nil
|
||||||
|
}}
|
||||||
|
versionActed(context.Background(), acts, kv, ansEntry{key: "republish.1", value: raw}, r, t.Logf)
|
||||||
|
var got build.ReAsk
|
||||||
|
select {
|
||||||
|
case v := <-kv.wrote:
|
||||||
|
if err := json.Unmarshal(v, &got); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
t.Fatal("the publish again was not answered")
|
||||||
|
}
|
||||||
|
if got.Refused || len(got.Queued) != 0 || !strings.Contains(got.Answer, "queued 0 versions") ||
|
||||||
|
!strings.Contains(got.Answer, "said the package-published again of 1 published versions the catalog holds no release of: watchman 0.1.170") {
|
||||||
|
t.Errorf("answered %q (queued %v, refused %v); want the version said again named", got.Answer, got.Queued, got.Refused)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// noAskKnown is a builder none of whose lanes waits: it records the keys asked again and builds, announces and releases nothing.
|
// noAskKnown is a builder none of whose lanes waits: it records the keys asked again and builds, announces and releases nothing.
|
||||||
type noAskKnown struct{ asked []string }
|
type noAskKnown struct{ asked []string }
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import (
|
|||||||
|
|
||||||
// Acts are the builder's hand acts on its versions, answered by its program (the tools bundle writes them to reasks).
|
// Acts are the builder's hand acts on its versions, answered by its program (the tools bundle writes them to reasks).
|
||||||
type Acts struct {
|
type Acts struct {
|
||||||
// Republish queues the reserved versions builder_publish_again names (design 47 G §588): the versions it queued.
|
// Republish queues the reserved versions builder_publish_again names (design 47 G §588): the versions it queued, and those whose
|
||||||
Republish func(ctx context.Context, module, version string) ([]string, error)
|
// package-published it said again, published and not released (design 47 H2 H-A-773 (1)).
|
||||||
|
Republish func(ctx context.Context, module, version string) (queued, said []string, err error)
|
||||||
// DropOldForm drops a retired node from the old form's count by hand (builder_old_form): its answer, or why not.
|
// DropOldForm drops a retired node from the old form's count by hand (builder_old_form): its answer, or why not.
|
||||||
DropOldForm func(ctx context.Context, node, by, why string, at time.Time) (string, error)
|
DropOldForm func(ctx context.Context, node, by, why string, at time.Time) (string, error)
|
||||||
// DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not.
|
// DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not.
|
||||||
|
|||||||
@@ -194,9 +194,11 @@ 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
|
// 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.
|
// 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)
|
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
|
// SayPublished says the package-published of an artifact marked published, with its digest, answering why it could not: each
|
||||||
// digest (design 47 H2 H-A-738 (1)): the builder says package-published of it; nil says none.
|
// artifact a holder answered `other-bytes` for the publish's own fingerprint, newly marked published with the held digest (design 47
|
||||||
AsHeld func(ctx context.Context, m Marked, digest string)
|
// H2 H-A-738 (1)), and each artifact of a published version whose release the catalog does not hold, said again by
|
||||||
|
// builder_publish_again (H-A-773 (1)); nil says none.
|
||||||
|
SayPublished func(ctx context.Context, m Marked, digest string) error
|
||||||
// Ended ends the publish item of a version that never publishes, its reservation withdrawn or taken over (H-A-290 (2));
|
// Ended ends the publish item of a version that never publishes, its reservation withdrawn or taken over (H-A-290 (2));
|
||||||
// nil ends none.
|
// nil ends none.
|
||||||
Ended func(ctx context.Context, module, version string)
|
Ended func(ctx context.Context, module, version string)
|
||||||
@@ -480,44 +482,134 @@ func (r *Republisher) enqueue(ctx context.Context, v ReservedVersion, holder str
|
|||||||
// Republish is builder_publish_again: with module and version, that reserved version's missing artifacts; with module
|
// Republish is builder_publish_again: with module and version, that reserved version's missing artifacts; with module
|
||||||
// alone, each reserved version of it whose artifacts are not all published; with neither, every version the finding
|
// alone, each reserved version of it whose artifacts are not all published; with neither, every version the finding
|
||||||
// version-unreleased names. It queues as the events do (no limit but the cap), at the holders Holders answers (design 47 G
|
// version-unreleased names. It queues as the events do (no limit but the cap), at the holders Holders answers (design 47 G
|
||||||
// A-416), and answers the versions it queued.
|
// A-416), and answers the versions it queued. A reservation it names whose artifacts are all published but whose version the
|
||||||
func (r *Republisher) Republish(ctx context.Context, module, version string) ([]string, error) {
|
// catalog does not hold, asked through the catalog's verb versions (Reserver.ReleasedOf), has the package-published of each
|
||||||
var vs []ReservedVersion
|
// artifact said again, so the indexer releases it as at a first delivery (design 47 H2 H-A-773 (1)): those it answers as said.
|
||||||
|
func (r *Republisher) Republish(ctx context.Context, module, version string) (queued, said []string, err error) {
|
||||||
|
vs, again, err := r.named(ctx, module, version, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
queued, qerr := r.queue(ctx, vs, r.holdersFn, 0, 0)
|
||||||
|
said, serr := r.sayAgain(ctx, again)
|
||||||
|
return queued, said, errors.Join(qerr, serr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queue is the publish of a version whose build is done, its first try at the build's end (A-473): the versions Republish names
|
||||||
|
// with an artifact unpublished, queued as Republish queues them; it says no package-published again.
|
||||||
|
func (r *Republisher) Queue(ctx context.Context, module, version string) ([]string, error) {
|
||||||
|
vs, _, err := r.named(ctx, module, version, false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return r.queue(ctx, vs, r.holdersFn, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// named are the reserved versions Republish names: those with an artifact unpublished (vs) and, with published, those whose
|
||||||
|
// artifacts are all published and whose version the catalog does not hold (again; H-A-773 (1)). With a module, a dropped publish
|
||||||
|
// is asked anew and none named is refused.
|
||||||
|
func (r *Republisher) named(ctx context.Context, module, version string, published bool) (vs, again []ReservedVersion, err error) {
|
||||||
if module == "" {
|
if module == "" {
|
||||||
over, err := r.Reserved.Overdue(ctx, nil)
|
over, err := r.Reserved.Overdue(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
for _, o := range over {
|
for _, o := range over {
|
||||||
if v, ok, err := r.Reserved.Of(ctx, o.Module, o.Version); err == nil && ok {
|
if v, ok, err := r.Reserved.Of(ctx, o.Module, o.Version); err == nil && ok {
|
||||||
vs = append(vs, v)
|
if len(v.Missing()) > 0 {
|
||||||
|
vs = append(vs, v)
|
||||||
|
} else if published {
|
||||||
|
again = append(again, v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return vs, again, nil
|
||||||
all, err := r.Reserved.All(ctx)
|
}
|
||||||
if err != nil {
|
all, err := r.Reserved.All(ctx)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
var released []string
|
||||||
|
read := false
|
||||||
|
for _, v := range all {
|
||||||
|
if v.Module != module || (version != "" && v.Version != version) {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
for _, v := range all {
|
if len(v.Missing()) > 0 {
|
||||||
if v.Module == module && (version == "" || v.Version == version) && len(v.Missing()) > 0 {
|
vs = append(vs, v)
|
||||||
vs = append(vs, v)
|
continue
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// builder_publish_again asks a dropped publish anew: the drop is cleared in the write before its put (H-A-746).
|
if !published || !publishedWhole(v) {
|
||||||
for i := range vs {
|
continue
|
||||||
if vs[i].Dropped == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if _, err := r.Reserved.ClearDropped(ctx, vs[i].Module, vs[i].Version); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
vs[i].Dropped = nil
|
|
||||||
}
|
}
|
||||||
if len(vs) == 0 {
|
if !read {
|
||||||
return nil, fmt.Errorf("%s holds no reserved version%s with an artifact unpublished", module, map[bool]string{true: " " + version, false: ""}[version != ""])
|
if released, err = r.Reserved.releasedOf(ctx, module); err != nil {
|
||||||
|
return nil, nil, fmt.Errorf("the catalog's versions of %s cannot be read, so its published versions are not said again: %w", module, err)
|
||||||
|
}
|
||||||
|
read = true
|
||||||
|
}
|
||||||
|
if !slices.Contains(released, v.Version) {
|
||||||
|
again = append(again, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.queue(ctx, vs, r.holdersFn, 0, 0)
|
// builder_publish_again asks a dropped publish anew: the drop is cleared in the write before its put (H-A-746).
|
||||||
|
for _, list := range [][]ReservedVersion{vs, again} {
|
||||||
|
for i := range list {
|
||||||
|
if list[i].Dropped == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err := r.Reserved.ClearDropped(ctx, list[i].Module, list[i].Version); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
list[i].Dropped = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(vs)+len(again) == 0 {
|
||||||
|
what := "with an artifact unpublished"
|
||||||
|
if published {
|
||||||
|
what += " or a published one the catalog holds no release of"
|
||||||
|
}
|
||||||
|
return nil, nil, fmt.Errorf("%s holds no reserved version%s %s", module, map[bool]string{true: " " + version, false: ""}[version != ""], what)
|
||||||
|
}
|
||||||
|
return vs, again, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// sayAgain says again the package-published of each published artifact of each of vs, versions whose artifacts are all published
|
||||||
|
// and whose release the catalog does not hold (design 47 H2 H-A-773 (1)), and answers the versions said, `<module> <version>`. A
|
||||||
|
// version whose reservation stands no more at it is said in the log and not said again; a package-published that cannot be said is
|
||||||
|
// the answer's fault.
|
||||||
|
func (r *Republisher) sayAgain(ctx context.Context, vs []ReservedVersion) ([]string, error) {
|
||||||
|
var said []string
|
||||||
|
var errs []error
|
||||||
|
for _, v := range vs {
|
||||||
|
if why := NotStanding(v, true); why != "" {
|
||||||
|
r.logf("publish again: the package-published of %s %s is not said again: %s", v.Module, v.Version, why)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r.SayPublished == nil {
|
||||||
|
errs = append(errs, fmt.Errorf("the package-published of %s %s cannot be said again: this builder says none", v.Module, v.Version))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var refs []string
|
||||||
|
for ref, ok := range v.Published {
|
||||||
|
if ok {
|
||||||
|
refs = append(refs, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Strings(refs)
|
||||||
|
whole := true
|
||||||
|
for _, ref := range refs {
|
||||||
|
if err := r.SayPublished(ctx, Marked{Reserved: v, Artifact: ref}, v.Artifacts[ref]); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("the package-published of %s at %s is not said again: %w", ref, v.Version, err))
|
||||||
|
whole = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if whole {
|
||||||
|
r.logf("publish again: %s %s is published and the catalog holds no release of it: the package-published of %s said again", v.Module, v.Version, strings.Join(refs, ", "))
|
||||||
|
said = append(said, v.Module+" "+v.Version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return said, errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queued is builder_publish_queue's answer, small at any size of the queue (design 47 H H-A-290 (5)): the queued versions'
|
// Queued is builder_publish_queue's answer, small at any size of the queue (design 47 H H-A-290 (5)): the queued versions'
|
||||||
@@ -666,8 +758,9 @@ const PublishDropDescription = "Drop one version's publish (design 47 H2 section
|
|||||||
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
||||||
"version's missing artifacts; with module alone, each reserved version of that module whose artifacts are not all published; with neither, every " +
|
"version's missing artifacts; with module alone, each reserved version of that module whose artifacts are not all published; with neither, every " +
|
||||||
"version the finding version-unreleased names, newest first. It queues them as the builder's publish items do, and answers at once " +
|
"version the finding version-unreleased names, newest first. It queues them as the builder's publish items do, and answers at once " +
|
||||||
"with the versions it queued; each outcome is said as package-published, or left in version-unreleased with the holder's words. A hand act, " +
|
"with the versions it queued; each outcome is said as package-published, or left in version-unreleased with the holder's words. A version " +
|
||||||
"recorded in the hand-act log."
|
"it names whose artifacts are all published but which the catalog's versions do not hold released has each artifact's package-published " +
|
||||||
|
"said again, so the catalog releases it as at a first delivery (design 47 H2 H-A-773). A hand act, recorded in the hand-act log."
|
||||||
|
|
||||||
// MoveQueued puts the values of the old state publish-queue on the work queue, once (§793): each under its message id, so a
|
// MoveQueued puts the values of the old state publish-queue on the work queue, once (§793): each under its message id, so a
|
||||||
// move run twice puts each once within the duplicates window; its class as of this run (a build ended before it is of the
|
// move run twice puts each once within the duplicates window; its class as of this run (a build ended before it is of the
|
||||||
@@ -809,8 +902,8 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate
|
|||||||
}
|
}
|
||||||
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]))
|
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 {
|
for _, m := range marked {
|
||||||
if r.AsHeld != nil {
|
if r.SayPublished != nil {
|
||||||
r.AsHeld(ctx, m, other.Digest)
|
_ = r.SayPublished(ctx, m, other.Digest) // a fault is said by the holder of the hook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
held++
|
held++
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func TestRepublish(t *testing.T) {
|
|||||||
if v.Fingerprint != "src2:m" {
|
if v.Fingerprint != "src2:m" {
|
||||||
t.Fatalf("the reservation keeps the entry's fingerprint: %q", v.Fingerprint)
|
t.Fatalf("the reservation keeps the entry's fingerprint: %q", v.Fingerprint)
|
||||||
}
|
}
|
||||||
if q, err := b.Republish(ctx, "", ""); err != nil || len(b.sent) != 1 || fmt.Sprint(q) != "[m "+v.Version+"]" {
|
if q, _, err := b.Republish(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)
|
t.Fatalf("queued %v sent %d (%v), want 1", q, len(b.sent), err)
|
||||||
}
|
}
|
||||||
p := b.sent[0]
|
p := b.sent[0]
|
||||||
@@ -140,6 +140,48 @@ func TestRepublish(t *testing.T) {
|
|||||||
t.Errorf("the work queue took %+v, want one live item at oci", b.puts)
|
t.Errorf("the work queue took %+v, want one live item at oci", b.puts)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
t.Run("a published version the catalog holds no release of is said again, a released one refused", func(t *testing.T) {
|
||||||
|
// design 47 H2 H-A-773 (1): its release was lost, so builder_publish_again says each artifact's package-published again,
|
||||||
|
// asking the catalog's verb versions; the build's end's ask says nothing again; a released one is refused as today
|
||||||
|
b := newRepublishBed(t)
|
||||||
|
v := b.reserve(t, "m")
|
||||||
|
if _, _, err := b.Reserved.MarkHeld(ctx, "m", v.Version, []HeldArtifact{{Ref: "m:prog", Digest: "sha256:aa"}, {Ref: "m:lib", Digest: "sha256:bb"}}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
|
var said []string
|
||||||
|
b.SayPublished = func(_ context.Context, m Marked, digest string) error {
|
||||||
|
said = append(said, m.Reserved.Version+" "+m.Artifact+" "+digest)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var released []string
|
||||||
|
var versionsErr error
|
||||||
|
b.Reserved.ReleasedOf = func(context.Context, string) ([]string, error) { return released, versionsErr }
|
||||||
|
if q, s, err := b.Republish(ctx, "m", ""); err != nil || len(q) != 0 || fmt.Sprint(s) != "[m "+v.Version+"]" || len(b.puts) != 0 ||
|
||||||
|
fmt.Sprint(said) != "["+v.Version+" m:lib sha256:bb "+v.Version+" m:prog sha256:aa]" {
|
||||||
|
t.Fatalf("module alone: queued %v, said %v (%v), puts %d, package-published %v; want both artifacts said again, nothing queued", q, s, err, len(b.puts), said)
|
||||||
|
}
|
||||||
|
if _, s, err := b.Republish(ctx, "m", v.Version); err != nil || len(s) != 1 || len(said) != 4 {
|
||||||
|
t.Errorf("module and version: said %v (%v), package-published %v; want it said again", s, err, said)
|
||||||
|
}
|
||||||
|
if _, err := b.Queue(ctx, "m", v.Version); err == nil || len(said) != 4 {
|
||||||
|
t.Errorf("the build's end's ask: %v, package-published %v; want refused as nothing is left to queue, nothing said again", err, said)
|
||||||
|
}
|
||||||
|
versionsErr = errors.New("no holder of mesh-catalog answered")
|
||||||
|
if _, _, err := b.Republish(ctx, "m", v.Version); err == nil || !strings.Contains(err.Error(), "cannot be read") || len(said) != 4 {
|
||||||
|
t.Errorf("the catalog's versions unread: %v, package-published %v; want refused, nothing said", err, said)
|
||||||
|
}
|
||||||
|
versionsErr = nil
|
||||||
|
say := b.SayPublished
|
||||||
|
b.SayPublished = func(context.Context, Marked, string) error { return errors.New("nats: jetstream not enabled") }
|
||||||
|
if _, s, err := b.Republish(ctx, "m", v.Version); err == nil || !strings.Contains(err.Error(), "jetstream not enabled") || len(s) != 0 {
|
||||||
|
t.Errorf("a package-published the bus refuses: said %v (%v); want the refusal answered, nothing said", s, err)
|
||||||
|
}
|
||||||
|
b.SayPublished, released = say, []string{v.Version}
|
||||||
|
if _, s, err := b.Republish(ctx, "m", v.Version); err == nil || len(s) != 0 || len(said) != 4 {
|
||||||
|
t.Errorf("a released version: said %v (%v); want it refused as today", s, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
t.Run("an entry that cannot be read stops neither the other versions nor the drain", func(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)
|
b := newRepublishBed(t)
|
||||||
b.reserve(t, "m1")
|
b.reserve(t, "m1")
|
||||||
@@ -152,7 +194,7 @@ func TestRepublish(t *testing.T) {
|
|||||||
return entry(ctx, fp)
|
return entry(ctx, fp)
|
||||||
}
|
}
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
if _, err := b.Republish(ctx, "", ""); err == nil || !strings.Contains(err.Error(), "src2:m1") {
|
if _, _, err := b.Republish(ctx, "", ""); err == nil || !strings.Contains(err.Error(), "src2:m1") {
|
||||||
t.Errorf("the unreadable entry is not said: %v", err)
|
t.Errorf("the unreadable entry is not said: %v", err)
|
||||||
}
|
}
|
||||||
if len(b.sent) != 1 || !strings.HasPrefix(b.sent[0].Name, "m2/") {
|
if len(b.sent) != 1 || !strings.HasPrefix(b.sent[0].Name, "m2/") {
|
||||||
@@ -164,8 +206,8 @@ func TestRepublish(t *testing.T) {
|
|||||||
b.reserve(t, "m")
|
b.reserve(t, "m")
|
||||||
b.refuse = "oci-artifact-registry's publish of m/prog: not stored: no blob sha256:aa"
|
b.refuse = "oci-artifact-registry's publish of m/prog: not stored: no blob sha256:aa"
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
if len(b.sent) != 1 || len(b.said) != 1 || !strings.Contains(b.said[0], "not stored: ") {
|
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)
|
t.Errorf("sent %d, said %v: want one try and one saying of not stored", len(b.sent), b.said)
|
||||||
}
|
}
|
||||||
@@ -206,7 +248,10 @@ func TestRepublish(t *testing.T) {
|
|||||||
b := newRepublishBed(t)
|
b := newRepublishBed(t)
|
||||||
v := b.reserve(t, "m")
|
v := b.reserve(t, "m")
|
||||||
var said []string
|
var said []string
|
||||||
b.AsHeld = func(_ context.Context, m Marked, digest string) { said = append(said, m.Artifact+" "+digest) }
|
b.SayPublished = func(_ context.Context, m Marked, digest string) error {
|
||||||
|
said = append(said, m.Artifact+" "+digest)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
b.other = &OtherBytes{Seat: SeatArtifacts, Name: "m/prog", Version: v.Version, Digest: "sha256:zz", Fingerprint: v.Fingerprint}
|
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))
|
f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now))
|
||||||
cur, _, _ := b.Reserved.At(ctx, ReservedKey("m", "0.1"))
|
cur, _, _ := b.Reserved.At(ctx, ReservedKey("m", "0.1"))
|
||||||
@@ -235,8 +280,8 @@ func TestRepublish(t *testing.T) {
|
|||||||
b.reserve(t, "m")
|
b.reserve(t, "m")
|
||||||
b.refuse = "the holder is full"
|
b.refuse = "the holder is full"
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
if len(b.sent) != 2 || len(b.said) != 2 {
|
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)
|
t.Errorf("sent %d, said %v: want both events tried and said", len(b.sent), b.said)
|
||||||
}
|
}
|
||||||
@@ -246,7 +291,7 @@ func TestRepublish(t *testing.T) {
|
|||||||
b.reserve(t, "m")
|
b.reserve(t, "m")
|
||||||
b.full = true
|
b.full = true
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
if len(b.sent) != 0 || len(b.said) != 1 || !strings.HasSuffix(b.said[0], QueueFull) {
|
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)
|
t.Errorf("sent %d, said %v, want nothing sent and queue full said", len(b.sent), b.said)
|
||||||
}
|
}
|
||||||
@@ -256,8 +301,8 @@ func TestRepublish(t *testing.T) {
|
|||||||
v := b.reserve(t, "m")
|
v := b.reserve(t, "m")
|
||||||
b.window, b.held = true, true
|
b.window, b.held = true, true
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
q1, _ := b.Republish(ctx, "m", v.Version)
|
q1, _, _ := b.Republish(ctx, "m", v.Version)
|
||||||
q2, _ := b.Republish(ctx, "m", v.Version)
|
q2, _, _ := b.Republish(ctx, "m", v.Version)
|
||||||
if len(b.puts) != 1 || len(q1) != 1 || len(q2) != 1 {
|
if len(b.puts) != 1 || len(q1) != 1 || len(q2) != 1 {
|
||||||
t.Errorf("puts %d, queued %v then %v: want one item, queued both times", len(b.puts), q1, q2)
|
t.Errorf("puts %d, queued %v then %v: want one item, queued both times", len(b.puts), q1, q2)
|
||||||
}
|
}
|
||||||
@@ -288,19 +333,19 @@ func TestRepublish(t *testing.T) {
|
|||||||
b := newRepublishBed(t)
|
b := newRepublishBed(t)
|
||||||
b.reserve(t, "m1")
|
b.reserve(t, "m1")
|
||||||
b.reserve(t, "m2")
|
b.reserve(t, "m2")
|
||||||
if q, err := b.Republish(ctx, "", ""); err != nil || len(q) != 0 {
|
if q, _, err := b.Republish(ctx, "", ""); err != nil || len(q) != 0 {
|
||||||
t.Errorf("no holder named: queued %v (%v), want none", q, err)
|
t.Errorf("no holder named: queued %v (%v), want none", q, err)
|
||||||
}
|
}
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
q, err := b.Republish(ctx, "", "")
|
q, _, err := b.Republish(ctx, "", "")
|
||||||
if err != nil || fmt.Sprint(q) != "[m2 0.1.0 m1 0.1.0]" || len(b.sent) != 2 || b.sent[0].Seat != SeatArtifacts {
|
if err != nil || fmt.Sprint(q) != "[m2 0.1.0 m1 0.1.0]" || len(b.sent) != 2 || b.sent[0].Seat != SeatArtifacts {
|
||||||
t.Errorf("the tool with neither queued %v (%v), sent %+v: want both versions at oci, with no limit", q, err, b.sent)
|
t.Errorf("the tool with neither queued %v (%v), sent %+v: want both versions at oci, with no limit", q, err, b.sent)
|
||||||
}
|
}
|
||||||
if _, err := b.Republish(ctx, "m1", "0.1.9"); err == nil {
|
if _, _, err := b.Republish(ctx, "m1", "0.1.9"); err == nil {
|
||||||
t.Error("a version no reservation holds is not refused")
|
t.Error("a version no reservation holds is not refused")
|
||||||
}
|
}
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
_, _ = b.Republish(ctx, "", "")
|
_, _, _ = b.Republish(ctx, "", "")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,8 +425,8 @@ func TestAQueuedItemIsSentWhileItsBuildStands(t *testing.T) {
|
|||||||
live := b.reserve(t, "l")
|
live := b.reserve(t, "l")
|
||||||
b.held = true
|
b.held = true
|
||||||
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
b.holders = map[string][]string{SeatArtifacts: {"oci"}}
|
||||||
_, _ = b.Republish(ctx, "o", old.Version)
|
_, _, _ = b.Republish(ctx, "o", old.Version)
|
||||||
_, _ = b.Republish(ctx, "l", live.Version)
|
_, _, _ = b.Republish(ctx, "l", live.Version)
|
||||||
if len(b.puts) != 2 || b.puts[0].Class != PublishClassStart || b.puts[1].Class != PublishClassLive ||
|
if len(b.puts) != 2 || b.puts[0].Class != PublishClassStart || b.puts[1].Class != PublishClassLive ||
|
||||||
PublishEvent("oci", PublishClassLive, "l", live.Version) != "publish.oci.live.l.0=2E1=2E0" {
|
PublishEvent("oci", PublishClassLive, "l", live.Version) != "publish.oci.live.l.0=2E1=2E0" {
|
||||||
t.Errorf("puts %+v, want o again and l live, on publish.<holder>.<class>.<module>.<version>", b.puts)
|
t.Errorf("puts %+v, want o again and l live, on publish.<holder>.<class>.<module>.<version>", b.puts)
|
||||||
@@ -396,7 +441,7 @@ func TestAQueuedItemIsSentWhileItsBuildStands(t *testing.T) {
|
|||||||
t.Fatalf("withdrawn %v (%v)", ok, err)
|
t.Fatalf("withdrawn %v (%v)", ok, err)
|
||||||
}
|
}
|
||||||
if at == "put" {
|
if at == "put" {
|
||||||
if q, _ := b.Republish(ctx, "m", v.Version); len(q) != 0 {
|
if q, _, _ := b.Republish(ctx, "m", v.Version); len(q) != 0 {
|
||||||
t.Errorf("queued %v", q)
|
t.Errorf("queued %v", q)
|
||||||
}
|
}
|
||||||
} else if f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)); f.Ended == "" {
|
} else if f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)); f.Ended == "" {
|
||||||
@@ -504,13 +549,13 @@ func TestAQueuedItemIsSentWhileItsBuildStands(t *testing.T) {
|
|||||||
if found, err := b.Reserved.MarkDropped(ctx, "d", v.Version, "op@node", "a test drops it", b.now); err != nil || !found {
|
if found, err := b.Reserved.MarkDropped(ctx, "d", v.Version, "op@node", "a test drops it", b.now); err != nil || !found {
|
||||||
t.Fatalf("drop: %v %v", found, err)
|
t.Fatalf("drop: %v %v", found, err)
|
||||||
}
|
}
|
||||||
if _, err := b.Republish(ctx, "", ""); err != nil || len(b.puts) != 0 {
|
if _, _, err := b.Republish(ctx, "", ""); err != nil || len(b.puts) != 0 {
|
||||||
t.Errorf("an event put %d items (%v), want the dropped version passed over", len(b.puts), err)
|
t.Errorf("an event put %d items (%v), want the dropped version passed over", len(b.puts), err)
|
||||||
}
|
}
|
||||||
if f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)); f.Ended == "" || !strings.Contains(f.Ended, "op@node") || len(b.sent) != 0 {
|
if f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)); f.Ended == "" || !strings.Contains(f.Ended, "op@node") || len(b.sent) != 0 {
|
||||||
t.Errorf("a send of the dropped version answered %+v, sent %d: want it ended unsent, naming who dropped it", f, len(b.sent))
|
t.Errorf("a send of the dropped version answered %+v, sent %d: want it ended unsent, naming who dropped it", f, len(b.sent))
|
||||||
}
|
}
|
||||||
if _, err := b.Republish(ctx, "d", v.Version); err != nil || len(b.puts) != 1 {
|
if _, _, err := b.Republish(ctx, "d", v.Version); err != nil || len(b.puts) != 1 {
|
||||||
t.Errorf("builder_publish_again put %d items (%v), want the one", len(b.puts), err)
|
t.Errorf("builder_publish_again put %d items (%v), want the one", len(b.puts), err)
|
||||||
}
|
}
|
||||||
if cur, ok, err := b.Reserved.Of(ctx, "d", v.Version); err != nil || !ok || cur.Dropped != nil {
|
if cur, ok, err := b.Reserved.Of(ctx, "d", v.Version); err != nil || !ok || cur.Dropped != nil {
|
||||||
|
|||||||
@@ -726,6 +726,20 @@ type Unreleased struct {
|
|||||||
Missing []string
|
Missing []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// publishedWhole says whether v's build ended with every artifact a registry publishes published: a version the catalog then does
|
||||||
|
// not hold released is one whose release was lost (design 47 H2 H-A-773).
|
||||||
|
func publishedWhole(v ReservedVersion) bool {
|
||||||
|
return !v.BuiltAt.IsZero() && len(v.Published) > 0 && len(v.Missing()) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// releasedOf are the versions the catalog holds released for module, asked through its verb versions (ReleasedOf).
|
||||||
|
func (r *Reserver) releasedOf(ctx context.Context, module string) ([]string, error) {
|
||||||
|
if r.ReleasedOf == nil {
|
||||||
|
return nil, errors.New("this builder asks no catalog's versions")
|
||||||
|
}
|
||||||
|
return r.ReleasedOf(ctx, module)
|
||||||
|
}
|
||||||
|
|
||||||
// Overdue answers the reservations past the bound with an artifact not published.
|
// Overdue answers the reservations past the bound with an artifact not published.
|
||||||
func (r *Reserver) Overdue(ctx context.Context, published func(module, version, artifact string) bool) ([]Unreleased, error) {
|
func (r *Reserver) Overdue(ctx context.Context, published func(module, version, artifact string) bool) ([]Unreleased, error) {
|
||||||
keys, err := r.Store.KeysOf(ctx, AllFilter)
|
keys, err := r.Store.KeysOf(ctx, AllFilter)
|
||||||
|
|||||||
Reference in New Issue
Block a user