comms: answer node name queries

This commit is contained in:
Brad Stein 2026-01-26 01:35:47 -03:00
parent 36f7de76e9
commit 5aac018a7b
2 changed files with 30 additions and 1 deletions

View File

@ -16,7 +16,7 @@ spec:
labels:
app: atlasbot
annotations:
checksum/atlasbot-configmap: manual-atlasbot-7
checksum/atlasbot-configmap: manual-atlasbot-8
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "comms"
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"

View File

@ -466,6 +466,27 @@ def nodes_summary(cluster_name: str) -> str:
return f"{cluster_name} cluster has {total} nodes: {ready} Ready, {not_ready} NotReady."
return f"{cluster_name} cluster has {total} nodes, all Ready."
def nodes_names_summary(cluster_name: str) -> str:
try:
data = k8s_get("/api/v1/nodes?limit=500")
except Exception:
return ""
items = data.get("items") or []
if not isinstance(items, list) or not items:
return ""
names = []
for node in items:
name = (node.get("metadata") or {}).get("name") or ""
if name:
names.append(name)
names = sorted(set(names))
if not names:
return ""
if len(names) <= 30:
return f"{cluster_name} node names: {', '.join(names)}."
shown = ", ".join(names[:30])
return f"{cluster_name} node names: {shown}, … (+{len(names) - 30} more)."
def _strip_code_fence(text: str) -> str:
cleaned = (text or "").strip()
match = CODE_FENCE_RE.match(cleaned)
@ -633,6 +654,14 @@ def sync_loop(token: str, room_id: str):
continue
send_msg(token, rid, summary)
continue
if re.search(r"\bnode names?\b|\bnodes? named\b|\bnaming\b", lower_body):
if any(word in lower_body for word in ("cluster", "atlas", "titan")):
names_summary = nodes_names_summary("Atlas")
if not names_summary:
send_msg(token, rid, "I couldnt reach the cluster API to list node names. Try again in a moment.")
continue
send_msg(token, rid, names_summary)
continue
# Only do live cluster/metrics introspection in DMs.
allow_tools = is_dm