atlasbot: fix bottom ops and pod queries
This commit is contained in:
parent
c5a7eece35
commit
f43acaa554
@ -163,6 +163,8 @@ CLUSTER_HINT_WORDS = {
|
|||||||
"documentation",
|
"documentation",
|
||||||
"docs",
|
"docs",
|
||||||
"playbook",
|
"playbook",
|
||||||
|
"utilization",
|
||||||
|
"usage",
|
||||||
"grafana",
|
"grafana",
|
||||||
"victoria",
|
"victoria",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
@ -561,8 +563,10 @@ def _has_any(text: str, phrases: tuple[str, ...]) -> bool:
|
|||||||
def _detect_operation(q: str) -> str | None:
|
def _detect_operation(q: str) -> str | None:
|
||||||
if _has_any(q, OPERATION_HINTS["top"]):
|
if _has_any(q, OPERATION_HINTS["top"]):
|
||||||
return "top"
|
return "top"
|
||||||
|
if _has_any(q, OPERATION_HINTS["bottom"]):
|
||||||
|
return "bottom"
|
||||||
for op, phrases in OPERATION_HINTS.items():
|
for op, phrases in OPERATION_HINTS.items():
|
||||||
if op == "top":
|
if op in ("top", "bottom"):
|
||||||
continue
|
continue
|
||||||
if _has_any(q, phrases):
|
if _has_any(q, phrases):
|
||||||
return op
|
return op
|
||||||
@ -1353,6 +1357,11 @@ def snapshot_metric_answer(
|
|||||||
failed = metrics.get("pods_failed")
|
failed = metrics.get("pods_failed")
|
||||||
succeeded = metrics.get("pods_succeeded")
|
succeeded = metrics.get("pods_succeeded")
|
||||||
status_terms = ("running", "pending", "failed", "succeeded", "completed")
|
status_terms = ("running", "pending", "failed", "succeeded", "completed")
|
||||||
|
if ("most pods" in q or ("most" in q and "pod" in q and "node" in q)) and not nodes_in_query:
|
||||||
|
return _format_confidence(
|
||||||
|
"I don't have per-node pod counts in the snapshot.",
|
||||||
|
"medium",
|
||||||
|
)
|
||||||
if "total" in q or "sum" in q:
|
if "total" in q or "sum" in q:
|
||||||
values = [v for v in (running, pending, failed, succeeded) if isinstance(v, (int, float))]
|
values = [v for v in (running, pending, failed, succeeded) if isinstance(v, (int, float))]
|
||||||
if values:
|
if values:
|
||||||
@ -1363,13 +1372,13 @@ def snapshot_metric_answer(
|
|||||||
return _format_confidence(f"Pods not running: {sum(parts):.0f}.", "high")
|
return _format_confidence(f"Pods not running: {sum(parts):.0f}.", "high")
|
||||||
if sum(1 for term in status_terms if term in q) > 1:
|
if sum(1 for term in status_terms if term in q) > 1:
|
||||||
parts = []
|
parts = []
|
||||||
if running is not None:
|
if "running" in q and running is not None:
|
||||||
parts.append(f"running {running:.0f}")
|
parts.append(f"running {running:.0f}")
|
||||||
if pending is not None:
|
if "pending" in q and pending is not None:
|
||||||
parts.append(f"pending {pending:.0f}")
|
parts.append(f"pending {pending:.0f}")
|
||||||
if failed is not None:
|
if "failed" in q and failed is not None:
|
||||||
parts.append(f"failed {failed:.0f}")
|
parts.append(f"failed {failed:.0f}")
|
||||||
if succeeded is not None:
|
if ("succeeded" in q or "completed" in q) and succeeded is not None:
|
||||||
parts.append(f"succeeded {succeeded:.0f}")
|
parts.append(f"succeeded {succeeded:.0f}")
|
||||||
if parts:
|
if parts:
|
||||||
return _format_confidence(f"Pods: {', '.join(parts)}.", "high")
|
return _format_confidence(f"Pods: {', '.join(parts)}.", "high")
|
||||||
@ -1461,7 +1470,12 @@ def structured_answer(
|
|||||||
if hw_line:
|
if hw_line:
|
||||||
return _format_confidence(hw_line, "high")
|
return _format_confidence(hw_line, "high")
|
||||||
|
|
||||||
if entity == "node" and op == "status" and metric is None:
|
if (
|
||||||
|
entity == "node"
|
||||||
|
and op == "status"
|
||||||
|
and metric is None
|
||||||
|
and not (include_hw or exclude_hw or nodes_in_query or only_workers or role_filters)
|
||||||
|
):
|
||||||
summary = _nodes_summary_line(inventory, snapshot)
|
summary = _nodes_summary_line(inventory, snapshot)
|
||||||
if summary:
|
if summary:
|
||||||
return _format_confidence(summary, "high")
|
return _format_confidence(summary, "high")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user