feat: pick the engine from Docker contexts, with one shared client #28
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/16-engine-picker"
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?
Closes #16
Krane can now talk to any engine the docker CLI knows: local Docker, rootless Podman, and remote engines over SSH or TCP+TLS. You pick it from a menu at the bottom of the sidebar.
Engine menu. Click the engine status (dot, version, running count) to open it.
defaultplus every context in~/.docker/contexts(or$DOCKER_CONFIG), each with its description and address. The list is read fresh each time the menu opens.SkipTLSVerify, or an address Krane can't use, are listed greyed out with the reason.default.Which engine. The order matches the CLI:
DOCKER_HOST. When it's set, it wins and the menu is locked with a note.enginein~/.config/krane/settings.json.$DOCKER_CONTEXT, thencurrentContextin config.json.default.A saved context that has since been removed is skipped. Krane never runs
docker context use.Switching. Krane connects and asks the new engine for its version, giving it up to 5 s. If that works:
If the engine doesn't answer, an alert says so ("deadhost didn't answer within 5 seconds.") and Krane stays on the engine it had.
Must-dos from the plan
engine::client()): all 14connect_with_local_defaults()call sites now use it, including statsfollow()from #11 (which made a client per container), pulls, logs, notifications and the resource watcher. Over SSH this means one ssh session, not one per call.Other changes
sshandsslfeatures, and sha2 is added (the CLI stores each context under the SHA-256 of its name).docker exec) runsdocker --context <name>. The terminals that Open in Terminal (#20) opens getDOCKER_CONTEXT=<name>. Neither does this whenDOCKER_HOSTis set, because--contextwould win over it.Tests
default(Docker 29.9) →podman(Podman 5.4.2). Containers and images changed over within a second.podman.tcp://10.255.255.1:2375context: an alert after 5 s, and Krane stayed on podman.DOCKER_HOSTset, the menu was locked.Screenshots (mock engines;
labshows an unsupported SkipTLSVerify context)d6775f29924a33b9aa104a33b9aa109cdb6df985Review from Nye (posted by Upper Wolfjaw) — at
d6775f2PR #28 (#16 engine picker) review — Nye,
d6775f2Verdict: changes requested (one medium finding, F12). Everything else checks out.
Passed
through podman (Podman 5.4.2), sshlocal (ssh://peak@localhost), tlsctx (tcp :2376, client cert
required), tcpplain (tcp :2375), default. Each lists exactly the containers
docker --context X ps -alists; cli_args() = --context X. deadtcp (blackholed 10.255.255.1) fails with"deadtcp didn't answer within 5 seconds." after 5.0 s and Krane stays on the old engine.
DOCKER_TLS_VERIFY/DOCKER_CERT_PATH all list the CLI's containers; switch() is refused; no --context.
status ("Podman 5.4.2 · podman"); deadtcp shows "Couldn't Switch Engine" dialog after 5 s.
logs, notify events and resource events all end on switch.
F12 (medium): resources stuck after switching away from a dead engine
spawn_resource_watch awaits fetch_resources() on the old client with no timeout and no switch
check. If the engine doesn't answer (saved choice is a remote that's down, or it drops mid-read),
the loop sits in list_volumes until bollard's 120 s request timeout. Switching to a good engine
brings containers back at once, but Volumes/Images/Networks stay empty for up to 2 minutes.
Proof:
bash notes/pr28-switch-away-proof.shin a PR worktree (appendsnotes/pr28-switch-away-test.rs and runs it): 15 s after switching deadtcp -> default there are
0 networks. Fix sketch (notes/pr28-f12-fix.patch): select! fetch_resources against
engine::switches().changed(); with it the test passes in 1.5 s. (Old-engine errors arriving
after a switch are dropped too.)
Notes, not findings
first finishes last and wins. Low; could ignore a switch() that isn't the latest request.
connect; a slow remote with many containers over ssh could flap "unreachable". Not seen here.
F12 fixed in
9cdb6df(rebased onto main now that #26/#27 merged). The resource loopselect!sfetch_resourcesagainstengine::switches(), so a switch drops the dead engine's request straight away (Nye's sketch), and it marks sizes stale so the new engine's volume sizes are read on the next pass. Nye's switch-away test: 8 networks / 19 images 1.5 s after switching away from a blackholed tcp engine. Back to Nye for recheck.