From 9491846d4313e233f1785dac41bbce1190957a57 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Tue, 6 Oct 2026 14:56:08 -0600 Subject: [PATCH] fix: make Jeannie doctor output more actionable --- cmd/jeannie-core/main.go | 16 +++++++++++++--- scripts/report-ui | 31 ++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/cmd/jeannie-core/main.go b/cmd/jeannie-core/main.go index 24e9a23..4445c94 100644 --- a/cmd/jeannie-core/main.go +++ b/cmd/jeannie-core/main.go @@ -462,6 +462,9 @@ func renderReportText(out io.Writer, title string, rows []reportRow, details boo } else { fmt.Fprintf(out, "Investigate %s / %s\n", row.Area, row.Check) } + if row.Mitigate != "" { + fmt.Fprintf(out, "Mitigate: %s\n", row.Mitigate) + } return } } @@ -501,6 +504,10 @@ func diagnoseReportRow(row reportRow) reportDiagnosis { diagnosis.Cause = "A node cannot pull the image it was scheduled to run. Likely causes are unsigned/stale tag, missing image, insecure registry config drift, or the registry endpoint not reachable from Pimox workers." diagnosis.Mitigate = "Run the apps pipeline to rebuild/sign/push the image, verify worker access to the registry, and restart only the affected deployment." diagnosis.Redesign = "Make registry endpoint, insecure registry setup, signing policy, and image overrides generated from the same profile inputs." + case containsAny(text, "containerstatusunknown", "evicted"): + diagnosis.Cause = "Kubernetes has stale or unhealthy pod records, usually after node disruption, kubelet/container runtime restart, disk or memory pressure, or an interrupted local-registry rollout." + diagnosis.Mitigate = "Focus on the current owner first: verify nodes are Ready, then delete stale Evicted/ContainerStatusUnknown pods and confirm the deployment/daemonset recreates healthy replicas." + diagnosis.Redesign = "Add cleanup for stale terminated pods after disruptive Pimox/node recovery and keep local-registry replicas/storage sized for node pressure events." case containsAny(text, "pending", "didn't match pod's node affinity", "insufficient", "taint", "unbound immediate persistentvolumeclaims"): diagnosis.Cause = "The scheduler cannot place the pod. The usual cause is node affinity/selector drift, missing labels, taints, resource pressure, or storage claims not bound." diagnosis.Mitigate = "Describe the pod and compare requested selectors/tolerations/resources with current node labels and capacity; reapply the profile/policy that owns those labels." @@ -509,7 +516,7 @@ func diagnoseReportRow(row reportRow) reportDiagnosis { diagnosis.Cause = "A Kubernetes node is unhealthy or under pressure. On Pimox this often points to VM health, CPU pinning, storage health, kubelet/containerd, or CNI readiness." diagnosis.Mitigate = "Check the specific node condition, kubelet status, and Pimox VM state before restarting workloads; recover the node first." diagnosis.Redesign = "Add capacity guardrails and profile-specific VM sizing/pinning so the cluster stays inside OPI5/Pimox limits." - case containsAny(text, "qemu guest agent is not running", "qm", "vm", "pimox", "storage", "input/output error"): + case containsAny(text, "qemu guest agent is not running", "guest agent", "pimox", "input/output error"): diagnosis.Cause = "The virtualization layer is unhealthy or unreachable. Likely causes are Pimox storage trouble, stopped/stuck VM, guest-agent failure, or CPU/storage pressure." diagnosis.Mitigate = "Check Pimox storage and VM status first; avoid rebuilding Kubernetes until the VM and disk layer are healthy." diagnosis.Redesign = "Keep VM CPU affinity, storage checks, and backup/restore drills as first-class profile checks." @@ -556,7 +563,7 @@ func assessReportImpact(row reportRow) reportImpact { case containsAny(text, "kubernetes", "api ready", "nodes ready", "notready", "control-plane", "pimox runtime"): score += 40 label = "critical - cluster control plane or node availability is affected" - case containsAny(text, "registry", "imagepullbackoff", "errimagepull", "failed to pull"): + case containsAny(text, "registry", "imagepullbackoff", "errimagepull", "failed to pull", "containerstatusunknown", "evicted"): score += 35 label = "high - deployments cannot recover or roll out reliably" case containsAny(text, "backup", "restore"): @@ -644,5 +651,8 @@ func truncate(value string, max int) string { if len(value) <= max { return value } - return value[:max] + if max <= 3 { + return value[:max] + } + return value[:max-3] + "..." } diff --git a/scripts/report-ui b/scripts/report-ui index 05becd2..e43d56d 100644 --- a/scripts/report-ui +++ b/scripts/report-ui @@ -175,6 +175,8 @@ report_ui_local_rca() { local payload local response local answer + local tags_response + local curl_status problems="$(awk -F'\t' ' ($1 == "fail" || $1 == "warn") { @@ -194,6 +196,17 @@ report_ui_local_rca() { return 0 fi + tags_response="$(curl -fsS --connect-timeout 2 --max-time 5 "${ollama_url%/}/api/tags" 2>/dev/null || true)" + if [[ -z "${tags_response}" ]]; then + printf 'skipped: Ollama is not reachable at %s; deterministic focus above is still valid.\n' "${ollama_url%/}" + return 0 + fi + if ! printf '%s' "${tags_response}" | jq -e --arg model "${model}" '.models[]?.name == $model' >/dev/null 2>&1; then + printf 'skipped: model %s is not installed in Ollama; deterministic focus above is still valid.\n' "${model}" + printf 'hint: set LAB_DOCTOR_LOCAL_MODEL to one from `ollama list`, or pull %s.\n' "${model}" + return 0 + fi + prompt="$(cat </dev/null || true)" + "${ollama_url%/}/api/generate" 2>/dev/null)" + curl_status=$? + set -e answer="$(printf '%s' "${response}" | jq -r '.response // empty' 2>/dev/null || true)" if [[ -z "${answer}" ]]; then - printf 'skipped: Ollama did not return a local RCA from %s using model %s.\n' "${ollama_url%/}" "${model}" - printf 'fix: start Ollama or set LAB_DOCTOR_LOCAL_MODEL to an installed local model.\n' + if [[ "${curl_status}" -eq 28 ]]; then + printf 'skipped: model %s timed out after %ss; deterministic focus above is still valid.\n' "${model}" "${LAB_DOCTOR_LOCAL_RCA_TIMEOUT_SECONDS:-90}" + printf 'hint: use LAB_DOCTOR_LOCAL_MODEL=qwen2.5:0.5b or increase LAB_DOCTOR_LOCAL_RCA_TIMEOUT_SECONDS.\n' + else + printf 'skipped: Ollama returned no RCA using model %s; deterministic focus above is still valid.\n' "${model}" + fi return 0 fi