Merge pull request 'builder: drain every holder a publish again queued at, whatever a later version met' (#224) from fix/builder-drain-after-entry-error into main
This commit was merged in pull request #224.
This commit is contained in:
@@ -316,7 +316,14 @@ func holdersOf(holders map[string][]string, seat string) []string {
|
||||
func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf func(seat string) []string, max int) ([]string, error) {
|
||||
sort.SliceStable(vs, func(i, j int) bool { return vs[i].At.After(vs[j].At) })
|
||||
var queued []string
|
||||
var errs []error
|
||||
started := map[string]bool{}
|
||||
// Every holder given a version is drained, whatever a later version met: a version queued and never drained waits forever.
|
||||
defer func() {
|
||||
for holder := range started {
|
||||
r.drainLater(ctx, holder)
|
||||
}
|
||||
}()
|
||||
for _, v := range vs {
|
||||
if max > 0 && len(queued) >= max {
|
||||
break
|
||||
@@ -327,7 +334,9 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf
|
||||
}
|
||||
e, err := r.Entry(ctx, v.Fingerprint)
|
||||
if err != nil {
|
||||
return queued, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err)
|
||||
// One version's unreadable entry leaves only that version unqueued; the others go on.
|
||||
errs = append(errs, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err))
|
||||
continue
|
||||
}
|
||||
byHolder := map[string]map[string]string{}
|
||||
for _, ref := range v.Missing() {
|
||||
@@ -368,10 +377,7 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf
|
||||
queued = append(queued, v.Module+" "+v.Version)
|
||||
}
|
||||
}
|
||||
for holder := range started {
|
||||
r.drainLater(ctx, holder)
|
||||
}
|
||||
return queued, nil
|
||||
return queued, errors.Join(errs...)
|
||||
}
|
||||
|
||||
// enqueue puts one holder's artifacts of a version in its queue: not again when it is queued already, and not past the
|
||||
|
||||
@@ -151,6 +151,25 @@ func TestRepublish(t *testing.T) {
|
||||
t.Errorf("sent %+v, want the two newest, m3 then m2", b.sent)
|
||||
}
|
||||
})
|
||||
t.Run("an entry that cannot be read stops neither the other versions nor the drain", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m1")
|
||||
b.reserve(t, "m2") // newest: queued before m1's entry is met
|
||||
entry := b.Entry
|
||||
b.Entry = func(ctx context.Context, fp string) (meshcatalog.CatalogEntry, error) {
|
||||
if fp == "src2:m1" {
|
||||
return meshcatalog.CatalogEntry{}, errors.New("no entry of fingerprint src2:m1 is kept")
|
||||
}
|
||||
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") {
|
||||
t.Errorf("the unreadable entry is not said: %v", err)
|
||||
}
|
||||
if len(b.sent) != 1 || !strings.HasPrefix(b.sent[0].Name, "m2/") {
|
||||
t.Errorf("sent %+v, want m2 drained though m1's entry cannot be read", b.sent)
|
||||
}
|
||||
})
|
||||
t.Run("an artifact no store holds is said once and not tried again", func(t *testing.T) {
|
||||
b := newRepublishBed(t, 50)
|
||||
b.reserve(t, "m")
|
||||
|
||||
Reference in New Issue
Block a user