Repository navigation
feat(cli): add kamal doctor deploy readiness diagnostics - #31
Merged
Merged
Conversation
## Summary
New read-only `kamal doctor` command that reports OK/WARN/FAIL per check
before a deploy: SSH reachability, Docker running, registry login, proxy
image manifest fetchable, running proxy version vs MINIMUM_VERSION, ports
80/443 (or configured) free or proxy-held, DNS resolution of proxy host
domains against server IPs, and TLS certificate expiry (custom PEM parsed
locally, ACME-managed checked live). Exits 1 on any FAIL; never crashes on
a broken environment - failures become failing rows.
Remote checks run per host through Kamal::Cli::Doctor::HostChecks (SSHKit
backend injected, App::Boot pattern); DNS/cert checks run locally in
Kamal::Cli::Doctor::EndpointChecks. Command builders added as
Commands::Docker#manifest_available? and Commands::Server#listeners_on.
## Test Coverage
- all-green run incl. per-check output rows and exit 0
- proxy version too old / running-at-minimum / not-running paths
- port conflict FAIL, proxy-held ports OK
- DNS unresolvable FAIL, DNS-elsewhere WARN (CDN-friendly)
- expired custom cert FAIL, expiring-soon WARN, unreachable TLS WARN
- local registry skips docker login
- unreachable host becomes an SSH FAIL row, not a crash
## Verification
- [x] bundle exec rubocop --parallel passes
- [x] unit tests pass (only pre-existing host-arch/Docker-daemon builder
failures remain; verified identical on pristine main)
Refs #9
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.
Summary
New read-only
kamal doctorcommand (ROADMAP R1, pgbus#212 pattern) that reports OK/WARN/FAIL per check before a deploy and exits 1 on any FAIL:trueprobe forces a connectiondocker versiondocker login(skipped for local registry)docker manifest inspecton the configured proxy imageProxy::Run::MINIMUM_VERSIONss -ltnHon configured http/https ports; proxy-held = OKResolv.getaddresses(domain)∩ server IPs; mismatch = WARN (CDN-friendly)Kamal::Cli::Main#doctor→Kamal::Cli::Doctor(orchestrator) →Kamal::Cli::Doctor::HostChecks(SSHKit backend injected,App::Bootpattern) +Kamal::Cli::Doctor::EndpointChecks(local DNS/TLS)Kamal::Commands::Docker#manifest_available?,Kamal::Commands::Server#listeners_on— argv arrays, no inline shell stringsdeploy.ymlkeys; respects--hosts/--roles; no deploy lock (read-only)Closes #9
Test plan
test/cli/doctor_test.rb— 11 cases: all-green, proxy too old / at minimum / not running, port conflict, proxy-held ports, DNS unresolvable / elsewhere, expired + expiring + unreachable TLS certs, local registry skip, unreachable host → SSH FAIL row (no crash)test/commands/docker_test.rb/server_test.rb— new builder assertionsbundle exec rubocop --parallelclean; unit suite green apart from pre-existing host-arch/Docker-daemon builder failures (verified identical on pristinemainworktree)kamal doctoragainst a real target reports pass/fail per check (issue's verify step)Deviations & judgment calls
Deviations
Discoveries
dash, not onmain-rooted branches — read the R1 anchor viagit show dash:ROADMAP.md.main(upstream), soMINIMUM_VERSIONhere is upstream'sv0.9.2and the default proxy repo isbasecamp/kamal-proxy. Doctor reads both from config/constants, so the dash merge needs no doctor changes.SSHKit::Backend::Printer(test backend) never sets an exit status, soexecutereturns false under it — doctor tests stub a catch-allexecute → trueand override per test.mainshows 7 pre-existing builder/build failures, not the 2 documented Apple-Silicon ones — the extra 5 areCliBuildTest#test_dev*needing a running Docker daemon plus 2 more arch-dependent asserts. Verified identical on amainworktree; none touch doctor paths.Judgment calls
docker login(mutates~/.docker/config.json) — exactly what every deploy does, and the only faithful auth check.modifyblock — read-only diagnostics, likekamal details.StandardErrorat per-host/per-domain boundaries, against the "rescue specific errors" style rule — the doctor contract (pgbus#212) is "never raises on a broken environment"; connection failures span Net::SSH::, Errno::, SocketError, Timeout::Error.proxy boot_confighost-file overrides (deprecated) are ignored when computing the expected proxy image; onlyproxy.runconfig + defaults count.ss -pneeds root).kamal-proxy:#{MINIMUM_VERSION}) so this new test file merges intodashwithout the org-fixup conflicts the playbook requires for older proxy tests.