Simplify Jeannie status output
Homelab Main / validate (push) Successful in 1m16s Details
Homelab Main / running-update (push) Successful in 3s Details
Homelab Main / debian-ops (push) Failing after 5s Details

This commit is contained in:
juvenal.diaz 2026-11-11 09:58:10 -06:00
parent 3f51d17250
commit c452eafc3e
6 changed files with 87 additions and 14 deletions

View File

@ -261,12 +261,13 @@ func runReportRender(args []string, in io.Reader, out io.Writer) error {
details := flags.Bool("details", false, "")
only := flags.String("only", "all", "")
asJSON := flags.Bool("json", false, "")
statusSummary := flags.Bool("status-summary", false, "")
if err := flags.Parse(args); err != nil {
usage(os.Stderr)
return err
}
rows, err := parseReportRows(in)
rows, err := parseReportRows(in, !*statusSummary || *asJSON)
if err != nil {
return err
}
@ -283,10 +284,43 @@ func runReportRender(args []string, in io.Reader, out io.Writer) error {
}})
}
renderReportText(out, *title, rows, *details, *only)
if *statusSummary {
renderStatusSummary(out, *title, rows)
} else {
renderReportText(out, *title, rows, *details, *only)
}
return nil
}
func renderStatusSummary(out io.Writer, title string, rows []reportRow) {
fmt.Fprintln(out, title)
fmt.Fprintln(out, strings.Repeat("=", len(title)))
if profile := os.Getenv("LAB_CLUSTER_PROFILE"); profile != "" {
fmt.Fprintf(out, "profile=%s runtime=%s\n", profile, os.Getenv("LAB_CLUSTER_RUNTIME"))
}
for _, area := range orderedReportAreas(rows) {
areaRows := rowsForReportArea(rows, area)
sort.SliceStable(areaRows, func(i, j int) bool { return areaRows[i].Check < areaRows[j].Check })
headerPrinted := false
for _, row := range areaRows {
status := ""
switch row.Status {
case "ok":
status = "OK"
case "warn", "fail":
status = "FAILED"
default:
continue
}
if !headerPrinted {
fmt.Fprintf(out, "\n== %s ==\n", area)
headerPrinted = true
}
fmt.Fprintf(out, "%-6s %s\n", status, row.Check)
}
}
}
func envDefault(name, fallback string) string {
if value := os.Getenv(name); value != "" {
return value
@ -294,7 +328,7 @@ func envDefault(name, fallback string) string {
return fallback
}
func parseReportRows(in io.Reader) ([]reportRow, error) {
func parseReportRows(in io.Reader, diagnose bool) ([]reportRow, error) {
data, err := io.ReadAll(in)
if err != nil {
return nil, err
@ -328,7 +362,7 @@ func parseReportRows(in io.Reader) ([]reportRow, error) {
row.Graph = ""
row.Query = ""
}
if row.Status == "fail" || row.Status == "warn" {
if diagnose && (row.Status == "fail" || row.Status == "warn") {
diagnosis := diagnoseReportRow(row)
row.Cause = diagnosis.Cause
row.Mitigate = diagnosis.Mitigate

View File

@ -32,6 +32,30 @@ func TestReportRenderProblemsOnly(t *testing.T) {
}
}
func TestStatusSummaryShowsOnlyCheckResults(t *testing.T) {
input := strings.Join([]string{
"ok\tHosts\tHealthy\tok\tdetail\tfix\t\t",
"warn\tHosts\tNeeds attention\twarning\tdetail\tfix\t\t",
"fail\tHosts\tUnavailable\terror\tdetail\tfix\t\t",
"skip\tHosts\tNot checked\tskipped\t\t\t\t",
}, "\n")
var output bytes.Buffer
if err := runReportRender([]string{"--status-summary", "--only", "all", "--details"}, strings.NewReader(input), &output); err != nil {
t.Fatal(err)
}
got := output.String()
for _, want := range []string{"OK Healthy", "FAILED Needs attention", "FAILED Unavailable"} {
if !strings.Contains(got, want) {
t.Fatalf("status missing %q:\n%s", want, got)
}
}
for _, unwanted := range []string{"Not checked", "Next Fix", "Mitigate", "detail", "fix"} {
if strings.Contains(got, unwanted) {
t.Fatalf("status contained %q:\n%s", unwanted, got)
}
}
}
func TestRecentInformationalEventDoesNotSuggestFix(t *testing.T) {
input := "info\tRecent events\tGitea client disconnects\tHTTP checks pass; no fix indicated\tdetail\t\t\t\n"
var output bytes.Buffer

View File

@ -12,11 +12,16 @@ Run on the Debian server (or use the same arguments after `./jeannie remote`):
```
`status` and `status all` check all five areas. A scope runs only its checks.
Use `--details` or `--json` after the scope for evidence or structured output.
Use `--json` after the scope for structured output; text output lists checks as
`OK` or `FAILED` without remediation advice. Warnings are displayed as failed
checks and skipped checks are omitted. `--details` remains accepted but does
not expand text output.
For example: `./jeannie remote status opi5 --json`. Scoped reports display
passing checks too and do not invoke an AI model. Checks run concurrently and
use configured inventory addresses, ports and the selected cluster profile.
Warnings return exit status zero; failed checks return a nonzero status.
Warnings return exit status zero; checks classified internally as failures
return a nonzero status. JSON preserves the underlying warning and skip states
for existing consumers.
Each host scope lists discovered Docker Compose containers by project and
service, including Docker health when available. One-off containers are
@ -43,6 +48,6 @@ certificates. An SSH warning can indicate an unavailable host, credentials or
an untrusted host key. These quick probes are point-in-time observations.
Existing unscoped options such as `status --json`, `status --deep`,
`status --ai`, and `status --heal-plan` retain their existing detailed report
and machine-readable behavior. Focused status accepts `--json`, `--details`,
and `status --heal-plan` retain their existing machine-readable and healing
behavior. Focused status accepts `--json`, `--details`,
`--all`, and `--no-local-rca`.

View File

@ -2303,7 +2303,7 @@ overview to that area; cluster uses the selected cluster profile.
cluster Selected Kubernetes cluster and Argo CD applications
Scoped overview options:
--details Include detail fields.
--details Accepted for compatibility; text stays concise.
--json Output structured JSON.
--all Include all results (the scoped overview default).
--no-local-rca Disable AI explanations (already disabled for scopes).
@ -2312,11 +2312,11 @@ Unscoped diagnostic options retain the existing status report:
--fast Run the existing fast diagnostic checks.
--deep Run the deeper diagnostic checks.
--json Output the existing machine-readable diagnostic report.
--details Include detail fields.
--details Accepted for compatibility; text stays concise.
--all Include passing and skipped checks.
--ai Request an unverified AI explanation.
--ai Enable AI analysis in the healing workflow.
--no-local-rca Disable AI explanations.
--verbose Show the older full diagnostic output.
--verbose Run deep checks with concise status output.
--heal-plan Show the proposed healing plan using deep checks.
--heal Run the existing healing workflow using deep checks.
@ -2395,6 +2395,10 @@ status_report() {
JEANNIE_STATUS_MODE=deep
fi
if [[ -z "${heal_mode}" && "${REPORT_UI_VERBOSE}" == true ]]; then
REPORT_UI_VERBOSE=false
fi
if [[ -n "${heal_mode}" ]]; then
status_json="$(mktemp "${TMPDIR:-/tmp}/jeannie-status-json.XXXXXX")"
# shellcheck disable=SC2034
@ -2420,6 +2424,8 @@ status_report() {
if [[ "${REPORT_UI_VERBOSE}" != "true" ]]; then
report_ui_begin
local REPORT_UI_PARALLEL=true
# shellcheck disable=SC2034
local REPORT_UI_STATUS_SUMMARY=true
JEANNIE_REPORT_MODE=true status_cascade_report || cascade_status=$?
report_ui_finish
((REPORT_UI_FAILURES == 0)) || cascade_status=1

View File

@ -256,9 +256,13 @@ report_ui_render() {
args+=(--json)
fi
if [[ "${REPORT_UI_STATUS_SUMMARY:-false}" == true && "${REPORT_UI_JSON}" != true ]]; then
args+=(--status-summary)
fi
"${REPO_ROOT}/scripts/report-render" "${args[@]}" <"${REPORT_UI_ROWS_FILE}"
if [[ "${REPORT_UI_JSON}" != "true" ]] && truthy "${REPORT_UI_LOCAL_RCA:-false}"; then
if [[ "${REPORT_UI_JSON}" != "true" && "${REPORT_UI_STATUS_SUMMARY:-false}" != true ]] && truthy "${REPORT_UI_LOCAL_RCA:-false}"; then
report_ui_local_rca "${title}"
fi
}

View File

@ -175,7 +175,7 @@ status_focused_report() {
shift
# These dynamically scoped variables are consumed by the report helpers.
# shellcheck disable=SC2034
local REPORT_UI_ONLY=all REPORT_UI_LOCAL_RCA=false REPORT_UI_PARALLEL=true
local REPORT_UI_ONLY=all REPORT_UI_LOCAL_RCA=false REPORT_UI_PARALLEL=true REPORT_UI_STATUS_SUMMARY=true
# shellcheck disable=SC2034
local LAB_REPORT_PARALLELISM="${LAB_REPORT_PARALLELISM:-8}"
for arg in "$@"; do