selfcompose: the manifest of the build a module runs here is answered in one place; every step reads it there (A-484)
Entry of the running build, else the composition this node runs of it, else the module's trunk manifest through the seat mesh-catalog's verb module; said once per module and source; words naming the three where none answers. Read there: a held module's offer (frombus Scope.RunningManifest), FormChanges (A-483), the store holder and the stand of a running module without an entry (A-461d, A-480a), and the tool composition. Builds: design 47 G A-484, A-480, A-480a, A-483, A-461d, A-482
This commit is contained in:
+101
-95
@@ -296,14 +296,6 @@ func (c *Composer) wantedBuilds() map[string]bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The trunk build of a module this node runs without an entry of its wanted or running build is asked too (A-480a).
|
||||
for module, tb := range c.trunkBuilds {
|
||||
if tb.fp != "" && c.runsWithoutEntry(module) {
|
||||
if _, named := out[tb.fp]; !named {
|
||||
out[tb.fp] = false
|
||||
}
|
||||
}
|
||||
}
|
||||
// The build each module runs here, as the node's own record of it says: its entry, kept in the composition state, stays held
|
||||
// for the judgement of a move's data forms though the catalog half dropped it and no event of the stream names it.
|
||||
for _, r := range running {
|
||||
@@ -391,6 +383,11 @@ func (c *Composer) layModules() {
|
||||
c.sayOnceEach(line)
|
||||
}
|
||||
}()
|
||||
// Read before the lock: what the node runs is the agent's, and a read of it may wait.
|
||||
var running []engcomp.Composed
|
||||
if c.env.Running != nil {
|
||||
running = c.env.Running()
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
modules := map[string]meshcatalog.ModulesByModuleValue{}
|
||||
@@ -413,6 +410,19 @@ func (c *Composer) layModules() {
|
||||
c.manifests[digest] = raw
|
||||
return true
|
||||
}
|
||||
// layAnswer lays a module from the manifest the one place read of the build it runs (A-484): the entry's own fields, or the
|
||||
// trunk's answer, which holds none of an entry's checks.
|
||||
layAnswer := func(module string, a runningAnswer) bool {
|
||||
switch {
|
||||
case !a.Known:
|
||||
return false
|
||||
case a.Source == SourceTrunk:
|
||||
modules[module] = meshcatalog.ModulesByModuleValue{Fp2: a.FP, Manifest: a.Digest, Repository: a.Repository, Commit: a.Commit, Path: a.Path}
|
||||
c.manifests[a.Digest] = a.Raw
|
||||
return true
|
||||
}
|
||||
return lay(module, a.FP)
|
||||
}
|
||||
nodes := make([]string, 0, len(c.heard))
|
||||
for node := range c.heard {
|
||||
nodes = append(nodes, node)
|
||||
@@ -424,9 +434,7 @@ func (c *Composer) layModules() {
|
||||
// Where the running build has no entry, the module is laid from the entry of the build the assignment places
|
||||
// for that node, the mesh's truth of what it runs there (A-461); with neither it stays name-only below.
|
||||
if !lay(module, run.fingerprint) && node != c.env.Node {
|
||||
if built := c.placedBuild(node, module); built != "" && built != run.fingerprint {
|
||||
lay(module, built)
|
||||
}
|
||||
layAnswer(module, c.runningLocked(running, node, module, ""))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -446,9 +454,7 @@ func (c *Composer) layModules() {
|
||||
if _, laid := modules[pm.Module]; laid || !c.needsAddressOf(node, pm.Module) || !c.lacksEntry(node, pm.Module) {
|
||||
continue
|
||||
}
|
||||
if built := c.placedBuild(node, pm.Module); built != "" {
|
||||
lay(pm.Module, built)
|
||||
}
|
||||
layAnswer(pm.Module, c.runningLocked(running, node, pm.Module, ""))
|
||||
}
|
||||
}
|
||||
for module, w := range c.wants {
|
||||
@@ -471,14 +477,19 @@ func (c *Composer) layModules() {
|
||||
}
|
||||
continue
|
||||
}
|
||||
// Running here with no entry of its wanted or running build and none of the newest: it stands, for resolution alone, as its
|
||||
// trunk build, so the module that requires what it provides is no "nothing provides" (A-480a); its want stays held.
|
||||
if _, laid := modules[module]; !laid && c.runsWithoutEntry(module) {
|
||||
if tb := c.trunkBuilds[module]; tb.fp != "" && lay(module, tb.fp) {
|
||||
// Running here with no entry of its wanted build and none of the newest: it stands, for resolution alone, as the manifest of
|
||||
// the build it runs, from the one place (A-484), so the module that requires what it provides is no "nothing provides";
|
||||
// its want stays held. A running build whose entry is held is laid where it is heard (above) and is read by a held module's offer
|
||||
// through the one place alone, so it is not laid again here.
|
||||
if _, laid := modules[module]; !laid && c.countsAsRunning(module) {
|
||||
if a := c.runningLocked(running, c.env.Node, module, ""); a.Source != SourceEntry && layAnswer(module, a) {
|
||||
m := modules[module]
|
||||
m.Fp2 = w.Fp
|
||||
modules[module] = m
|
||||
said = append(said, fmt.Sprintf("%s runs a build whose manifest the node does not hold, so it counts what the trunk build %s of %s provides; its want stays held", module, tb.fp, module))
|
||||
said = append(said, fmt.Sprintf("%s runs a build whose entry the node does not hold, so it counts the manifest read from %s; its want stays held", module, a.Source))
|
||||
if a.Said != "" {
|
||||
said = append(said, a.Said)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -503,15 +514,12 @@ func (c *Composer) layModules() {
|
||||
c.modules = modules
|
||||
}
|
||||
|
||||
// placedBuild is the build the assignment places for module on node (c.mu held), the mesh's truth of what it runs there; where the
|
||||
// placement names none, the module's trunk build as syncEntries asked it (A-461b). Empty where neither is known.
|
||||
// placedBuild is the build the assignment places for module on node (c.mu held), the mesh's truth of what it runs there; empty
|
||||
// where the placement names none (the one place then asks the trunk's manifest, A-484).
|
||||
func (c *Composer) placedBuild(node, module string) string {
|
||||
for _, pm := range c.assignments[node].Modules {
|
||||
if pm.Module == module {
|
||||
if pm.Build != "" {
|
||||
return pm.Build
|
||||
}
|
||||
return c.trunkBuilds[module].fp
|
||||
return pm.Build
|
||||
}
|
||||
}
|
||||
return ""
|
||||
@@ -549,68 +557,40 @@ func (c *Composer) needsAddressOf(node, module string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// runsWithoutEntry says this node holds module on, as it runs it, and holds no entry of its wanted build nor of its running build
|
||||
// (c.mu held), and whose running event's manifest is not held (A-480a): the case where its
|
||||
// provisions are read from its trunk build (A-480a). A module built by hand before G says no running event (the engine says one only
|
||||
// of a build whose manifest it knows), so it counts as running when its have names a build in the phase running or held (A-482); one
|
||||
// wanted here that is heard running nowhere, runs nothing here and has no such have does not count.
|
||||
func (c *Composer) runsWithoutEntry(module string) bool {
|
||||
run := c.heard[c.env.Node][module]
|
||||
w, wanted := c.wants[module]
|
||||
if run.stopped || !wanted || w.Fp == "" || !(c.runsHere(module) || c.haveRuns[module]) {
|
||||
return false
|
||||
}
|
||||
// What is read decides (A-480a: "can be read from neither"): the manifest its running event names, where that digest is held;
|
||||
// a running composition's build is read as frombus ranOf reads it, only through the entry of the wanted fingerprint (the
|
||||
// loop below), so a composition at another build reads nothing.
|
||||
if _, read := c.manifests[run.manifest]; run.manifest != "" && read {
|
||||
return false
|
||||
}
|
||||
for _, fp := range []string{w.Fp, run.fingerprint} {
|
||||
if k, held := c.keptEnt[fp]; held && k.entry.Module != "" {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// askTrunkBuilds asks, for each module another node runs at a build with no entry and whose placement names no build, the trunk
|
||||
// build by the seat's verb `module`, once per running build (A-461b). Called before the lock is taken: the verb is a call.
|
||||
func (c *Composer) askTrunkBuilds() (wait func()) {
|
||||
type ask struct{ node, module, running string }
|
||||
var asks []ask
|
||||
var running []engcomp.Composed
|
||||
if c.env.Running != nil {
|
||||
running = c.env.Running()
|
||||
}
|
||||
c.mu.Lock()
|
||||
// The module whose running build's manifest the one place reads from the trunk, where neither its entry nor its composition
|
||||
// answers (A-484): the modules this node runs, and another node's module this node needs the address of (A-461, A-461d).
|
||||
for node, p := range c.assignments {
|
||||
for _, pm := range p.Modules {
|
||||
module := pm.Module
|
||||
// Only a module this node needs the address of (A-461): the store's holder, the provider of a requirement.
|
||||
if pm.Build != "" || !c.needsAddressOf(node, module) || !c.lacksEntry(node, module) || c.trunkAsking[module] {
|
||||
if c.trunkAsking[module] {
|
||||
continue
|
||||
}
|
||||
running := c.heard[node][module].fingerprint
|
||||
if had, asked := c.trunkBuilds[module]; !asked || had.running != running {
|
||||
asks = append(asks, ask{node, module, running})
|
||||
if c.trunkAsking == nil {
|
||||
c.trunkAsking = map[string]bool{}
|
||||
if node == c.env.Node {
|
||||
if !c.countsAsRunning(module) {
|
||||
continue
|
||||
}
|
||||
c.trunkAsking[module] = true
|
||||
} else if !c.needsAddressOf(node, module) || !c.lacksEntry(node, module) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
// A module this node runs whose wanted build and running build have no entry stands as its trunk build, for resolution alone
|
||||
// (A-480a): asked once per running build, as another node's is.
|
||||
for _, pm := range c.assignments[c.env.Node].Modules {
|
||||
module := pm.Module
|
||||
if !c.runsWithoutEntry(module) || c.trunkAsking[module] {
|
||||
continue
|
||||
}
|
||||
running := c.heard[c.env.Node][module].fingerprint
|
||||
if had, asked := c.trunkBuilds[module]; !asked || had.running != running {
|
||||
asks = append(asks, ask{c.env.Node, module, running})
|
||||
if c.trunkAsking == nil {
|
||||
c.trunkAsking = map[string]bool{}
|
||||
if a := c.runningLocked(running, node, module, ""); a.NeedTrunk {
|
||||
if had, asked := c.trunkBuilds[module]; !asked || had.running != a.RunFP {
|
||||
asks = append(asks, ask{node, module, a.RunFP})
|
||||
if c.trunkAsking == nil {
|
||||
c.trunkAsking = map[string]bool{}
|
||||
}
|
||||
c.trunkAsking[module] = true
|
||||
}
|
||||
}
|
||||
c.trunkAsking[module] = true
|
||||
}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
@@ -623,14 +603,22 @@ func (c *Composer) askTrunkBuilds() (wait func()) {
|
||||
go func() {
|
||||
defer all.Done()
|
||||
for a := range work {
|
||||
fp, why := c.trunkFp(a.module)
|
||||
t, why := c.trunkOf(a.module)
|
||||
fp := t.fp
|
||||
c.mu.Lock()
|
||||
delete(c.trunkAsking, a.module)
|
||||
if fp != "" {
|
||||
if c.trunkBuilds == nil {
|
||||
c.trunkBuilds = map[string]trunkBuild{}
|
||||
}
|
||||
c.trunkBuilds[a.module] = trunkBuild{running: a.running, fp: fp}
|
||||
t.running = a.running
|
||||
c.trunkBuilds[a.module] = t
|
||||
delete(c.trunkWhy, a.module)
|
||||
} else {
|
||||
if c.trunkWhy == nil {
|
||||
c.trunkWhy = map[string]string{}
|
||||
}
|
||||
c.trunkWhy[a.module] = why
|
||||
}
|
||||
c.mu.Unlock()
|
||||
if fp == "" {
|
||||
@@ -823,23 +811,34 @@ func (c *Composer) FormChanges(_ context.Context, module, runningFp, appliedFp s
|
||||
}
|
||||
return catalogue.Decode(raw)
|
||||
}
|
||||
running, err := read(runningFp)
|
||||
if err != nil {
|
||||
// A running build with no entry (one from before G): what it keeps on the bus is read from the composition it runs on this
|
||||
// node, as what it provides is (A-480). Where neither that composition nor the wanted build's manifest keeps data, no form
|
||||
// can change; where either does, the module still waits for the entry (A-113, A-483).
|
||||
// The manifest of the build the module runs is read in the one place (A-484): its entry, else the composition this node runs of
|
||||
// it, else the trunk's manifest. Where it reads no manifest, the composition says whether the running build keeps data: with
|
||||
// none on either side no form can change and the move goes on; where either keeps data, the move waits (A-113, A-483), with
|
||||
// the words naming the three sources tried.
|
||||
// The entry of the running build is asked of the catalog half (once), and kept when answered, as every entry the composer reads.
|
||||
if e, state := c.entryOf(runningFp); state == meshcatalogclient.EntryAnswered && e.Module != "" {
|
||||
c.mu.Lock()
|
||||
if _, kept := c.keptEnt[runningFp]; !kept {
|
||||
c.keptEnt[runningFp] = keptEntry{entry: e, since: c.now()}
|
||||
}
|
||||
c.mu.Unlock()
|
||||
}
|
||||
ra := c.runningManifest(c.env.Node, module, runningFp)
|
||||
var running catalogue.Manifest
|
||||
if ra.Known {
|
||||
var err error
|
||||
if running, err = catalogue.Decode(ra.Raw); err != nil {
|
||||
return nil, fmt.Errorf("%s's running manifest: %w", module, err)
|
||||
}
|
||||
} else {
|
||||
wanted, werr := read(appliedFp)
|
||||
if werr != nil {
|
||||
return nil, fmt.Errorf("%s's wanted manifest: %w", module, werr)
|
||||
}
|
||||
if c.env.Running != nil && len(wanted.DataItems()) == 0 {
|
||||
for _, r := range c.env.Running() {
|
||||
if r.Module == module && r.FP != "" && !r.Data {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
if ra.Source == SourceComposition && !ra.Data && len(wanted.DataItems()) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("%s's running manifest: %w", module, err)
|
||||
return nil, fmt.Errorf("%s's running manifest: %s", module, ra.Why)
|
||||
}
|
||||
applied, err := read(appliedFp)
|
||||
if err != nil {
|
||||
@@ -873,27 +872,34 @@ func (c *Composer) syncShadowEntries(ctx context.Context) (pending bool) {
|
||||
// moduleVerb is the seat mesh-catalog's verb `module`: one module's trunk fingerprint and manifest by name.
|
||||
const moduleVerb = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbModule
|
||||
|
||||
// trunkFp is the fingerprint of a module's trunk build, by the seat's verb `module`; empty with why where the catalog half gives none.
|
||||
func (c *Composer) trunkFp(module string) (fp, why string) {
|
||||
// trunkOf is a module's trunk build, by the seat's verb `module`: its fingerprint, manifest and where it is built from; empty with
|
||||
// why where the catalog half gives none.
|
||||
func (c *Composer) trunkOf(module string) (t trunkBuild, why string) {
|
||||
if c.env.Entry == nil {
|
||||
return "", "this node reads no module of the catalog half"
|
||||
return t, "this node reads no module of the catalog half"
|
||||
}
|
||||
raw, err := c.env.Entry(moduleVerb, meshcatalog.ModuleInput{Module: module})
|
||||
if err != nil {
|
||||
return "", fmt.Sprintf("the catalog half's answer for %s: %v", module, err)
|
||||
return t, fmt.Sprintf("the catalog half's answer for %s: %v", module, err)
|
||||
}
|
||||
answer, said, ok := buscalls.Unwrap(raw)
|
||||
if !ok {
|
||||
return "", fmt.Sprintf("the catalog half holds no module %s: %s", module, said)
|
||||
return t, fmt.Sprintf("the catalog half holds no module %s: %s", module, said)
|
||||
}
|
||||
var a meshcatalog.ModuleAnswer
|
||||
if err := json.Unmarshal(answer, &a); err != nil {
|
||||
return "", fmt.Sprintf("the catalog half's answer for %s cannot be read: %v", module, err)
|
||||
return t, fmt.Sprintf("the catalog half's answer for %s cannot be read: %v", module, err)
|
||||
}
|
||||
if a.Module.Fp == "" {
|
||||
return "", fmt.Sprintf("the catalog half gives %s no fingerprint: %s", module, a.Module.None)
|
||||
return t, fmt.Sprintf("the catalog half gives %s no fingerprint: %s", module, a.Module.None)
|
||||
}
|
||||
return a.Module.Fp, ""
|
||||
return trunkBuild{fp: a.Module.Fp, manifest: a.Module.Manifest, repository: a.Module.Repository, commit: a.Module.Commit, path: a.Module.Path}, ""
|
||||
}
|
||||
|
||||
// trunkFp is the fingerprint of a module's trunk build (trunkOf); empty with why where the catalog half gives none.
|
||||
func (c *Composer) trunkFp(module string) (fp, why string) {
|
||||
t, why := c.trunkOf(module)
|
||||
return t.fp, why
|
||||
}
|
||||
|
||||
// addedModule is the trunk's build of a module an assignment candidate adds to this node when no want here names it yet: the
|
||||
|
||||
Reference in New Issue
Block a user