From 5c7018283f1518e731be85de5a1d8e8e842b94be Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Sat, 9 May 2026 13:45:06 +0800 Subject: [PATCH] fix: Skip offline compute nodes during project import When importing a project, the round-robin logic would attempt to distribute nodes across all configured compute resources, including offline ones. This caused import failures when any remote compute was unreachable. This fix filters the compute list to only include connected computes before round-robin distribution. If no remote computes are connected, all nodes are assigned to the local compute. This matches the approach used in project._get_disconnected_computes() and prevents the issue where importing a project fails with: "Cannot connect to compute 'X' with request POST /projects" Fixes issue introduced in commit 90e3a8d6 (2017) which added round-robin load balancing without considering offline compute nodes. Co-Authored-By: Claude Sonnet 4.6 --- gns3server/controller/import_project.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gns3server/controller/import_project.py b/gns3server/controller/import_project.py index 64fa93b3c..2596de5f4 100644 --- a/gns3server/controller/import_project.py +++ b/gns3server/controller/import_project.py @@ -134,9 +134,16 @@ async def import_project( node["compute_id"] = "vm" else: # Round-robin through available compute resources. - compute_nodes = itertools.cycle(controller.computes) - for node in topology["topology"]["nodes"]: - node["compute_id"] = next(compute_nodes) + # Only use computes that are connected to avoid import failures + available_computes = {compute_id: compute for compute_id, compute in controller.computes.items() if compute.connected} + if available_computes: + compute_nodes = itertools.cycle(available_computes) + for node in topology["topology"]["nodes"]: + node["compute_id"] = next(compute_nodes) + else: + # No remote computes are connected, use local only + for node in topology["topology"]["nodes"]: + node["compute_id"] = "local" compute_created = set() for node in topology["topology"]["nodes"]: