Fix: Check compute connection status before project deletion

This commit addresses issue #2703 where deleting a project with nodes
on remote compute nodes would result in long waits with no feedback
if those computes were unreachable.

Changes:
1. Compute connection status updates on connection failure
   - When a compute fails to connect, update connected=False and last_error
   - Send compute.updated notification to UI so users can see status
   - This allows Web UI to display real-time connection status

2. Project deletion checks compute status before attempting deletion
   - Check all computes used by the project are connected
   - If any compute is disconnected, immediately reject deletion
   - Provide clear error message indicating which computes are offline
   - This prevents long timeouts and gives users immediate feedback

Benefits:
- Immediate feedback instead of 120-second timeouts
- Clear error messages about which computes are disconnected
- Prevents orphaned resources on offline computes
- Improves user experience by avoiding silent waits

Related: #2703

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
YueGuobin 2026-05-06 00:05:10 +08:00
parent ee7c5d6d59
commit 4444da9ffa
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View File

@ -375,6 +375,11 @@ class Compute:
log.info(f"Connecting to compute '{self._id}'")
response = await self._run_http_query("GET", "/capabilities")
except ComputeError as e:
# Update connection status and notify UI
self._connected = False
self._last_error = str(e)
self._controller.notification.controller_emit("compute.updated", self.asdict())
if report_failed_connection:
raise
log.warning(f"Cannot connect to compute '{self._id}': {e}")

View File

@ -1029,6 +1029,20 @@ class Project:
except ControllerError as e:
# ignore missing images or other conflicts when deleting a project
log.warning(f"Conflict while deleting project: {e}")
# Check if all computes used by this project are connected before deletion
disconnected_computes = []
for compute in self._project_created_on_compute:
if not compute.connected:
disconnected_computes.append(compute)
if disconnected_computes:
compute_names = ", ".join([f"'{c.name}'" for c in disconnected_computes])
raise ControllerForbiddenError(
f"Cannot delete project '{self.name}': {len(disconnected_computes)} compute(s) are disconnected: {compute_names}. "
f"Please fix the connection or delete the project manually on those computes."
)
await self.delete_on_computes()
await self.close()