feat: name nodes and templates in Docker image delete conflicts

The compute translates the container ids in a daemon delete conflict
into the GNS3 node and project behind each container. Leftover
containers from closed projects and containers created outside GNS3
are named as such.

The controller lists the templates referencing the image in the
conflict error, matched through the canonical image name. After a
successful deletion it emits a docker.image.deleted notification with
those templates: their nodes can no longer start.
This commit is contained in:
YueGuobin committed 2026-11-06 22:05:52 +08:00
1 parent 04a8ba06a8
commit de986e890e
6 files changed
+341 -7

No files matched your search

+30 -1
View File
@@ -20,7 +20,13 @@ import threading
import pytest
from gns3server.utils import force_unix_path
from gns3server.utils.images import images_directories, list_images, md5sum, remove_checksum
from gns3server.utils.images import (
canonical_docker_image_name,
images_directories,
list_images,
md5sum,
remove_checksum,
)
def test_images_directories(tmpdir, config):
@@ -108,6 +114,29 @@ def test_remove_checksum(tmpdir):
remove_checksum(str(tmpdir / "not_exists"))
@pytest.mark.parametrize(
"reference, expected",
(
("alpine", "library/alpine:latest"),
("alpine:3", "library/alpine:3"),
("library/alpine:3", "library/alpine:3"),
("docker.io/library/alpine:3", "library/alpine:3"),
("index.docker.io/library/alpine:3", "library/alpine:3"),
("localhost/alpine:3", "library/alpine:3"),
("gns3/frr", "gns3/frr:latest"),
("gns3/frr:latest", "gns3/frr:latest"),
("quay.io/some/namespace/image:2.0", "some/namespace/image:2.0"),
("alpine@sha256:" + "a" * 64, "library/alpine@sha256:" + "a" * 64),
("alpine:3@sha256:" + "a" * 64, "library/alpine@sha256:" + "a" * 64),
),
)
def test_canonical_docker_image_name(reference, expected):
assert canonical_docker_image_name(reference) == expected
# the canonical form is stable: canonicalizing twice does not change it
assert canonical_docker_image_name(expected) == expected
@pytest.mark.asyncio
async def test_list_images(tmpdir, config):