diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go index 42e99b8e..ef544bcb 100644 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go +++ b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/main.go @@ -174,6 +174,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err != nil { return err } + holdCallsFor(answerBound) verdicts := &manifestVerdicts{} compositions := check.EngineCompositions{ Asker: engineAsks{call: caller.CallOn}, diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go index c65f0f73..c3c44afd 100644 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go +++ b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings.go @@ -9,6 +9,7 @@ import ( "time" "git.novox.be/novox/mesh-sdk/go/delivery" + "git.novox.be/novox/mesh-sdk/go/process" ) // The checker's own settings (its config, written by the node-engine into ${dir:state}/settings.json, named to the @@ -42,3 +43,12 @@ func composeAnswerBound(path string) (time.Duration, error) { } return time.Duration(*s.Bound) * time.Second, nil } + +// holdCallsFor makes a bus call wait the compose-answer-bound (novox/hq ADR 0593 §7), not the SDK's CallTimeout of 30 s: +// the request of Conn.CallOn gives up at CallTimeout, so a node-engine answering at 30.4 s was lost before the bound +// applied (issue 1126). It only ever lengthens the SDK's bound, and it is set once, before the first call. +func holdCallsFor(bound time.Duration) { + if bound > process.CallTimeout { + process.CallTimeout = bound + } +} diff --git a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go index 37155a3f..ed6e148a 100644 --- a/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go +++ b/modules/mesh-delivery-checker/cmd/mesh-delivery-checker/settings_test.go @@ -7,6 +7,7 @@ import ( "time" "git.novox.be/novox/mesh-sdk/go/delivery" + "git.novox.be/novox/mesh-sdk/go/process" ) // ADR 0593 §7: the answer bound is the checker's setting compose-answer-bound, 60 s when the file or the value is @@ -33,3 +34,22 @@ func TestTheAnswerBoundIsTheCheckersSetting(t *testing.T) { } } } + +// Issue 1126, ADR 0593 §7: the SDK's call gives up at CallTimeout (30 s), so an engine answering at 31 s is lost under a +// 60 s answer bound unless the checker's calls wait the bound; the bound never shortens the SDK's own. +func TestCallsWaitTheComposeAnswerBound(t *testing.T) { + was := process.CallTimeout + defer func() { process.CallTimeout = was }() + for _, row := range []struct{ bound, want time.Duration }{ + {delivery.ComposeAnswerBound, delivery.ComposeAnswerBound}, {10 * time.Second, was}, {600 * time.Second, 600 * time.Second}, + } { + process.CallTimeout = was + holdCallsFor(row.bound) + if process.CallTimeout != row.want { + t.Errorf("bound %v: calls wait %v, want %v", row.bound, process.CallTimeout, row.want) + } + if row.bound > 31*time.Second && process.CallTimeout < 31*time.Second { + t.Errorf("an answer at 31 s would be lost under bound %v", row.bound) + } + } +}