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,14 +583,20 @@ 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: for line in summary_lines:
if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line: if line.startswith("node_namespaces_top:") and f"{hotspot_node} " in line:
namespace_line = line namespace_line = line
@ -600,7 +606,7 @@ class AnswerEngine:
if line.startswith("node_pods_top:") and 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 fact in metric_facts: for fact in metric_facts:
if fact.startswith("node_namespaces_top:"): if fact.startswith("node_namespaces_top:"):
namespace_line = fact namespace_line = fact
@ -610,10 +616,13 @@ class AnswerEngine:
if fact.startswith("node_pods_top:"): if fact.startswith("node_pods_top:"):
namespace_line = fact namespace_line = fact
break break
if namespace_line: if hotspot_line:
reply = f"Current hotspots: {hotspot_line}. {namespace_line}."
else:
reply = f"Current hotspots: {hotspot_line}." reply = f"Current hotspots: {hotspot_line}."
elif hotspot_node:
reply = f"Hotspot node: {hotspot_node}."
if namespace_line and reply:
reply = f"{reply} {namespace_line}."
if reply:
hotspot_override = True 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: