mesh-grants: named asks stay in use while a wanted build invokes a queue; the named-asks decision is said (A-413, A-414)
Builds: design 47 G A-413, A-414
This commit is contained in:
@@ -42,9 +42,35 @@ func NamedAsksUnused(in Inputs) bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
// The manifest each machine is wanted to run counts as an entry of the revision too: a build taken from its want's newest
|
||||
// build (A-414) that invokes a queue keeps the named workers (A-413).
|
||||
for _, m := range in.Running {
|
||||
for _, i := range m.Invokes {
|
||||
if _, _, ok := catalogue.QueueInvoke(i); ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// namedAsksWhy says what decided whether the named asks are unused, for the journal.
|
||||
func namedAsksWhy(in Inputs, granted bool) string {
|
||||
switch {
|
||||
case in.CatalogUnread != "":
|
||||
return "the catalog half is unread"
|
||||
case len(in.Manifests) == 0:
|
||||
return "no manifest is held"
|
||||
case in.CarriedNamedAsks:
|
||||
return "a carried membership is granted to publish a named ask"
|
||||
case granted:
|
||||
return "a composed account is granted to publish a named ask"
|
||||
case NamedAsksUnused(in):
|
||||
return "no entry of the revision and no wanted build invokes a build seat's queue"
|
||||
}
|
||||
return "an entry of the revision or a wanted build invokes a build seat's queue"
|
||||
}
|
||||
|
||||
// withNoNamedAsks marks each pulled-by-kind seat a declaration holds as having no named worker while unused.
|
||||
func withNoNamedAsks(unused bool, d *buscompose.Declared) {
|
||||
for _, list := range []*[]buscompose.Seat{&d.Holds, &d.Uses, &d.Watches} {
|
||||
|
||||
@@ -53,6 +53,12 @@ func TestTheNamedAsksArePurgedAtTheFirstRevisionThatLeavesThem(t *testing.T) {
|
||||
Holds: []buscompose.Seat{{Name: "node-build-go", Scope: "node", Accepts: []string{"check"}, PulledByKind: true}}}}}}
|
||||
unused := Inputs{Manifests: map[string]catalogue.Manifest{"runner": {Module: "runner", Invokes: []string{"seat:node-build-go.run"}}}}
|
||||
used := Inputs{Manifests: map[string]catalogue.Manifest{"runner": {Module: "runner", Invokes: []string{"seat:node-build-go.accept.check"}}}}
|
||||
// A-414: a build taken from its want's newest build that invokes a queue keeps the named workers too.
|
||||
runs := unused
|
||||
runs.Running = map[string]catalogue.Manifest{"shanks.builder": {Module: "builder", Invokes: []string{"seat:node-build-go.accept.check"}}}
|
||||
if NamedAsksUnused(runs) {
|
||||
t.Error("named asks unused though a wanted build invokes a queue")
|
||||
}
|
||||
unread := unused
|
||||
unread.CatalogUnread = "the catalog half of the branch main"
|
||||
bus := &purged{}
|
||||
|
||||
@@ -211,6 +211,7 @@ type Part struct {
|
||||
heldSaid string
|
||||
// leftOutSaid is the left-out and wanted-manifest lines last logged, so each change is said once (sayLeftOut).
|
||||
leftOutSaid string
|
||||
namedSaid string
|
||||
heldKnown bool
|
||||
// differSaid is the account consumers' differences last said as a condition, once differKnown (consumers.go).
|
||||
differSaid string
|
||||
@@ -592,6 +593,7 @@ func (p *Part) Compose() Result {
|
||||
res.AssertionsWritten++
|
||||
}
|
||||
}
|
||||
p.sayNamedAsks(in, recs)
|
||||
p.consumers(&res, recs, ask.Consumer)
|
||||
byHand := ""
|
||||
if ask.NamedPurge {
|
||||
@@ -773,3 +775,29 @@ func (p *Part) sayLeftOut(gaps, left []Gap) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sayNamedAsks logs, once per change, whether the named asks of the build seats' queues are in use and why (A-413), and so whether
|
||||
// the pass composes each seat's named worker.
|
||||
func (p *Part) sayNamedAsks(in Inputs, recs buscompose.Records) {
|
||||
granted := buscompose.NamedAsksGranted(recs)
|
||||
unused := NamedAsksUnused(in) && !granted
|
||||
var workers []string
|
||||
for _, ds := range recs.Assigned {
|
||||
for _, d := range ds {
|
||||
for _, w := range buscompose.SeatTrafficOf(d.Module, d.Holds, d.Uses, d.Watches).Workers {
|
||||
if strings.HasSuffix(w.Consumer, "_named_worker") {
|
||||
workers = append(workers, w.Consumer+" of "+d.Module)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
slices.Sort(workers)
|
||||
said := fmt.Sprintf("named asks %s: %s; named workers composed: %d", map[bool]string{true: "unused", false: "in use"}[unused], namedAsksWhy(in, granted), len(workers))
|
||||
if said == p.namedSaid {
|
||||
return
|
||||
}
|
||||
p.namedSaid = said
|
||||
if p.Logf != nil {
|
||||
p.Logf("%s", said)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user