Fix: Check compute connectivity before node creation in open()

When opening a closed project with nodes on an offline remote compute,
open() would block for 120s trying to connect before eventually
failing. Now checks compute connectivity after loading the topology
file but before creating nodes, allowing immediate failure with a
clear error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
YueGuobin 2026-05-07 10:48:18 +08:00
parent 30ebde0cb0
commit f1b11e7cae
No known key found for this signature in database

View File

@ -1184,6 +1184,16 @@ class Project:
if compute_id not in self._computes:
self._computes.append(compute_id)
# Check compute connectivity before creating nodes to avoid
# 120-second timeout when a remote compute is unreachable
disconnected = self._get_disconnected_computes()
if disconnected:
compute_names = ", ".join([f"'{c.name}'" for c in disconnected])
raise ControllerError(
f"Cannot open project '{self.name}': {len(disconnected)} compute(s) are disconnected: {compute_names}. "
f"Please check the connection and try again."
)
for node in topology.get("nodes", []):
compute = self.controller.get_compute(node.pop("compute_id"))
name = node.pop("name")