Skip to content

feat(kubesoloctl): report every preflight result as json [R8S-1932] - #229

Merged
testA113 merged 2 commits into
developfrom
feat/R8S-1915/R8S-1932/check-json
Oct 26, 2026
Merged

testA113 merged 2 commits into
developfrom
feat/R8S-1915/R8S-1932/check-json

Conversation

@testA113

Copy link
Copy Markdown
Contributor

kubesoloctl check prints text and stops at the first failure. kubesoloctl check --json runs 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 ..." }
  ]
}
  • The result type is types.PreflightReport, in the public types package, which imports only the standard library, so Portainer decodes it with KubeSolo's own type. message is omitted when a check passes; Failed() reports whether any check failed.
  • result is pass, warn or fail. The AppArmor check used to log a warning and pass; it now returns a preflight.Warning, which RunSuite logs the same way before carrying on, so install and plain check print exactly what they did before.
  • The JSON goes to stdout. Log lines, such as packages --install-prereqs installs, stay on stderr.
  • test/firewall/run.sh now also runs check --json against 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, -update to 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 check matched 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

Copilot AI lite review requested due to automatic review settings October 24, 2026 00:18
@linear

linear Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

R8S-1915

R8S-1932

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@github-actions

Copy link
Copy Markdown

Note

PR image published: portainerci/kubesolo:pr-229

@testA113
testA113 merged commit a3c3482 into develop Oct 26, 2026
44 of 51 checks passed
@testA113
testA113 deleted the feat/R8S-1915/R8S-1932/check-json branch October 26, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants