You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: keep ksail-desktop running without Docker and after closing the window (#5354)
* fix(k3d): never os.Exit the host when the Docker runtime is unavailable
k3d's embedded cobra commands call logrus Fatal on their own logger
(k3dlogger.Log(), not the standard logger) when the Docker daemon is
unreachable, and logrus Fatal calls os.Exit(1) — terminating the whole
host process. This crashed ksail-desktop on boot and `ksail ui` on its
first request (cluster discovery enumerates k3d clusters) whenever Docker
Desktop was not running, and would also crash a Docker-down cluster
create/update.
Neutralize it once in NewProvisioner by permanently replacing k3d's
logger ExitFunc with one that panics a sentinel (ErrK3dRuntimeUnavailable),
and route every site that runs a k3d command through a single recover
seam, runK3dSafely, which converts that panic into a returned error and
re-raises any other panic. Because the ExitFunc is process-global, the
seam must cover every site: List (discovery), the create/delete/start/stop
lifecycle commands, and the add/remove/list agent-node commands used by
`cluster update` — including one that runs in its own goroutine, where an
unrecovered panic would be uncatchable.
silenceK3dLogging now only mutes output (the lifecycle/node paths keep
k3d progress visible). Other distributions are unaffected: kind/talos/
vcluster use SDKs, and kwok's embedded kwokctl commands use cobra RunE
(returning errors) — k3d is the only distribution embedding Fatal-calling
commands.
Adds real-runtime regression tests that point DOCKER_HOST at a dead
socket and assert List and all seven k3d command sites return an error
instead of exiting the process.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(desktop): hide window to tray on close instead of destroying it
ksail-desktop is a menu-bar app, but Wails v3's default WindowClosing
listener destroys the window when it is closed (red button / Cmd+W). Once
destroyed, the tray's "Show KSail" only tries to recreate the window — a
no-op on this Wails alpha, so nothing happens — and "Hide KSail" calls
hide on the freed native window, crashing the whole process. Those are the
two reported tray failures.
Register a WindowClosing hook that cancels the close and hides the window
instead. Hooks run before listeners and short-circuit them when the event
is cancelled, so the destroying listener is skipped and the single window
stays alive and reopenable for the app's lifetime. Quitting is unaffected:
the tray's "Quit KSail" and Cmd+Q call app.Quit() directly, which never
emits WindowClosing and so bypasses the hook.
Adds a unit test for the hook's cancel-and-hide behavior (the hook body is
split behind a small interface so it can be exercised without a live GUI
window).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(k3d): restore os.Stdout after the command goroutine to avoid a data race
The List and node-list paths redirect the process-global os.Stdout to a
pipe to capture k3d's JSON output, run the k3d command in a goroutine, then
restore os.Stdout. k3d's docker client reads os.Stdout (via
moby/term.StdStreams) while building its CLI, so the restore on the main
goroutine raced that read: io.Copy unblocking on pipe EOF is not a
happens-before edge the race detector recognizes, and the restore ran
before the errChan receive that actually synchronizes with the goroutine.
CI runs the suite with -race and flagged it; the new real-runtime tests are
the first to exercise these paths against the real k3d runtime and so
exposed a pre-existing race. Move the errChan receive ahead of the
os.Stdout restore in both defaultListClustersRaw and listAgentNodes so the
restore happens-after the goroutine's stdout access.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments