comms: answer node name queries
This commit is contained in:
parent
36f7de76e9
commit
5aac018a7b
@ -16,7 +16,7 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: atlasbot
|
app: atlasbot
|
||||||
annotations:
|
annotations:
|
||||||
checksum/atlasbot-configmap: manual-atlasbot-7
|
checksum/atlasbot-configmap: manual-atlasbot-8
|
||||||
vault.hashicorp.com/agent-inject: "true"
|
vault.hashicorp.com/agent-inject: "true"
|
||||||
vault.hashicorp.com/role: "comms"
|
vault.hashicorp.com/role: "comms"
|
||||||
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"
|
vault.hashicorp.com/agent-inject-secret-turn-secret: "kv/data/atlas/comms/turn-shared-secret"
|
||||||
|
|||||||
@ -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: {ready} Ready, {not_ready} NotReady."
|
||||||
return f"{cluster_name} cluster has {total} nodes, all Ready."
|
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:
|
def _strip_code_fence(text: str) -> str:
|
||||||
cleaned = (text or "").strip()
|
cleaned = (text or "").strip()
|
||||||
match = CODE_FENCE_RE.match(cleaned)
|
match = CODE_FENCE_RE.match(cleaned)
|
||||||
@ -633,6 +654,14 @@ def sync_loop(token: str, room_id: str):
|
|||||||
continue
|
continue
|
||||||
send_msg(token, rid, summary)
|
send_msg(token, rid, summary)
|
||||||
continue
|
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 couldn’t 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.
|
# Only do live cluster/metrics introspection in DMs.
|
||||||
allow_tools = is_dm
|
allow_tools = is_dm
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user