From 002bdfa964c5090b8e1e895a53f5852ec495fe92 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Thu, 8 Oct 2026 12:08:34 -0600 Subject: [PATCH] fix: run Holmes k8s doctor with generated AI config --- lib/jeannie/commands.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 1da8add..529c692 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -2070,6 +2070,7 @@ doctor_k8s() { local run_holmes=true local output_json=false local artifact_base="${LAB_DOCTOR_K8S_ARTIFACT_DIR:-${HOMELAB_STATE_DIR:-${HOME}/.local/share/homelab}/doctor-k8s}" + local tools_env_file="${LAB_AI_STACK_TOOLS_ENV_FILE:-/data/homelab-ai-stack/ai-tools.env}" local timestamp local artifact_dir local kubeconfig="${KUBECONFIG_PATH}" @@ -2084,6 +2085,10 @@ doctor_k8s() { local holmes_stdout local holmes_stderr local holmes_combined + local holmes_config="${LAB_HOLMES_CONFIG_FILE:-/dev/null}" + local holmes_api_key="${LAB_AI_GATEWAY_API_KEY:-${OPENAI_API_KEY:-sk_omniroute}}" + local holmes_model="${LAB_HOLMES_MODEL:-${AI_STACK_AGENT_SMART_MODEL:-agent-smart-free}}" + local holmes_fast_model="${LAB_HOLMES_FAST_MODEL:-${AI_STACK_AGENT_FAST_MODEL:-agent-fast-free}}" local arg require_debian_server "doctor-k8s" @@ -2126,11 +2131,22 @@ EOF holmes_stderr="${artifact_dir}/holmes-error.txt" mkdir -p "${artifact_dir}" + if [[ -r "${tools_env_file}" && -s "${tools_env_file}" ]]; then + # shellcheck disable=SC1090 + . "${tools_env_file}" + holmes_api_key="${OPENAI_API_KEY:-${LAB_AI_GATEWAY_API_KEY:-${holmes_api_key}}}" + holmes_model="${LAB_HOLMES_MODEL:-${AI_STACK_AGENT_SMART_MODEL:-${holmes_model}}}" + holmes_fast_model="${LAB_HOLMES_FAST_MODEL:-${AI_STACK_AGENT_FAST_MODEL:-${holmes_fast_model}}}" + fi + { printf 'command=doctor-k8s\n' printf 'timestamp=%s\n' "${timestamp}" printf 'kubeconfig=%s\n' "${kubeconfig}" printf 'cluster_profile=%s\n' "${LAB_CLUSTER_PROFILE:-debian}" + printf 'holmes_config=%s\n' "${holmes_config}" + printf 'holmes_model=%s\n' "${holmes_model}" + printf 'holmes_fast_model=%s\n' "${holmes_fast_model}" } >"${artifact_dir}/metadata.env" if [[ ! -s "${kubeconfig}" ]]; then @@ -2197,7 +2213,16 @@ EOF set -e elif [[ -n "${holmes_bin}" ]]; then set +e - timeout "${holmes_timeout}" env KUBECONFIG="${kubeconfig}" "${holmes_bin}" ask "$(cat "${prompt_file}")" >"${holmes_stdout}" 2>"${holmes_stderr}" + timeout "${holmes_timeout}" env KUBECONFIG="${kubeconfig}" OPENAI_BASE_URL="${OPENAI_BASE_URL:-http://127.0.0.1:20128/v1}" OPENAI_API_KEY="${holmes_api_key}" \ + "${holmes_bin}" ask \ + --config "${holmes_config}" \ + --prompt-file "${prompt_file}" \ + --api-key "${holmes_api_key}" \ + --model "${holmes_model}" \ + --fast-model "${holmes_fast_model}" \ + --no-interactive \ + --bash-always-deny \ + >"${holmes_stdout}" 2>"${holmes_stderr}" holmes_status=$? set -e else