Fix: Handle project deletion errors in autoidlepc

When deleting the AUTOIDLEPC project in autoidlepc(), if a remote compute
is disconnected, the deletion fails with ControllerForbiddenError due to
our compute connection status check. This causes:
- The project to remain in the controller's memory
- Subsequent autoidlepc calls to fail
- User must restart the server to recover

This fix adds exception handling to ensure the project is always removed
from the controller's memory, even if deletion fails.

Related to #2703
This commit is contained in:
YueGuobin 2026-05-06 00:47:24 +08:00
parent 9c868911e1
commit c92188cad4
No known key found for this signature in database

View File

@ -842,7 +842,14 @@ class Controller:
compute = self.get_compute(compute_id)
for project in list(self._projects.values()):
if project.name == "AUTOIDLEPC":
await project.delete()
try:
await project.delete()
except ControllerForbiddenError as e:
# Project couldn't be deleted due to disconnected computes
log.warning(f"Could not delete AUTOIDLEPC project '{project.id}': {e}")
except ControllerError as e:
log.warning(f"Error deleting AUTOIDLEPC project '{project.id}': {e}")
# Always remove from controller to allow creating a new one
self.remove_project(project)
project = await self.add_project(name="AUTOIDLEPC")
node = await project.add_node(