Since the build CPU cap (issue 1806) shanks' mesh-build-go kept capacity 3 inside a 12-core slice: three full checks got about 4 cores each and ran past the 30-minute step bound (issue 1890). The puller now judges by min(configured, floor(slice quota cores / cores-per-step)), the quota read live from its cgroup, says it on change and writes capacity.<node> to the pauses state. A run's phases (fetch and merge, digest, tests) are logged with the ask id and written to its running step key; Asker.Wait hands every step value to a WithStepSeen hook.
40 lines
1.8 KiB
Go
40 lines
1.8 KiB
Go
package buildstep
|
|
|
|
import (
|
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
|
)
|
|
|
|
// SeatTools are a build seat's verbs on one node, as its holder serves them (novox/hq ADR 0525 §10; mesh-sdk catalogue
|
|
// buildSeatVerbs): `<seat>.current` (what the node runs, its capacity, whether it is paused), `<seat>.pause` and
|
|
// `<seat>.resume`, the pause kept on the node's pause key by the puller. what names the asks in the descriptions ("Go").
|
|
func SeatTools(seat, what string, p *Puller) []stdio.Tool {
|
|
verb := func(name, description string, run func() (any, error)) stdio.Tool {
|
|
return stdio.Tool{Name: seat + "." + name, Description: description,
|
|
Input: map[string]any{"type": "object", "properties": map[string]any{}},
|
|
Run: func(map[string]any) (any, error) { return run() }}
|
|
}
|
|
current := func() (any, error) {
|
|
c := p.CapacityDetail()
|
|
return map[string]any{"node": p.Node, "capacity": c.Effective, "capacity_why": c.Why, "capacity_detail": c,
|
|
"running": p.Running(), "paused": p.Paused()}, nil
|
|
}
|
|
return []stdio.Tool{
|
|
verb("current", "The "+what+" asks this node runs now (each one's id, kind and when it started), its build capacity (the configured one, "+
|
|
"bounded by the cores its node's build slice gives over the cores a step needs) and why, "+
|
|
"and whether it is paused.", current),
|
|
verb("pause", "Take no new "+what+" ask on this node until resumed; an ask running here ends in its place. Kept "+
|
|
"across a restart (the node's pause key).", func() (any, error) {
|
|
if err := p.Pause("the seat's pause verb"); err != nil {
|
|
return nil, err
|
|
}
|
|
return current()
|
|
}),
|
|
verb("resume", "Take "+what+" asks again on this node.", func() (any, error) {
|
|
if err := p.Resume("the seat's resume verb"); err != nil {
|
|
return nil, err
|
|
}
|
|
return current()
|
|
}),
|
|
}
|
|
}
|