mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 15:21:13 +02:00
fix(docker): handle container name conflict automatically
When a Docker container with the same name already exists (e.g., from a previous crashed GNS3 session), Docker returns a 409 Conflict error when trying to create a new container with that name. This causes the project open operation to fail. This fix adds automatic cleanup of stale containers when encountering a name conflict: - Added DockerHttp409Error exception class - Updated http_query to detect 409 status codes - Modified create() to remove conflicting containers and retry Fixes the issue where opening a project fails with: "Docker has returned an error: 409 Conflict. The container name '/GNS3.xxx' is already in use by container 'xxx'"
This commit is contained in:
1 parent
a0116902a6
commit
ce90b2b92c
3 files changed
+30
-3
No files matched your search
@@ -32,7 +32,7 @@ from gns3server.config import Config
|
||||
from gns3server.utils.asyncio import locking
|
||||
from gns3server.compute.base_manager import BaseManager
|
||||
from gns3server.compute.docker.docker_vm import DockerVM
|
||||
from gns3server.compute.docker.docker_error import DockerError, DockerHttp304Error, DockerHttp404Error
|
||||
from gns3server.compute.docker.docker_error import DockerError, DockerHttp304Error, DockerHttp404Error, DockerHttp409Error
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -240,6 +240,8 @@ class Docker(BaseManager):
|
||||
raise DockerHttp304Error(f"Docker has returned an error: {response.status} {body}")
|
||||
elif response.status == 404:
|
||||
raise DockerHttp404Error(f"Docker has returned an error: {response.status} {body}")
|
||||
elif response.status == 409:
|
||||
raise DockerHttp409Error(f"Docker has returned an error: {response.status} {body}")
|
||||
else:
|
||||
raise DockerError(f"Docker has returned an error: {response.status} {body}")
|
||||
return response
|
||||
|
||||
Reference in new issue
Block a user