feat: Networks page #23
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/12-networks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #22 (container stats): this PR targets
feat/11-container-stats, so the diff shows only the Networks work. Once #22 merges I'll retarget it tomain.A Networks page in the sidebar, built on the same ResourceList / ResourceDetail pattern as Volumes and Images.
List
bridge,host,none) at the bottom, so Docker's own networks are out of the way. Built-in ones can't be deleted (no trash button; a clear message if tried from the menu).Details (same fields as
docker network inspect)Actions: New Network (name prompt, creates a bridge network), Delete (refused client-side while containers are attached, with who's attached), Delete Unused (prune; built-ins are kept), Copy Name / ID / Subnet.
Refresh: network events join the image/volume event watch, so the page updates as networks come and go.
How: networks come from
GET /networks(which returns the same IPAM/options/labels as inspect, minus containers); attached containers and their IPs come from the container list'sNetworkSettings, matched by network ID.ResourceListgained optionalsectionOf/sectionsso a page can choose its sections (Volumes and Images keep In Use / Unused).Mock data: networks
shop_default,monitoring_default, an internalbackend, an attachablelegacy-net, plus the built-ins; mock containers now carry endpoints with addresses. Newnetworksscreenshot scene; README features/screenshots updated (every screenshot changed because the sidebar has a new entry).Tested
cargo fmt --check,clippy --all-targets -D warningswith and withoutmock,cargo build,cargo test(new test: networks JSON — attached containers with IPs, sorting with built-ins last, subnet/gateway, internal flag, compose project), Rust 1.100.0.docker network ls; shop_default showed its 3 containers with the same IPs asdocker network inspect; New Network createdui-made, Delete removed it, Delete Unused removedspare-netand kept the rest.Screenshots (mock data)
Closes #12
4da39450f841a43e0e6aFixed F1 (from Nye) in
41a43e0, amended into the feature commit: "Delete unused networks" no longer calls Docker's prune. That prune only spares networks that have a running container, so it deleted networks used only by stopped containers, and those containers then could not start. Krane now removes, by ID, exactly the networks listed in the confirmation, and Docker still refuses any network a container joined in the meantime. The confirmation text now says networks of stopped containers are kept. I added a live-engine regression test,prune_keeps_networks_of_stopped_containers(run it withcargo test -- --ignored): it fails when the old prune runs and passes now.PR #23 (#12 Networks page) review — Nye, at
4da3945Verdict: CHANGES REQUESTED (one medium finding, F1). Everything else checks out.
Checks (C2)
compose project, labels; subnet search ("172.22" -> backend) works. Volumes still section In Use / Unused.
built-in check holds.
F1 (medium): prune deletes networks Krane shows as "In Use"
A network whose only containers are stopped is listed In Use (networks_json matches the stopped endpoint;
the PR's test asserts that), and confirmPrune() names only !inUse networks. But
docker network prunedeletes any network with no running endpoints, so it silently removes it; the stopped container then
fails
docker start("failed to start containers"). Visible in mock: monitoring_default (prometheus stopped)has one running user so is safe; stop grafana and Krane still shows it In Use while prune deletes it.
Proof: notes/pr23-prune-proof.sh (real Docker, scoped by a label).
Suggested fix (either):
a) Track
runningusers separately (e.g. "activeUsers" = running containers). Prune list/dialog = networkswith no running users, non-builtin; warn by name when a listed network still has stopped containers
("db, worker (stopped) won't start until reconnected"). Keep In Use section as is.
b) Or do the prune client-side: remove only the networks Krane shows as Unused, one by one.
(a) matches Docker; (b) matches the UI. I'd take (b): what the dialog lists is exactly what goes.
Add a networks_json test for the stopped-only case either way.
Non-blocking
(and break those containers), so refusing is the safer call. Fine as is.
stopped containers keep NetworkID, so this is only for older engines. OK.
Posted by Upper Wolfjaw for Nye (Nye can't comment here).
41a43e0e6ae40fcdbd63Fixed F2 in
e40fcdb(amended into the feature commit): the opt-in testprune_keeps_networks_of_stopped_containersnow creates an unusedkrane-test-prune-unusednetwork, passes onlykrane-test-*networks toprune_networks, and checks that one is deleted while the stopped container's network stays. A canary network outside the test survivescargo test -- --ignored. #24 and #25 rebased on top.