atlasbot: avoid namespace-only workload matches

This commit is contained in:
Brad Stein 2026-01-27 15:45:18 -03:00
parent 3f159c6c83
commit 354275f3ad
2 changed files with 7 additions and 1 deletions

View File

@ -16,7 +16,7 @@ spec:
labels: labels:
app: atlasbot app: atlasbot
annotations: annotations:
checksum/atlasbot-configmap: manual-atlasbot-50 checksum/atlasbot-configmap: manual-atlasbot-51
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"

View File

@ -1071,11 +1071,17 @@ def workload_answer(prompt: str, workloads: list[dict[str, Any]]) -> str:
q = normalize_query(prompt) q = normalize_query(prompt)
if not any(word in q for word in ("where", "which", "node", "run", "running", "host", "located")): if not any(word in q for word in ("where", "which", "node", "run", "running", "host", "located")):
return "" return ""
target = _workload_query_target(prompt)
entry = _select_workload(prompt, workloads) entry = _select_workload(prompt, workloads)
if not entry: if not entry:
return "" return ""
workload = entry.get("workload") or "" workload = entry.get("workload") or ""
namespace = entry.get("namespace") or "" namespace = entry.get("namespace") or ""
if target:
workload_l = str(workload).lower()
namespace_l = str(namespace).lower()
if workload_l != target and namespace_l == target and "namespace" not in q and "workload" not in q:
return ""
nodes = entry.get("nodes") if isinstance(entry.get("nodes"), dict) else {} nodes = entry.get("nodes") if isinstance(entry.get("nodes"), dict) else {}
primary = entry.get("primary_node") or "" primary = entry.get("primary_node") or ""
if not workload or not nodes: if not workload or not nodes: