feat(diagnose): Update Consul client to fetch health check output and display diagnostics

This commit is contained in:
2026-02-08 07:44:22 -08:00
parent 3c4c1c4d80
commit 7c0c146d0c
5 changed files with 112 additions and 2 deletions

View File

@@ -80,3 +80,28 @@ def format_node_table(nodes, use_color=True):
])
return tabulate(table_data, headers=headers, tablefmt="simple")
def format_diagnostics(nodes, use_color=True):
"""
Formats detailed diagnostic information for nodes with errors.
"""
error_nodes = [n for n in nodes if n["status"] != "passing" or n.get("litefs_error")]
if not error_nodes:
return ""
output = ["", colorize("DIAGNOSTICS", BOLD, use_color), "=" * 20]
for node in error_nodes:
output.append(f"\n{BOLD}Node:{RESET} {colorize(node['node'], RED, use_color)}")
if node["status"] != "passing":
output.append(f" {BOLD}Consul Check Status:{RESET} {colorize(node['status'], RED, use_color)}")
if node.get("check_output"):
output.append(f" {BOLD}Consul Check Output:{RESET}\n {node['check_output'].strip()}")
if node.get("litefs_error"):
output.append(f" {BOLD}LiteFS API Error:{RESET} {colorize(node['litefs_error'], RED, use_color)}")
return "\n".join(output)