conductor(checkpoint): Checkpoint end of Phase 3 - UI and Health Logic
This commit is contained in:
@@ -44,7 +44,15 @@ def format_node_table(nodes, use_color=True):
|
||||
for node in nodes:
|
||||
# Consul status color
|
||||
status = node["status"]
|
||||
status_color = GREEN if status == "passing" else RED
|
||||
if status == "passing":
|
||||
status_color = GREEN
|
||||
elif status == "standby":
|
||||
status_color = CYAN
|
||||
elif status == "unregistered":
|
||||
status_color = YELLOW
|
||||
else:
|
||||
status_color = RED
|
||||
|
||||
colored_status = colorize(status, status_color, use_color)
|
||||
|
||||
# Role color
|
||||
@@ -90,7 +98,9 @@ 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")]
|
||||
# Only show diagnostics if status is critical/unregistered OR if there is a LiteFS error
|
||||
# Ignore 'standby' since it is expected for replicas
|
||||
error_nodes = [n for n in nodes if (n["status"] not in ["passing", "standby"]) or n.get("litefs_error")]
|
||||
|
||||
if not error_nodes:
|
||||
return ""
|
||||
|
||||
@@ -54,8 +54,25 @@ def test_format_diagnostics_empty():
|
||||
"node": "node1",
|
||||
"status": "passing",
|
||||
"litefs_error": None
|
||||
},
|
||||
{
|
||||
"node": "node2",
|
||||
"status": "standby", # Should also be empty
|
||||
"litefs_error": None
|
||||
}
|
||||
]
|
||||
diagnostics = output_formatter.format_diagnostics(nodes, use_color=False)
|
||||
assert diagnostics == ""
|
||||
|
||||
def test_format_node_table_status_colors():
|
||||
"""Test that different statuses are handled."""
|
||||
nodes = [
|
||||
{"node": "n1", "role": "primary", "status": "passing", "litefs_primary": True},
|
||||
{"node": "n2", "role": "replica", "status": "standby", "litefs_primary": False},
|
||||
{"node": "n3", "role": "primary", "status": "unregistered", "litefs_primary": True},
|
||||
]
|
||||
table = output_formatter.format_node_table(nodes, use_color=False)
|
||||
assert "passing" in table
|
||||
assert "standby" in table
|
||||
assert "unregistered" in table
|
||||
|
||||
|
||||
Reference in New Issue
Block a user