push: the wait is the call's or the controller's setting push-wait, never a length in the code (issue 629)
mesh/merge-gate head f09c5ebdec6c merged into trunk 584aa2d7d7a5 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head f09c5ebdec6c merged into trunk 584aa2d7d7a5 — pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate head f09c5ebdec6c merged into trunk 584aa2d7d7a5 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head f09c5ebdec6c merged into trunk 584aa2d7d7a5 — pass: its merge-check.sh passed
mesh/delivery superseded: a newer head of the same pull request
The operator's rule: a wait is never hard-coded, at most a default is configured. The push verb takes `wait`; without it the controller's setting `push-wait` (module default 2m) applies; a setting that cannot be read waits for nothing, as a push did before, and says so.
This commit is contained in:
@@ -55,7 +55,7 @@ func TestARepairByHandCarriesItsReason(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{"push", map[string]any{"node": "anchor", "why": "stuck", "cause": "sent-not-reported"},
|
||||
"push anchor --wait 2m0s --why stuck --cause sent-not-reported"},
|
||||
"push anchor --wait 0s --why stuck --cause sent-not-reported"},
|
||||
{"plans", map[string]any{"close": "plan-1", "why": "the report will not come"},
|
||||
"plans close plan-1 --why the report will not come"},
|
||||
{"plans", map[string]any{"retry": "plan-1"}, "plans retry plan-1"},
|
||||
|
||||
@@ -522,9 +522,11 @@ func (a *verbArguments) commandLine() ([]string, error) {
|
||||
case "push":
|
||||
// A push to a named machine waits for that machine's own answer, so the call's record says
|
||||
// how it went: applied, refused with the machine's reason, or which resources failed and why
|
||||
// (novox/hq issue 629). The caller is answered before the push starts (answersFirst), so the
|
||||
// wait holds nobody; it is what `calls` then shows. A sweep (--behind) still does not wait: it
|
||||
// sends many machines, and the slowest would hold back what is said of the others.
|
||||
// (novox/hq issue 629). How long is the call's `wait`, else the controller's setting `push-wait`;
|
||||
// neither given waits for nothing, as before. The caller is answered before the push starts
|
||||
// (answersFirst) and the machines are released once sent, so the wait holds nobody; it is what
|
||||
// `calls` then shows. A sweep (--behind) does not wait: the slowest machine would hold back
|
||||
// what is said of the others.
|
||||
// A push through the seat is a push by hand, and says why (novox/hq to-be 45 §7).
|
||||
if err := need("why"); err != nil {
|
||||
return nil, fmt.Errorf("%w: a push by hand is a repair, recorded in the hand-act log with why", err)
|
||||
@@ -537,7 +539,11 @@ func (a *verbArguments) commandLine() ([]string, error) {
|
||||
// behind is not read here: given with a machine, it is refused as passed over — naming
|
||||
// a machine and asking for every machine behind are two requests, and guessing one
|
||||
// would push a machine nobody named, or not push one somebody did.
|
||||
argv := []string{"push", n, "--wait", seatPushWait.String()}
|
||||
wait, err := pushWait(str("wait"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
argv := []string{"push", n, "--wait", wait.String()}
|
||||
// A running module's data moving is sent only when said, per module (novox/hq ADR 0217).
|
||||
if m := str("move"); m != "" {
|
||||
argv = append(argv, "--move", m)
|
||||
@@ -1331,10 +1337,46 @@ var inProcess = map[string]bool{"tools": true, "calls": true, "doctor": true,
|
||||
// 0259 §8): the router asks it before an approval.
|
||||
"root-free": true}
|
||||
|
||||
// seatPushWait is how long a push through the seat waits for the machine it names to report applying what it
|
||||
// was sent (novox/hq issue 629): inside the call's bound with room for the send itself, which took two minutes
|
||||
// on 2026-10-13 with four pushes at once.
|
||||
const seatPushWait = 2 * time.Minute
|
||||
// pushFileVar names the file the controller's push settings are written to (module.json, `push-wait`).
|
||||
const pushFileVar = "MESH_PUSH_FILE"
|
||||
|
||||
// pushWait is how long a push to a named machine waits for its answer (novox/hq issue 629): the call's own
|
||||
// `wait` when given, else the controller's setting `push-wait`, else nothing. No length is written here: the
|
||||
// setting's default is the module's, and a setting that cannot be read waits for nothing, as a push did
|
||||
// before, and is said.
|
||||
func pushWait(given string) (time.Duration, error) {
|
||||
if strings.TrimSpace(given) != "" {
|
||||
d, ok := durationSetting(given)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("push: wait %q is no duration: say it as \"90s\", \"2m\", or \"0\" to wait for nothing", given)
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
path := os.Getenv(pushFileVar)
|
||||
if path == "" {
|
||||
return 0, nil
|
||||
}
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "the push settings cannot be read (%v); a push waits for nothing\n", err)
|
||||
return 0, nil
|
||||
}
|
||||
var values map[string]any
|
||||
if err := json.Unmarshal(raw, &values); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "the push settings are not JSON (%v); a push waits for nothing\n", err)
|
||||
return 0, nil
|
||||
}
|
||||
v, has := values["push-wait"]
|
||||
if !has || v == "" {
|
||||
return 0, nil
|
||||
}
|
||||
d, ok := durationSetting(v)
|
||||
if !ok {
|
||||
fmt.Fprintf(os.Stderr, "the setting push-wait=%v is no duration; a push waits for nothing\n", v)
|
||||
return 0, nil
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
||||
// answersFirst is a command line whose caller is answered before it runs: a push, by its verb or
|
||||
// through `command`. A push sends the machine holding the bus first when its user list changed, the
|
||||
|
||||
@@ -146,8 +146,7 @@ func TestAnArgumentAVerbDoesNotDeclareIsRefused(t *testing.T) {
|
||||
// naming one beside behind is refused rather than one of the two guessed.
|
||||
func TestAPushIsOneMachineOrSaysItIsTheWholeMesh(t *testing.T) {
|
||||
argv, err := argvFor("push", map[string]any{"node": "g1", "why": "w"})
|
||||
// A named push waits for the machine's own answer, so the call says how it went (novox/hq issue 629).
|
||||
if err != nil || strings.Join(argv, " ") != "push g1 --wait 2m0s --why w" {
|
||||
if err != nil || strings.Join(argv, " ") != "push g1 --wait 0s --why w" {
|
||||
t.Fatalf("a named push: %v %v", argv, err)
|
||||
}
|
||||
for _, args := range []map[string]any{{"why": "w"}, {"behind": "true", "why": "w"}} {
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/novox/mesh-controller/internal/link"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -170,8 +172,8 @@ func TestAVerbMissingWhatItNeedsIsRefused(t *testing.T) {
|
||||
// repository given as a forge path is said to be one (issue 176).
|
||||
func TestActsDoNotBlockTheCall(t *testing.T) {
|
||||
argv, _ := argvFor("push", map[string]any{"node": "one", "why": "w"})
|
||||
if strings.Join(argv, " ") != "push one --wait 2m0s --why w" || !answersFirst(argv) {
|
||||
t.Fatalf("a named push does not wait for the machine's answer, or holds its caller: %v", argv)
|
||||
if strings.Join(argv, " ") != "push one --wait 0s --why w" || !answersFirst(argv) {
|
||||
t.Fatalf("a named push with no setting waits, or holds its caller: %v", argv)
|
||||
}
|
||||
argv, _ = argvFor("build", map[string]any{"repository": "novox/x", "path": "modules/x"})
|
||||
if strings.Join(argv, " ") != "build novox/x --wait 0 --self --path modules/x" {
|
||||
@@ -462,3 +464,40 @@ func TestAQuotedValueRoundTrips(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A named push waits as long as the call says, else as long as the controller's setting push-wait says, else
|
||||
// not at all: no length is the code's own (novox/hq issue 629).
|
||||
func TestAPushWaitsAsTheCallOrTheSettingSays(t *testing.T) {
|
||||
file := filepath.Join(t.TempDir(), "push.json")
|
||||
if err := os.WriteFile(file, []byte(`{"push-wait": "2m"}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv(pushFileVar, file)
|
||||
argv, err := argvFor("push", map[string]any{"node": "one", "why": "w"})
|
||||
if err != nil || strings.Join(argv, " ") != "push one --wait 2m0s --why w" {
|
||||
t.Fatalf("the setting was not the default: %v %v", argv, err)
|
||||
}
|
||||
argv, err = argvFor("push", map[string]any{"node": "one", "why": "w", "wait": "30s"})
|
||||
if err != nil || strings.Join(argv, " ") != "push one --wait 30s --why w" {
|
||||
t.Fatalf("the call's wait did not win over the setting: %v %v", argv, err)
|
||||
}
|
||||
argv, err = argvFor("push", map[string]any{"node": "one", "why": "w", "wait": "0"})
|
||||
if err != nil || strings.Join(argv, " ") != "push one --wait 0s --why w" {
|
||||
t.Fatalf("a wait of 0 did not wait for nothing: %v %v", argv, err)
|
||||
}
|
||||
if _, err := argvFor("push", map[string]any{"node": "one", "why": "w", "wait": "soon"}); err == nil ||
|
||||
!strings.Contains(err.Error(), "no duration") {
|
||||
t.Fatalf("a wait that is no duration was taken: %v", err)
|
||||
}
|
||||
if err := os.WriteFile(file, []byte(`{"push-wait": "later"}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
argv, err = argvFor("push", map[string]any{"node": "one", "why": "w"})
|
||||
if err != nil || strings.Join(argv, " ") != "push one --wait 0s --why w" {
|
||||
t.Fatalf("an unreadable setting did not fall back to waiting for nothing: %v %v", argv, err)
|
||||
}
|
||||
argv, _ = argvFor("push", map[string]any{"why": "w"})
|
||||
if strings.Join(argv, " ") != "push --behind --wait 0 --why w" {
|
||||
t.Fatalf("a sweep waits: %v", argv)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ func TestTheVerbsCarryReadReplaceAndMove(t *testing.T) {
|
||||
{"settings", map[string]any{"module": "plex", "history": "true"}, []string{"settings", "show", "plex", "--history"}},
|
||||
{"settings", map[string]any{"module": "plex", "values": "{}", "replace": "true"}, []string{"settings", "set", "plex", "{}", "--replace"}},
|
||||
{"push", map[string]any{"node": "home", "move": "plex", "why": "w"},
|
||||
[]string{"push", "home", "--wait", "2m0s", "--move", "plex", "--why", "w"}},
|
||||
[]string{"push", "home", "--wait", "0s", "--move", "plex", "--why", "w"}},
|
||||
{"push", map[string]any{"why": "w"}, []string{"push", "--behind", "--wait", "0", "--why", "w"}},
|
||||
{"plan", map[string]any{"node": "home", "diff": "true"}, []string{"plan", "home", "--diff"}},
|
||||
} {
|
||||
|
||||
Reference in New Issue
Block a user