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:
@@ -3,6 +3,8 @@ package selfcompose
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -33,10 +35,13 @@ const versionsVerb = "versions"
|
||||
type resolvedKey struct{ module, fp, version string }
|
||||
|
||||
// versionParts is a module's build at a version as resolved: its digests by artifact reference, or why not, and when that was found.
|
||||
// forgotten marks a resolution whose fetch failed (H-A-146): it stands as a failed one, and is asked again at the module's next want,
|
||||
// at the next compose by hand, or after resolveAgain.
|
||||
type versionParts struct {
|
||||
parts map[string]string
|
||||
failed string
|
||||
at time.Time
|
||||
parts map[string]string
|
||||
failed string
|
||||
at time.Time
|
||||
forgotten bool
|
||||
}
|
||||
|
||||
// registryVersions is the answer of either seat's verb `versions`: the two seats answer the same shape.
|
||||
@@ -125,6 +130,46 @@ func (c *Composer) resolve(module string, e meshcatalog.CatalogEntry, w meshwant
|
||||
return parts, ""
|
||||
}
|
||||
|
||||
// forgetFetched forgets every resolution that names digest, as its fetch failed for why (design 47 H, the lead's answer H-A-146; A-430a:
|
||||
// the bytes are fetched by the digest the versions answer gives): the store's answer may have been wrong, and a resolution kept for
|
||||
// the process's life would never see it fixed. Each is said in the journal; the module is held until the seat's verb versions is
|
||||
// asked again, at its next want, at the next compose by hand, or after resolveAgain. A resolution whose fetch succeeded is kept.
|
||||
func (c *Composer) forgetFetched(digest, why string) {
|
||||
if digest == "" {
|
||||
return
|
||||
}
|
||||
now := c.now()
|
||||
var lines []string
|
||||
c.mu.Lock()
|
||||
for k, r := range c.resolved {
|
||||
if r.failed != "" || !slices.Contains(slices.Collect(maps.Values(r.parts)), digest) {
|
||||
continue
|
||||
}
|
||||
line := fmt.Sprintf("resolution of %s %s forgotten: %s", k.module, k.version, why)
|
||||
c.resolved[k] = versionParts{failed: line + "; the seats' verb versions is asked again at its next want, at the next compose or in " + resolveAgain.String(),
|
||||
at: now, forgotten: true}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
c.mu.Unlock()
|
||||
sort.Strings(lines)
|
||||
for _, line := range lines {
|
||||
c.env.Say(line)
|
||||
}
|
||||
if len(lines) > 0 {
|
||||
time.AfterFunc(resolveAgain, c.askRehand)
|
||||
}
|
||||
}
|
||||
|
||||
// dropForgottenLocked ends the standing of every forgotten resolution (H-A-146), of module alone or, for "", of all: the next
|
||||
// pass asks the seats' verb versions again. Under mu.
|
||||
func (c *Composer) dropForgottenLocked(module string) {
|
||||
for k, r := range c.resolved {
|
||||
if r.forgotten && (module == "" || k.module == module) {
|
||||
delete(c.resolved, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// lookUp asks each artifact's digest at w's version of the seat of its kind. Every failure is said, naming the module, the version
|
||||
// and the seat; any failure resolves nothing of the build.
|
||||
func (c *Composer) lookUp(module string, e meshcatalog.CatalogEntry, w meshwants.WantsByWantNodeModuleValue) (map[string]string, string) {
|
||||
|
||||
Reference in New Issue
Block a user