fix(orchestration): normalize worker-start timeout defaults

This commit is contained in:
Brennan Benson
2026-08-27 01:13:05 -07:00
parent a33e684f4c
commit 7082547604
2 changed files with 20 additions and 3 deletions
@@ -1,6 +1,9 @@
import { describe, expect, it } from 'vitest'
import { MAX_TIMER_DELAY_MS } from '../../../../shared/timer-delay'
import { ORCHESTRATION_WORKER_START_CLIENT_GRACE_MS } from '../../../../shared/orchestration-timing-budgets'
import {
ORCHESTRATION_READINESS_TIMEOUT_MS,
ORCHESTRATION_WORKER_START_CLIENT_GRACE_MS
} from '../../../../shared/orchestration-timing-budgets'
import { resolveFederatedWorkerStartBudgets } from './orchestration-worker-start-budgets'
describe('worker-start transport budgets', () => {
@@ -16,4 +19,16 @@ describe('worker-start transport budgets', () => {
'derived timeout must fit'
)
})
it('normalizes non-positive requests to the ordinary readiness default', () => {
const expectedOuterDeadline =
1_000 + ORCHESTRATION_READINESS_TIMEOUT_MS + ORCHESTRATION_WORKER_START_CLIENT_GRACE_MS
expect(resolveFederatedWorkerStartBudgets(0, 1_000).readinessTimeoutMs).toBe(
ORCHESTRATION_READINESS_TIMEOUT_MS
)
expect(resolveFederatedWorkerStartBudgets(0, 1_000).outerDeadlineMs).toBe(expectedOuterDeadline)
expect(resolveFederatedWorkerStartBudgets(-1, 1_000).outerDeadlineMs).toBe(
expectedOuterDeadline
)
})
})
@@ -1,8 +1,8 @@
import {
ORCHESTRATION_CONTRACT_PREFLIGHT_TIMEOUT_MS,
ORCHESTRATION_READINESS_TIMEOUT_MS,
isWorkerStartTimeoutWithinTimerLimit,
resolveFederationAttachDeadlineMs,
resolveWorkerStartReadinessTimeoutMs,
resolveWorkerStartClientTimeoutMs
} from '../../../../shared/orchestration-timing-budgets'
@@ -15,7 +15,9 @@ export function resolveFederatedWorkerStartBudgets(
'--timeout-ms is too large for worker-start transport grace; the derived timeout must fit within the timer limit.'
)
}
const readinessTimeoutMs = timeoutMs ?? ORCHESTRATION_READINESS_TIMEOUT_MS
// Normalize non-positive/invalid values exactly as the client does so local
// and federated transports share the ordinary default contract.
const readinessTimeoutMs = resolveWorkerStartReadinessTimeoutMs(timeoutMs)
const outerDeadlineMs = nowMs + resolveWorkerStartClientTimeoutMs(readinessTimeoutMs)
return {
readinessTimeoutMs,