opsx
cf54be3f7d
fix(logs): 「所有人」策略保存被拒 + 快捷 LogQL namespace 空且不认默认策略
...
=== 一、保存策略组报「用户ID无效或重复」===
validatePolicyGroup 里 `if id == 0 || seen[id]` 直接把「所有人」哨兵当非法。
修复:
- 新增常量 AnyoneUserID = 0(与 policyGroupAccess、前端 ANYONE 对齐)
- 0 跳过用户存在性校验,但必须独占:与具体用户混选时报
「「所有人」不能与具体用户同时选择」
- 重复检查独立出来,报错带具体 ID
=== 二、快捷 LogQL 的 namespace 下拉总是空的 ===
两个叠加原因:
1. 用的是原生 <datalist>,只在输入时才提示、样式弱,看着像"下拉是空的"
2. 候选只来自 Loki 实际值 —— 而默认策略配的 default 命名空间里没有业务 Pod,
Loki 里根本没有这个 label 值,所以永远不出现;前端也不会拿策略值当默认选中
修复:
后端新增 GET /api/v1/logs/my-scope?sourceId= → {labels, unrestricted}
(services.UserAccessLabels 暴露当前用户在数据源上的授权 labels;
admin 返回 unrestricted=true 但仍带上策略 labels 供 UI 做默认值)
前端:
- logsApi.myScope()
- QuickQueryTemplates 用策略里的 namespace 作为初始选中值
- namespaceOptions = 策略值 ∪ Loki 实际值(去重,策略值优先)
- namespace/app/pod 三个 <datalist> 全部换成 SearchableValueSelect
(点击即展开、可搜索,placeholder 显示「请选择(共 N 个)」)
验证:
PUT /logs/policy-groups/1 {userIds:[0]} → 200 ✅
POST userIds:[0,2](混选) → 400「「所有人」不能与具体用户同时选择」✅
GET /logs/my-scope?sourceId=1 → {"labels":{"namespace":"default"},"unrestricted":true} ✅
bundle: my-scope 1 处、datalist 残留 0 处 ✅
镜像:lghost/lokistack:latest + v0.1 = sha256:ad659f564665
2026-10-27 02:59:33 +00:00
logan
2d73661dd1
feat: complete Loki query, insights, settings and deployment workflows
...
Add the Loki query UI, access policies, ingress insights, alert and registry settings, and their backend APIs. Include the related Kubernetes deployment and collector updates required by the integrated application.
Validated with go test ./..., npm run build, and npm run lint.
2026-10-25 21:28:32 +08:00