Skip to content

Commit a7c5d02

Browse files
committed
fix: give OpenClaw's startup one 60-second deadline
On busy hosts, such as CI runners starting three agents at once on four vCPUs, the Gateway took close to 40 s to become ready, and each startup step's own 30 s timeout let start fail at random. startup_timeout_seconds now bounds all of start, from checking the openclaw command to the Gateway becoming ready, with a 60 s default, as NVIDIA#547's L3 rule says for adapters that gain the setting. Found by NemoClaw's live Kubernetes tests. Signed-off-by: Carlos Villela <[email protected]>
1 parent 542c439 commit a7c5d02

6 files changed

Lines changed: 56 additions & 11 deletions

File tree

‎adapters/python/openclaw/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The following settings are specific to the OpenClaw adapter:
111111
| `interfaces.dashboard.port` | Required | Exact loopback Gateway base port, at most 65425. Can't be combined with `port_range`. |
112112
| `interfaces.dashboard.enabled` | `true` | Set to `false` to keep a configured dashboard off. |
113113
| `interfaces.dashboard.public_origins` | None | Browser origins accepted in addition to `http://127.0.0.1:<port>` and `http://localhost:<port>`. |
114-
| `startup_timeout_seconds` | `30` | Gateway startup timeout, at most 75 seconds. |
114+
| `startup_timeout_seconds` | `60` | One deadline for all of start, from checking the `openclaw` command to the Gateway becoming ready; at most 75 seconds. |
115115
| `shutdown_timeout_seconds` | `5` | Graceful shutdown timeout. |
116116
| `connect_timeout_seconds` | `10` | Local HTTP connection timeout. |
117117
| `read_timeout_seconds` | None | Local HTTP response timeout. When unset, the invocation timeout bounds the response. |

