Allow Holmes repair tools and retain crash error lines
This commit is contained in:
parent
1a90877e47
commit
d783b94c7f
|
|
@ -70,7 +70,9 @@ cluster context, records a change journal entry, enables Holmes tools and
|
|||
automatically allows Bash commands. **Holmes has the Debian user's host-level
|
||||
permissions**, including any passwordless sudo access; this is not a sandbox or
|
||||
an application-scoped permission boundary. Its actions can change the cluster
|
||||
or host. Holmes is asked for a diagnosis, an evidence-based five whys analysis,
|
||||
or host. Repair mode sets Holmes's `BASH_TOOL_UNSAFE_ALLOW_ALL` environment
|
||||
variable in addition to the CLI flag; support depends on the installed Holmes
|
||||
version. Holmes is asked for a diagnosis, an evidence-based five whys analysis,
|
||||
the repair, validation and recommendations, marking unsupported causes as
|
||||
unknown. Doctor saves its output, errors and a report in a private artifact
|
||||
directory, then independently checks the selected application's Argo CD health
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ doctor_focus_holmes_fix() {
|
|||
} >"${artifact}/holmes-prompt.txt"
|
||||
record_change_journal "doctor-holmes-k8s-repair" "${item}"
|
||||
echo "Holmes is authorized to execute commands to repair ${item}; its Bash tool has host-level access."
|
||||
if ! timeout "${LAB_HOLMES_TRIAGE_TIMEOUT_SECONDS:-360}" env KUBECONFIG="${KUBECONFIG_PATH}" \
|
||||
if ! timeout "${LAB_HOLMES_TRIAGE_TIMEOUT_SECONDS:-360}" env KUBECONFIG="${KUBECONFIG_PATH}" BASH_TOOL_UNSAFE_ALLOW_ALL=true \
|
||||
OPENAI_BASE_URL="${OPENAI_BASE_URL:-http://127.0.0.1:20128/v1}" \
|
||||
OPENAI_API_BASE="${OPENAI_BASE_URL:-http://127.0.0.1:20128/v1}" OPENAI_API_KEY="${key}" \
|
||||
"${bin}" ask --config "${config}" --prompt-file "${artifact}/holmes-prompt.txt" \
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ def main():
|
|||
mode = sys.argv[1]
|
||||
if mode == "logs":
|
||||
data = sys.stdin.buffer.read(8193).decode("utf-8", errors="replace")
|
||||
for line in data.splitlines()[-8:]:
|
||||
lines = data.splitlines()
|
||||
selected = lines if len(lines) <= 8 else lines[:4] + lines[-4:]
|
||||
for line in selected:
|
||||
print("previous log:", clean(line)[:200])
|
||||
if not data:
|
||||
print("Previous container logs were empty.")
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class DoctorFocusTests(unittest.TestCase):
|
|||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
binary = root / "jeannie-holmes"
|
||||
binary.write_text("#!/bin/sh\ncase \" $* \" in *' --bash-always-allow '*) echo 'attempted repair';; *) exit 3;; esac\n")
|
||||
binary.write_text("#!/bin/sh\n[ \"${BASH_TOOL_UNSAFE_ALLOW_ALL:-}\" = true ] || exit 4\ncase \" $* \" in *' --bash-always-allow '*) echo 'attempted repair';; *) exit 3;; esac\n")
|
||||
binary.chmod(0o755)
|
||||
rows = root / "rows"
|
||||
rows.write_text("warn\tKubernetes apps\tn8n\tUnavailable\n")
|
||||
|
|
@ -295,6 +295,15 @@ doctor_runner_report
|
|||
self.assertNotIn("secret123", result.stdout)
|
||||
self.assertNotIn("secret456", result.stdout)
|
||||
|
||||
def test_crash_log_preserves_exception_and_stack_tail(self):
|
||||
script = str(ROOT / "scripts/doctor-pod-evidence.py")
|
||||
lines = ["Error: read-only filesystem"] + [f"stack line {i}" for i in range(12)]
|
||||
result = subprocess.run([sys.executable, script, "logs"], input="\n".join(lines),
|
||||
capture_output=True, text=True, check=True)
|
||||
self.assertIn("Error: read-only filesystem", result.stdout)
|
||||
self.assertIn("stack line 11", result.stdout)
|
||||
self.assertNotIn("stack line 5", result.stdout)
|
||||
|
||||
def test_selected_item_does_not_inherit_unrelated_failure(self):
|
||||
code = r'''
|
||||
source "$1"
|
||||
|
|
|
|||
Loading…
Reference in New Issue