fix: make Jeannie doctor output more actionable
This commit is contained in:
parent
34efb4810f
commit
9491846d43
|
|
@ -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] + "..."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <<EOF
|
||||
You are Jeannie, a local homelab SRE assistant. Use only the evidence below.
|
||||
Homelab topology: Kubernetes runs on Pimox VMs; Debian hosts external services like Gitea, Dex, registry, Ollama, backups, and Jeannie; OCI edge proxies public traffic; RPi provides DNS/support services.
|
||||
|
|
@ -201,7 +214,8 @@ Homelab topology: Kubernetes runs on Pimox VMs; Debian hosts external services l
|
|||
Task:
|
||||
1. Pick the single highest-impact issue to focus first.
|
||||
2. Give likely root cause, evidence, immediate mitigation, and long-term redesign.
|
||||
3. Keep it concise and practical. Do not invent commands not implied by the fix field.
|
||||
3. Return exactly four bullets: Focus, Root cause, Mitigation, Redesign.
|
||||
4. Keep it concise and practical. Do not invent commands not implied by the fix field.
|
||||
|
||||
Report title: ${title}
|
||||
Problems:
|
||||
|
|
@ -213,14 +227,21 @@ EOF
|
|||
--arg model "${model}" \
|
||||
--arg prompt "${prompt}" \
|
||||
'{model: $model, prompt: $prompt, stream: false, options: {temperature: 0.1}}')"
|
||||
response="$(curl -fsS --connect-timeout 2 --max-time "${LAB_DOCTOR_LOCAL_RCA_TIMEOUT_SECONDS:-20}" \
|
||||
set +e
|
||||
response="$(curl -fsS --connect-timeout 2 --max-time "${LAB_DOCTOR_LOCAL_RCA_TIMEOUT_SECONDS:-90}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "${payload}" \
|
||||
"${ollama_url%/}/api/generate" 2>/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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue