H-A-146: the bound before a failed resolution is asked again is the setting resolve-again-minutes
A failed resolution of a want's version, or one forgotten after a failed fetch, stood a minute written into the code; by principle 11 a bound is a setting with a default. The manifest declares resolve-again-minutes (1 to 60, default 1) and its file, the engine reads it at its start and hands it to the composer's Env. Builds: design 47 H H-A-146 (hq 26f5505e), principle 11
This commit is contained in:
@@ -1222,7 +1222,7 @@ func composerEnv(session *link.Session, node string, say func(string), hooks com
|
||||
Hear: session.Hear,
|
||||
// And a moved module's templates archive, in the artifact store, as every archive is fetched (issue 1126).
|
||||
Fetch: apply.Fetch,
|
||||
Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound, EntryUnanswered: hooks.entryUnanswered, EntryAsks: entryAsks(),
|
||||
Running: hooks.running, Unseal: hooks.unseal, Refused: hooks.refused, Held: hooks.held, Kept: hooks.kept, EntryNotFound: hooks.entryNotFound, EntryUnanswered: hooks.entryUnanswered, EntryAsks: entryAsks(), ResolveAgain: resolveAgainBound(),
|
||||
VaultAuthority: hooks.vaultAuthority, Certify: hooks.certify}
|
||||
if hooks.seatList != nil {
|
||||
env.SeatList, env.SeatListChanged = hooks.seatList.reader, hooks.seatList.changed
|
||||
|
||||
@@ -94,4 +94,21 @@ func TestTheViewWaitsBoundIsTheManifestsSetting(t *testing.T) {
|
||||
if got := viewWaitsBound(); got != 5*time.Minute {
|
||||
t.Errorf("no file gives %v", got)
|
||||
}
|
||||
// H-A-146, principle 11: the bound after which a failed resolution is asked again is the file `resolve-again-minutes` feeds,
|
||||
// one minute when it holds nothing usable (1 to 60).
|
||||
wasAgain := resolveAgainFile
|
||||
defer func() { resolveAgainFile = wasAgain }()
|
||||
for content, want := range map[string]time.Duration{"7\n": 7 * time.Minute, "60": time.Hour, "61": time.Minute, "": time.Minute, "0": time.Minute, "x": time.Minute} {
|
||||
resolveAgainFile = filepath.Join(t.TempDir(), "w")
|
||||
if err := os.WriteFile(resolveAgainFile, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := resolveAgainBound(); got != want {
|
||||
t.Errorf("the file %q gives %v, want %v", content, got, want)
|
||||
}
|
||||
}
|
||||
resolveAgainFile = filepath.Join(t.TempDir(), "missing")
|
||||
if got := resolveAgainBound(); got != time.Minute {
|
||||
t.Errorf("no file gives %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
"github.com/novox/mesh-host/internal/link"
|
||||
"github.com/novox/mesh-host/internal/seatwait"
|
||||
"github.com/novox/mesh-host/internal/selfcompose"
|
||||
)
|
||||
|
||||
// The node-engine reads the seat list as every part does (novox/hq ADR 0635 §1, ADR 0636): through the seat mesh-catalog,
|
||||
@@ -281,6 +282,24 @@ func viewWaitsBound() time.Duration {
|
||||
return time.Duration(n) * time.Minute
|
||||
}
|
||||
|
||||
// resolveAgainFile is the file the manifest declares with the content ${config:resolve-again-minutes} (design 47 H, H-A-146;
|
||||
// principle 11), read at the engine's start as recoveryWaitFile is.
|
||||
var resolveAgainFile = "/var/lib/mesh-host/resolve-again-minutes"
|
||||
|
||||
// resolveAgainBound is how long a failed resolution of a want's version stands before the registry seats' verb versions is asked
|
||||
// again: the file's minutes (1 to 60), selfcompose.DefaultResolveAgain when the file is missing, empty or not such a number.
|
||||
func resolveAgainBound() time.Duration {
|
||||
raw, err := os.ReadFile(resolveAgainFile)
|
||||
if err != nil {
|
||||
return selfcompose.DefaultResolveAgain
|
||||
}
|
||||
n, err := strconv.Atoi(strings.TrimSpace(string(raw)))
|
||||
if err != nil || n < 1 || n > 60 {
|
||||
return selfcompose.DefaultResolveAgain
|
||||
}
|
||||
return time.Duration(n) * time.Minute
|
||||
}
|
||||
|
||||
// entryAsksFile is the file the manifest declares with the content ${config:entry-asks} (design 47 H, H-A-60), read at the
|
||||
// engine's start as recoveryWaitFile is.
|
||||
var entryAsksFile = "/var/lib/mesh-host/entry-asks"
|
||||
|
||||
Reference in New Issue
Block a user