Repository navigation
feat(kubesoloctl): report every preflight result as json [R8S-1932] - #229
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The JSON mode must retain architecture validation and report detection failures before approval.
No open issues 🎉
What changed in this PR
This pull request adds kubesoloctl check --json, producing a single machine-readable report containing every preflight result while preserving existing text-mode behavior.
Changes:
- Adds public preflight report and result types with JSON serialization and failure detection.
- Runs all checks for JSON output, distinguishing passes, warnings, and failures while preserving stderr diagnostics.
- Extends unit, golden-file, firewall integration, and documentation coverage.
Review finding: Moderate (1 vote): the JSON path skips architecture detection, so unsupported hosts may incorrectly report readiness. The existing architecture validation should be preserved and represented in the JSON report.
| File | Description |
|---|---|
types/preflight.go |
Defines public preflight report and result types. |
types/preflight_test.go |
Tests report JSON round-tripping and failure detection. |
test/firewall/run.sh |
Validates JSON results against real firewall configurations. |
internal/cli/preflight/testdata/report.json |
Provides the golden JSON report fixture. |
internal/cli/preflight/report_test.go |
Tests complete execution, warnings, failures, logging, and golden output. |
internal/cli/preflight/preflight.go |
Adds aggregate reporting and warning handling. |
internal/cli/cmd_check.go |
Adds the --json command path and exit-status handling. |
internal/cli/cmd_check_test.go |
Tests JSON encoding, messages, and failure status behavior. |
docs/installation/kubesoloctl.md |
Documents the new JSON reporting option. |
Review effort: Lite
|
Note PR image published: |
stevensbkang
approved these changes
Oct 26, 2026
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.
kubesoloctl checkprints text and stops at the first failure.kubesoloctl check --jsonruns every pre-flight check and prints one JSON document with each check's name, result and message, so Portainer's connection test (R8S-2008) can show every problem on a machine at once. It exits non-zero when any check failed.{ "checks": [ { "name": "root privileges", "result": "pass" }, { "name": "AppArmor parser", "result": "warn", "message": "AppArmor is enabled but apparmor_parser is missing: ..." }, { "name": "host firewall", "result": "fail", "message": "pods cannot reach the API server at ..." } ] }types.PreflightReport, in the publictypespackage, which imports only the standard library, so Portainer decodes it with KubeSolo's own type.messageis omitted when a check passes;Failed()reports whether any check failed.resultispass,warnorfail. The AppArmor check used to log a warning and pass; it now returns apreflight.Warning, whichRunSuitelogs the same way before carrying on, soinstalland plaincheckprint exactly what they did before.--install-prereqsinstalls, stay on stderr.test/firewall/run.shnow also runscheck --jsonagainst each real firewall, which fails with the firewall's help text and passes once the rules are added.Tests: stub checks in the preflight package (every check runs after a failure, warnings, a real port conflict, AppArmor warning on hosts that have it), a golden JSON fixture (
internal/cli/preflight/testdata/report.json,-updateto rewrite), a round trip of the type, and the exit code and message encoding of the command.Checked by hand in containers: Ubuntu, Debian, Rocky, UBI minimal, openSUSE, Alpine and BusyBox; armv7, riscv64 and amd64 under emulation; non-root, read-only root, an empty environment, a held port, a Docker socket, an invalid hostname and a faked AppArmor; and container mode on macOS. Each printed one valid report with the expected exit code, and the text output of
checkmatched develop's byte for byte.Not in this PR: on a machine already running KubeSolo the port check fails, and the report does not yet say the ports are KubeSolo's own (raised on R8S-1932 from the R8S-2006 spike).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WUTscEW1u8akQZb9HeYkif