H-A-303: a pass that holds a module for a part withheld composes the tool runner as it runs
The node-engine restarted the tool runner at every self-compose on three machines: a module held for a part that did not answer (the catalog half's entry, the registry seats' versions) had its slice of the runtime process rebuilt from what runs, with its fingerprint set to its want's and its files words dropped, so MESH_TOOL_MODULES and MESH_TOOL_ENV differed pass by pass. A held module's entries and words are now copied verbatim from the running process, after the fingerprints are laid, so a holding pass digests as what runs and writes no new revision; a module whose parts answered and changed is still composed from its build. The composition read's grants ask names the holder it asked and why, and says it once in the journal until the grants part answers again. Builds: design 47 H H-A-303 (1)-(3), H-A-306 (1)-(3); H-A-296
This commit is contained in:
@@ -161,7 +161,18 @@ func TestNatsAMoveIsAskedOfTheNodeAndTheVaultIsAskedInItsName(t *testing.T) {
|
||||
if err := conn.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, unknown := q.WithheldOf(t.Context(), "shell"); unknown != WithheldUnknown || got != nil {
|
||||
t.Errorf("with the grants part down, withheld = %+v (%q)", got, unknown)
|
||||
// H-A-303 (3), H-A-306: the part withheld and the holder asked are said in the read, and once in the journal.
|
||||
var journal []string
|
||||
sayWas := q.Say
|
||||
q.Say = func(s string) { journal = append(journal, s) }
|
||||
defer func() { q.Say = sayWas }()
|
||||
for range 2 {
|
||||
if got, unknown := q.WithheldOf(t.Context(), "shell"); !strings.HasPrefix(unknown, WithheldUnknown) ||
|
||||
!strings.Contains(unknown, "the seat mesh-grants's verb withheld") || got != nil {
|
||||
t.Errorf("with the grants part down, withheld = %+v (%q)", got, unknown)
|
||||
}
|
||||
}
|
||||
if len(journal) != 1 || !strings.Contains(journal[0], "the seat mesh-grants's verb withheld") {
|
||||
t.Errorf("the grants part withheld twice is said %q, want once naming the seat asked", journal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,10 @@ type Session struct {
|
||||
// Own is the module that is this node-engine (§527, §634): its discovery, finding writer and vault login names read it.
|
||||
// Nil names none, as a test's session does.
|
||||
Own *OwnName
|
||||
// withheldSaid says the grants part's withheld not answering was said in the journal, until it answers (WithheldOf);
|
||||
// guarded by withheldMu.
|
||||
withheldMu sync.Mutex
|
||||
withheldSaid bool
|
||||
// haveSay guards haveSaidFn and haveGoneFn (SetHaveSaid).
|
||||
haveSay sync.Mutex
|
||||
haveSaidFn func(module string, h nodeengine.HaveByNodeModuleValue)
|
||||
|
||||
@@ -11,9 +11,13 @@ import (
|
||||
// GrantsSeat is the seat of the grants part, whose verb withheld names the marked subjects withheld from a node's runtime.
|
||||
const GrantsSeat = "mesh-grants"
|
||||
|
||||
// WithheldUnknown is what a composition says when the grants part does not answer withheld (design 46 approval mark §6).
|
||||
// WithheldUnknown is what a composition says when the grants part does not answer withheld (design 46 approval mark §6),
|
||||
// followed by the holder it asked and why (design 47 H, H-A-303 (3), H-A-306).
|
||||
const WithheldUnknown = "withheld unknown: the grants part does not answer"
|
||||
|
||||
// withheldAsked names the holder the composition read asks what is withheld: the seat and its verb.
|
||||
const withheldAsked = "the seat " + GrantsSeat + "'s verb withheld"
|
||||
|
||||
// WithheldSubject is one marked subject withheld from this node's runtime, and why.
|
||||
type WithheldSubject struct {
|
||||
Subject string `json:"subject"`
|
||||
@@ -21,12 +25,14 @@ type WithheldSubject struct {
|
||||
}
|
||||
|
||||
// WithheldOf is what the grants part withholds of module on this node, asked through its verb withheld: the subjects, or,
|
||||
// when the verb does not answer or answers what is not its answer, WithheldUnknown as unknown.
|
||||
// when the verb does not answer (not answered, cut by its bound, no responders) or answers what is not its answer,
|
||||
// WithheldUnknown as unknown, naming the holder asked and why. That the part is withheld is said once in the journal
|
||||
// (Say), until it answers again (design 47 H, H-A-303 (3), H-A-306).
|
||||
func (q *Session) WithheldOf(ctx context.Context, module string) (subjects []WithheldSubject, unknown string) {
|
||||
raw, err := q.askCalled(ctx, GrantsSeat, "withheld", map[string]string{"node": q.Membership.Node}, VaultWithin,
|
||||
"the grants part's withheld")
|
||||
if err != nil {
|
||||
return nil, WithheldUnknown
|
||||
return nil, q.withheldUnknown("asked of " + withheldAsked + ", which did not answer: " + err.Error())
|
||||
}
|
||||
var answer struct {
|
||||
Node string `json:"node"`
|
||||
@@ -36,8 +42,11 @@ func (q *Session) WithheldOf(ctx context.Context, module string) (subjects []Wit
|
||||
} `json:"modules"`
|
||||
}
|
||||
if json.Unmarshal(raw, &answer) != nil || answer.Node != q.Membership.Node {
|
||||
return nil, WithheldUnknown
|
||||
return nil, q.withheldUnknown("asked of " + withheldAsked + ", which answered what is not its answer for " + q.Membership.Node)
|
||||
}
|
||||
q.withheldMu.Lock()
|
||||
q.withheldSaid = false
|
||||
q.withheldMu.Unlock()
|
||||
for _, m := range answer.Modules {
|
||||
if m.Module == module {
|
||||
subjects = append(subjects, m.Subjects...)
|
||||
@@ -45,3 +54,16 @@ func (q *Session) WithheldOf(ctx context.Context, module string) (subjects []Wit
|
||||
}
|
||||
return subjects, ""
|
||||
}
|
||||
|
||||
// withheldUnknown is WithheldUnknown with why, said once in the journal until the grants part answers again.
|
||||
func (q *Session) withheldUnknown(why string) string {
|
||||
unknown := WithheldUnknown + " (" + why + ")"
|
||||
q.withheldMu.Lock()
|
||||
said := q.withheldSaid
|
||||
q.withheldSaid = true
|
||||
q.withheldMu.Unlock()
|
||||
if !said && q.Say != nil {
|
||||
q.Say("the grants part is withheld from this node's composition read, which says " + unknown + " until it answers")
|
||||
}
|
||||
return unknown
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user