Repository navigation
doctor: detect stale kubeconfig, local port collisions and orphaned runtime sockets - #127
Closed
Jonesc2321601 wants to merge 2 commits into
Closed
Jonesc2321601 wants to merge 2 commits into
Jonesc2321601 wants to merge 2 commits into
Conversation
…untime sockets Adds three read-only self-checks to \hanzo doctor\ (issue hanzoai#111), each printing an exact one-line fix command: - kubeconfig: missing file, invalid YAML, absent apiVersion/clusters, or a localhost API endpoint that is not listening - local ports: 8080, 9090, 1234, 8000 already bound on loopback - runtime sockets: orphaned *.sock / *.pid under ~/.hanzo (dead pid, or untouched for 24h) The analysis is a pure function over a Snapshot (kubeconfig body, busy ports, socket states) so every branch is covered by deterministic unit tests that need neither a live cluster nor a real runtime directory. No new dependencies.
Member
|
Thanks for working on #111, @Jonesc2321601! Closing this PR in favor of #121, which has now been merged. A few specific technical notes from our review for future reference:
Appreciate your effort and detailed writeup! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #111.
What this adds
hanzo doctornow runs three extra self-checks and prints an exact one-line fix command for every one that fails:~/.kube/hanzo.yamlmissing, not valid YAML, missingapiVersion/clusters, or pointing at a127.0.0.1:<port>API endpoint that is not listeninghanzo up/hanzo k8s restart8080,9090,1234,8000already bound on loopbacklsof -nP -iTCP:8080 -sTCP:LISTEN(POSIX) ornetstat -ano | findstr :8080(Windows)*.sock/*.pidunder~/.hanzo(recorded pid is gone, or the socket has been untouched for more than 24h)rm -f <path>/del /f <path>The whole pass is read-only: it reads the kubeconfig, probes the four ports with
TcpListener::bind(("127.0.0.1", port)), andstats the runtime directories. No cluster, no network, no mutations.Implementation notes
Snapshot(kubeconfigbody,busy_ports,sockets), so every branch is covered by deterministic unit tests that need neither a live cluster nor a real runtime layout — exactly what the acceptance criteria ask for.serde_norway(already a dependency for-o yaml), and liveness useslibc::kill(pid, 0)on unix, falling back to age-only detection on targets without a portable signal probe.FAILfrom the kubeconfig check joins the existingfailurescounter, sohanzo doctorstill exits non-zero when the config is unusable; port and socket collisions stayWARNbecause they do not necessarily break the current invocation.LOCAL_PORT/ k3s API port are expected to be busy whenever the local cloud is up, so including them would only add noise.Reproducible build/test output
clippy reports no lints for the new code; the eight dead-code warnings printed on Windows (
describe,host_memory_mb,host_share,disk_verdict,QUIESCE_GUEST_SCRIPT,stop_and_save_in,warm_digest,mkdir/write_bytes/checkpoint/close_stdin) are pre-existing platform-gated items inup/vmand untouched by this PR.Sample output
Test plan
cargo test --locked --bin hanzo doctor::— 9/9 pass, including five new testscargo clippy --locked --bin hanzo— no new lintshanzo doctorwith a valid kubeconfig, a busy8080, and an orphaned pid file prints oneOKand twoWARNlines with runnable commands