atlasbot: keep hotspot namespace replies

This commit is contained in:
Brad Stein 2026-02-02 13:36:57 -03:00
parent 23b31a2a38
commit a74e5e9fad

View File

@ -583,38 +583,47 @@ class AnswerEngine:
if note: if note:
reply = f"{reply}\n\n{note}" reply = f"{reply}\n\n{note}"
if hotspot_request and hotspot_line: if hotspot_request:
namespace_line = None namespace_line = None
if "namespace" in lowered_q: hotspot_node = None
hotspot_node = None if hotspot_line:
match = re.search(r"(titan-[a-z0-9]+)", hotspot_line) match = re.search(r"(titan-[a-z0-9]+)", hotspot_line)
if match: if match:
hotspot_node = match.group(1) hotspot_node = match.group(1)
if hotspot_node: if not hotspot_node:
for fact in metric_facts:
match = re.search(r"hottest_\w+_node: (?P<node>[^\s\[]+)", fact)
if match:
hotspot_node = match.group("node")
break
if "namespace" in lowered_q and hotspot_node:
for line in summary_lines:
if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line:
namespace_line = line
break
if not namespace_line:
for line in summary_lines: for line in summary_lines:
if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line: if line.startswith("node_pods_top:") and hotspot_node in line:
namespace_line = line namespace_line = line
break break
if not namespace_line: if "namespace" in lowered_q and not namespace_line:
for line in summary_lines: for fact in metric_facts:
if line.startswith("node_pods_top:") and hotspot_node in line: if fact.startswith("node_namespaces_top:"):
namespace_line = line namespace_line = fact
break break
if not namespace_line: if not namespace_line:
for fact in metric_facts: for fact in metric_facts:
if fact.startswith("node_namespaces_top:"): if fact.startswith("node_pods_top:"):
namespace_line = fact namespace_line = fact
break break
if not namespace_line: if hotspot_line:
for fact in metric_facts:
if fact.startswith("node_pods_top:"):
namespace_line = fact
break
if namespace_line:
reply = f"Current hotspots: {hotspot_line}. {namespace_line}."
else:
reply = f"Current hotspots: {hotspot_line}." reply = f"Current hotspots: {hotspot_line}."
hotspot_override = True elif hotspot_node:
reply = f"Hotspot node: {hotspot_node}."
if namespace_line and reply:
reply = f"{reply} {namespace_line}."
if reply:
hotspot_override = True
if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts and not hotspot_override: if classify.get("question_type") in {"metric", "diagnostic"} and metric_facts and not hotspot_override:
reply = _metric_fact_guard(reply, metric_facts, keyword_tokens) reply = _metric_fact_guard(reply, metric_facts, keyword_tokens)