‎adapters/python/openclaw/openclaw.fabric-adapter.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
"type": "number",
101101
"exclusiveMinimum": 0,
102102
"maximum": 75,
103-
"default": 30,
104-
"description": "Maximum time to wait for the OpenClaw Gateway to become ready, within NeMo Fabric's 90-second start limit."
103+
"default": 60,
104+
"description": "One deadline for all of start, from checking the OpenClaw command to the Gateway becoming ready, within NeMo Fabric's 90-second start limit."
105105
},
106106
"shutdown_timeout_seconds": {
107107
"type": "number",

‎adapters/python/openclaw/src/nemo_fabric_adapters/openclaw/adapter.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from nemo_fabric_adapters.openclaw import _windows_job
3939

4040

41-
DEFAULT_STARTUP_TIMEOUT_SECONDS = 30.0
41+
DEFAULT_STARTUP_TIMEOUT_SECONDS = 60.0
4242
# Fabric gives the adapter host 10 s to stop, including this wait.
4343
DEFAULT_SHUTDOWN_TIMEOUT_SECONDS = 5.0
4444
DEFAULT_CONNECT_TIMEOUT_SECONDS = 10.0
@@ -1246,8 +1246,14 @@ async def start(self, payload: dict[str, Any]) -> dict[str, Any] | None:
12461246
DEFAULT_STARTUP_TIMEOUT_SECONDS,
12471247
maximum=MAX_STARTUP_TIMEOUT_SECONDS,
12481248
)
1249+
# One deadline covers every startup step, so start ends within it.
1250+
startup_deadline = asyncio.get_running_loop().time() + startup_timeout
1251+
1252+
def startup_remaining() -> float:
1253+
return max(startup_deadline - asyncio.get_running_loop().time(), 0.0)
1254+
12491255
version_output = await _command_output(
1250-
command, "--version", env=child_env, timeout=startup_timeout
1256+
command, "--version", env=child_env, timeout=startup_remaining()
12511257
)
12521258
version = _validate_openclaw_version(version_output)
12531259
from nemo_fabric_adapters.common.provenance import record_version
@@ -1315,7 +1321,7 @@ async def start(self, payload: dict[str, Any]) -> dict[str, Any] | None:
13151321
"validate",
13161322
"--json",
13171323
env=child_env,
1318-
timeout=startup_timeout,
1324+
timeout=startup_remaining(),
13191325
)
13201326
if os.name == "nt":
13211327
try:
@@ -1328,7 +1334,7 @@ async def start(self, payload: dict[str, Any]) -> dict[str, Any] | None:
13281334
gateway_command = _gateway_command(
13291335
command,
13301336
port=port,
1331-
prefix=await _parent_death_prefix(timeout=startup_timeout),
1337+
prefix=await _parent_death_prefix(timeout=startup_remaining()),
13321338
)
13331339
self._process = await asyncio.create_subprocess_exec(
13341340
*gateway_command,
@@ -1355,7 +1361,7 @@ async def start(self, payload: dict[str, Any]) -> dict[str, Any] | None:
13551361
),
13561362
]
13571363
self._install_signal_handlers()
1358-
await self._wait_started(port, token, startup_timeout)
1364+
await self._wait_started(port, token, startup_remaining())
13591365
if dashboard is not None:
13601366
if sys.platform == "linux" and not _port_listener_in_session(
13611367
port, self._process.pid

‎sdk/python/nemo-fabric-adapter-catalog/src/nemo_fabric_adapter_catalog/catalog.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,8 +2139,8 @@
21392139
"type": "number"
21402140
},
21412141
"startup_timeout_seconds": {
2142-
"default": 30,
2143-
"description": "Maximum time to wait for the OpenClaw Gateway to become ready, within NeMo Fabric's 90-second start limit.",
2142+
"default": 60,
2143+
"description": "One deadline for all of start, from checking the OpenClaw command to the Gateway becoming ready, within NeMo Fabric's 90-second start limit.",
21442144
"exclusiveMinimum": 0,
21452145
"maximum": 75,
21462146
"type": "number"
@@ -2154,7 +2154,7 @@
21542154
"name": "nemo-fabric-adapters-openclaw",
21552155
"version": "0.7.0"
21562156
},
2157-
"sha256": "2daeaf79951bf048c93183e7f21395149509e25066e3384e612dcfe0f881fa10",
2157+
"sha256": "6c7440f20bf5cbf5e2ef852976f7e56c73d3e7882fb7bbc7e3fd329495400ad7",
21582158
"source": "adapters/python/openclaw/openclaw.fabric-adapter.json"
21592159
},
21602160
"nvidia.fabric.opencode": {

‎tests/_utils/mock_openclaw.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
import os
99
import signal
1010
import sys
11+
import time
1112
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
1213

1314

1415
args = sys.argv[1:]
16+
if args[:1] != ["gateway"] and (delay := os.environ.get("FAKE_OPENCLAW_COMMAND_DELAY")):
17+
time.sleep(float(delay))
1518
if args == ["--version"]:
1619
print("OpenClaw 2026.9.34 (fabric test)")
1720
raise SystemExit(0)

‎tests/adapters/test_openclaw.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,42 @@ async def test_openclaw_services_reject_interfaces(
754754
assert runtime._process is None
755755

756756

757+
async def test_openclaw_startup_timeout_bounds_all_of_start(
758+
mock_openclaw: Path, tmp_path: Path, monkeypatch
759+
):
760+
# Each command finishes within the timeout, but the two together don't.
761+
monkeypatch.setenv("FAKE_OPENCLAW_COMMAND_DELAY", "0.6")
762+
monkeypatch.setenv("FAKE_OPENCLAW_CAPTURE", str(tmp_path / "config.json"))
763+
config = _config(mock_openclaw)
764+
assert config.harness is not None
765+
config.harness.settings["startup_timeout_seconds"] = 1
766+
runtime = adapter.OpenClawRuntime()
767+
768+
with pytest.raises(adapter.lifecycle.LifecycleError) as caught:
769+
await runtime.start(
770+
{
771+
"config": config,
772+
"runtime_context": _context(tmp_path).to_mapping(),
773+
"base_dir": str(tmp_path),
774+
}
775+
)
776+
777+
assert caught.value.code == "openclaw_command_timeout"
778+
assert runtime._process is None
779+
780+
781+
def test_openclaw_waits_a_minute_for_startup_by_default(repo_root: Path):
782+
descriptor = json.loads(
783+
(repo_root / "adapters/python/openclaw/openclaw.fabric-adapter.json").read_text(
784+
encoding="utf-8"
785+
)
786+
)
787+
timeout = descriptor["settings_schema"]["properties"]["startup_timeout_seconds"]
788+
789+
assert timeout["default"] == 60
790+
assert adapter.DEFAULT_STARTUP_TIMEOUT_SECONDS == 60
791+
792+
757793
async def test_openclaw_rejects_startup_timeout_above_core_limit(
758794
mock_openclaw: Path, tmp_path: Path
759795
):

0 commit comments

Comments
 (0)