mesh/merge-gate head 50c55a773eb8 merged into trunk c0c379af2b3c — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head 50c55a773eb8 merged into trunk c0c379af2b3c — pass: its merge-check.sh passed
mesh/delivery delivered
mesh/delivery-group group fix/544-the-build-agent-says-it-is-ready delivered: every member is delivered
The agent listens on nothing, so the node-engine could judge it only alive and held it starting for the whole grace on every machine a walk moved it to. It now writes a mark once it is bound to its worker, after its seat verbs are served, and 'mesh-builder ready' passes only while the mark is there.
45 lines
1.8 KiB
Go
45 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// **The build agent says it is ready** (novox/hq issue 544). It listens on nothing, so no http or tcp
|
|
// check can see it work; it writes a mark once it is bound to its worker and pulls build work, and its
|
|
// container's health check runs `mesh-builder ready`, which passes only while the mark is there. Without
|
|
// it the node-engine could judge the agent only alive, and every walk that moved it waited out the whole
|
|
// grace on each machine.
|
|
//
|
|
// The mark lives in the container's own temporary directory, never in the workspace the machine keeps:
|
|
// a new container starts without it, and a restarted one removes it before it binds again.
|
|
func readyMark() string { return filepath.Join(os.TempDir(), "mesh-builder.ready") }
|
|
|
|
// notReady removes the mark: a holder starting is not taking work until it says so again.
|
|
func notReady() error {
|
|
if err := os.Remove(readyMark()); err != nil && !errors.Is(err, os.ErrNotExist) {
|
|
return fmt.Errorf("cannot remove the mark that this agent takes build work (%s): %w", readyMark(), err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// taking writes the mark. A mark that cannot be written is said, and the agent goes on building: its
|
|
// check then says it is not ready, which is the truth the gate should hear.
|
|
func taking(seat string) {
|
|
if err := os.WriteFile(readyMark(), []byte(seat+"\n"), 0o644); err != nil {
|
|
fmt.Fprintf(os.Stderr, "cannot mark that this agent takes build work (%s): %v\n", readyMark(), err)
|
|
return
|
|
}
|
|
fmt.Fprintf(os.Stderr, "taking build work from %s\n", seat)
|
|
}
|
|
|
|
// ready is the health check: nil when this container's agent is bound and pulling build work.
|
|
func ready() error {
|
|
if _, err := os.Stat(readyMark()); err != nil {
|
|
return fmt.Errorf("not taking build work yet: %s is not there", readyMark())
|
|
}
|
|
return nil
|
|
}
|