H-A-146: forget a resolution whose fetch failed, so versions is asked again
The engine kept a want's version resolved to a digest for its process's life even when the artifact store's fetch of that digest failed (404, or bytes not of the digest), so a fix of the store's answer never reached the node without a restart. A failed fetch now forgets every resolution naming that digest, says "resolution of <module> <version> forgotten: <why>" in the journal and holds the module; the seats' verb versions is asked again at the module's next want, at the next compose by hand, and after resolveAgain (the bound a failed lookup already has). A resolution whose fetch succeeded is kept. Builds: design 47 H H-A-146, G A-430a
This commit is contained in:
@@ -460,6 +460,7 @@ func (c *Composer) ComposeNow(ctx context.Context) (Pass, error) {
|
||||
return Pass{}, errors.New("the node's composer runs no loop now: it composes nothing until its agent starts again")
|
||||
}
|
||||
c.mu.Lock()
|
||||
c.dropForgottenLocked("") // a compose by hand asks again what a failed fetch made it forget (H-A-146)
|
||||
last := c.last
|
||||
c.mu.Unlock()
|
||||
if !last.At.IsZero() && time.Since(last.At) < askedWithin {
|
||||
@@ -857,6 +858,7 @@ func (c *Composer) takeWantLocked(u agent.Update) string {
|
||||
}
|
||||
delete(c.notTaken, module)
|
||||
delete(c.keptWants, module)
|
||||
c.dropForgottenLocked(module) // its next want asks again what a failed fetch made it forget (H-A-146)
|
||||
w, err := meshwants.DecodeWantsByWantNodeModuleValue(u.Value)
|
||||
if u.Deleted || err != nil || w.Removed || w.Fp == "" {
|
||||
delete(c.wants, module)
|
||||
@@ -1691,11 +1693,15 @@ func (r reader) Archive(ctx context.Context, url, digest string) ([]byte, error)
|
||||
defer cancel()
|
||||
body, err := r.c.env.Fetch(fetching, url)
|
||||
if r.c.note(err) != nil {
|
||||
// A resolution whose fetch failed is forgotten, and versions asked again (H-A-146).
|
||||
r.c.forgetFetched(digest, fmt.Sprintf("the fetch of %s failed: %v", url, err))
|
||||
return nil, err
|
||||
}
|
||||
sum := sha256.Sum256(body)
|
||||
if got := "sha256:" + hex.EncodeToString(sum[:]); got != digest {
|
||||
return nil, fmt.Errorf("%s was recorded as %s and what arrived is %s", url, digest, got)
|
||||
err := fmt.Errorf("%s was recorded as %s and what arrived is %s", url, digest, got)
|
||||
r.c.forgetFetched(digest, "its fetch failed: "+err.Error())
|
||||
return nil, err
|
||||
}
|
||||
r.c.keepRead(func(k *Composer) { k.archives[digest] = body })
|
||||
return body, nil
|
||||
|
||||
Reference in New Issue
Block a user