Skip to content

Fix/pr 420 storage governance - #498

Open
LeiXZ wants to merge 5 commits into
raids-lab:mainfrom
LeiXZ:fix/pr-420-storage-governance
Open

Fix/pr 420 storage governance#498
LeiXZ wants to merge 5 commits into
raids-lab:mainfrom
LeiXZ:fix/pr-420-storage-governance

Conversation

@LeiXZ

@LeiXZ LeiXZ commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
image

Copilot AI lite review requested due to automatic review settings August 9, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 围绕“存储配额/治理(storage governance)”能力做了一次跨前后端与 Helm Chart 的系统性增强:后端新增 CephFS quota-agent/配额读写与存储治理决策记录相关基础设施,前端新增管理员存储管理入口与相关 API/页面,并同步更新 Chart 版本与部署选项,便于在 CephFS 场景下安全启用配额能力。

Changes:

  • 新增 quota-agent(受限模式 storage-server)与配套 Helm Chart 模板/values,支持通过内部 token 读取/设置 CephFS xattr 配额。
  • 后端增加存储配额 Provider/能力探测、作业创建前的配额/冻结校验,以及存储治理决策记录/回放相关类型与查询能力。
  • 前端新增 Admin Storage 路由与存储相关 API,并改进 cronjobs 卡片展示(新增描述字段)与多语言文案。

综合评估 / 阻断项(需修改后再合入):

  • 前端:管理员文件树的 currentPath 拼接 admin- 前缀会影响实际 API 路径请求,存在高概率功能性错误;新增的 cronjob 描述 key 在 ko/ja 未补齐会直接在界面显示 key。
  • 后端:默认配置中硬编码了内网 IP;新增对外返回的错误信息包含中文文案;新增 StorageDecisionConfig handler 但未注册路由导致接口不可达。

Reviewed changes

Copilot reviewed 95 out of 99 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
frontend/src/utils/formatter.ts 调整字节格式化对非正数/非有限值的处理逻辑。
frontend/src/utils/format.ts 新增另一份 formatBytes 实现(当前未见引用)。
frontend/src/utils/file-size.ts 文件大小格式化对非有限值/非正数做统一兜底。
frontend/src/services/client.ts apiPost 支持透传 ky Options(用于超时等配置)。
frontend/src/services/api/vcjob.ts 新增管理员执行巡检任务的 API 方法。
frontend/src/services/api/storage.ts 新增管理员侧存储能力/用量刷新/配额设置 API。
frontend/src/services/api/file.ts 新增目录大小、我的配额、存储能力等 API 定义。
frontend/src/routeTree.gen.ts 路由树生成文件:加入 /admin/storage 路由。
frontend/src/routes/admin/storage/route.tsx 新增 Admin Storage 路由入口。
frontend/src/routes/admin/storage/-components/storage-governance-panel.tsx 新增存储配额审计记录面板(操作日志展示)。
frontend/src/routes/admin/route.tsx Admin 侧边栏按存储能力探测结果动态展示“存储管理”。
frontend/src/routes/admin/more/index.tsx 重构部分 effect/错误处理与 pending 状态透传。
frontend/src/routes/admin/more/-components/llm-settings.tsx 文案微调与格式化小改动。
frontend/src/routes/admin/cronjobs/index.tsx cronjob 配置支持描述字段并按实际可用 job 决定 Tab 展示。
frontend/src/routes/admin/cronjobs/-components/cronjob-card.tsx 支持 patrol job 立即执行;渲染 jobDescription。
frontend/src/index.css 增加 collapsible 动画 keyframes 与变量。
frontend/src/i18n/locales/ko/translation.json 新增 storage governance/management 等文案。
frontend/src/i18n/locales/ja/translation.json 新增 storage governance/management 等文案。
frontend/src/i18n/locales/enUS/translation.json 新增 cronPolicy 描述、storage governance/management、存储决策配置等文案。
frontend/src/components/ui/collapsible.tsx CollapsibleContent 增加动画 className 合并支持。
frontend/src/components/file/lazy-file-tree.tsx 文件树支持管理员模式与 admin files API;根节点路径/id 处理调整。
frontend/src/components/file/file-select-dialog.tsx FileSelectDialog 透传 isadmin 以支持管理员文件选择。
docs/zh-CN/cephfs-quota-agent.md 新增 quota-agent 使用与部署说明文档。
charts/crater/values.yaml 新增 quotaAgent 配置段;新增 backendConfig.storage.quota 参数。
charts/crater/templates/quota-agent/service.yaml 新增 quota-agent Service 模板。
charts/crater/templates/quota-agent/secret.yaml 新增 quota-agent 内部 token Secret 模板。
charts/crater/templates/quota-agent/deployment.yaml 新增 quota-agent Deployment 模板(挂载专用 PVC)。
charts/crater/templates/_helpers.tpl quotaAgent.enabled 时自动注入 backend/storage-server quota 配置。
charts/crater/README.md 同步 Chart 参数文档与版本 badge。
charts/crater/Chart.yaml Chart version/appVersion 升级到 1.2.0。
backend/pkg/storagequota/client.go 新增 storage quota server 客户端、token 派生与 provider 归一化。
backend/pkg/storagequota/client_test.go 覆盖 token 校验、GetUsage/SetQuota、provider 归一化测试。
backend/pkg/storagegovernance/types.go 新增存储治理决策快照/约束配置/回放结构体。
backend/pkg/storagegovernance/replay.go 新增已存决策的回放与统计汇总逻辑。
backend/pkg/storagegovernance/query.go 新增决策记录分页/详情查询与 JSON 解码投影。
backend/pkg/storagegovernance/policy_test.go 新增安全约束策略的单元测试用例。
backend/pkg/monitor/interface.go PrometheusInterface 扩展通用 PromQL instant query 能力。
backend/pkg/monitor/helper.go 实现 QueryInstant / QueryInstantLabels。
backend/pkg/llm/skills/storage-governance-agent/SKILL.md 新增存储治理 agent skill 文本。
backend/pkg/llm/skills/README.md 新增 skills 目录说明(当前包含本地绝对路径)。
backend/pkg/llm/skill.go 新增 skill 加载逻辑(embed + env 覆盖)。
backend/pkg/llm/provider.go 新增/调整 LLM provider 调用与运行时配置加载逻辑。
backend/pkg/llm/direct_decision_test.go 新增 direct decision 一致性校验测试。
backend/pkg/cronjob/manger.go CronJobManager 注入 kubeConfig,并接入 storagegovernance engine。
backend/pkg/cronjob/manger_test.go 适配 NewCronJobManager 新签名的测试更新。
backend/pkg/constants/const_op.go 新增操作类型 OpTypeSetStorageQuota。
backend/pkg/config/storage_quota_test.go 新增 storage.quota provider 校验与默认值测试。
backend/pkg/config/config.go 新增 storage.quota 配置结构、校验、默认派生与打印输出。
backend/pkg/ceph/toolbox_test.go 新增 toolbox 与 xattr 相关单测。
backend/pkg/ceph/quota_provider_test.go 新增配额启用/路径转换/配额值校验单测。
backend/pkg/ceph/ceph.go 新增 CephFS 用量与配额读写、provider 自动回退逻辑。
backend/internal/util/quota.go 新增作业创建前的存储配额/冻结拦截逻辑。
backend/internal/storage/router.go storage-server 注册 quota routes。
backend/internal/storage/quota.go 新增 internal/storage xattr 读写 API(internal token 保护)。
backend/internal/storage/quota_xattr_unsupported.go 非 linux 下的 xattr 能力占位实现。
backend/internal/storage/quota_xattr_linux.go linux 下的 xattr 能力探测/读写实现。
backend/internal/storage/quota_test.go 新增 storage 目录解析与 root 用量路径测试。
backend/internal/service/config_service.go 新增存储决策模型配置读写/校验/重置与默认值。
backend/internal/handler/vcjob/webide.go 创建 WebIDE 作业前增加存储配额检查。
backend/internal/handler/vcjob/tensorflow.go 创建 Tensorflow 作业前增加存储配额检查。
backend/internal/handler/vcjob/pytorch.go 创建 Pytorch 作业前增加存储配额检查。
backend/internal/handler/vcjob/jupyter.go 创建 Jupyter 作业前增加存储配额检查。
backend/internal/handler/vcjob/custom.go 创建 Training(Custom) 作业前增加存储配额检查。
backend/internal/handler/system_config.go 新增 StorageDecisionConfig DTO/handler(但 RegisterAdmin 未注册)。
backend/internal/handler/spjob/spjob.go 创建 SparseJob 前增加存储配额检查。
backend/internal/handler/operations/operations.go 新增 /cronjob/execute 管理接口注册。
backend/internal/handler/operations/cronjob.go 新增立即执行 patrol job 的 handler。
backend/internal/handler/aijob/new.go AIJob 创建前增加存储配额检查。
backend/hack/run-cephfs-quota-agent-dev.sh 新增本地二进制跑 quota-agent 的开发脚本。
backend/hack/bootstrap-cephfs-quota-agent.sh 新增初始化 CephClient 与静态 PV/PVC 的脚本。
backend/go.sum 引入 go-openai 依赖校验和。
backend/go.mod 增加 github.com/sashabaranov/go-openai 依赖。
backend/etc/example-config.yaml example-config 增加 storage.quota 配置示例。
backend/dao/query/users.gen.go users 查询字段生成更新:增加 space_quota/jobs_frozen 等字段。
backend/dao/model/user.go User 模型增加存储配额/冻结/缩容阶段字段。
backend/dao/model/user_space_size.go 新增 UserSpaceSize/TenantUsageHistory 模型。
backend/dao/model/system_config.go SystemConfig 文档化与新增 storage decision keys。
backend/dao/model/storage_decision.go 新增 StorageDecisionRecord 模型。
backend/cmd/storage-server/main.go storage-server 支持 full/quota-agent 模式启动与路由分流。
backend/cmd/gorm-gen/models/migrate.go 新增存储治理/用量相关迁移与表初始化。
backend/cmd/crater/helper/config.go NewCronJobManager 注入 kubeConfig。
backend/.vscode/launch.json 增加本地调试环境变量(GOCACHE/GOTOOLCHAIN)。
.vscode/launch.json 增加本地调试环境变量(GOCACHE/GOTOOLCHAIN)。
.gitignore 增补本地缓存/实验产物忽略项。
.gitattributes 新增统一 eol=lf 与二进制文件属性配置。
Files not reviewed (2)
  • backend/dao/query/users.gen.go: Generated file
  • backend/docs/docs.go: Generated file
Suppressed comments (2)

backend/internal/util/quota.go:72

  • 【核心规范】该错误会直接返回给 API 调用方,但当前为中文文案,违反“对外错误信息使用清晰英文”的约定,也会导致前端 i18n 难以处理。建议改为英文并让前端根据错误码/场景做本地化展示。
    backend/internal/handler/system_config.go:78
  • 【核心规范】本文件新增了 StorageDecisionConfig 的 handler(Get/Update/Reset),但在 RegisterAdmin 中未注册对应路由,导致这些接口不可达/死代码。建议在这里补充 g.GET/g.PUT/g.DELETE 路由,并同步补全 swagger @Router 标注。
func (mgr *SystemConfigMgr) RegisterAdmin(g *gin.RouterGroup) {
	// 路由组: /v1/admin/system-config
	g.GET("/llm", mgr.GetLLMConfig)
	g.PUT("/llm", mgr.UpdateLLMConfig)
	// 重置平台通用 LLM 配置
	g.DELETE("/llm", mgr.ResetLLMConfig)

	g.GET("/gpu-analysis", mgr.GetGpuAnalysisStatus)
	g.PUT("/gpu-analysis", mgr.SetGpuAnalysisStatus)
	g.GET("/prequeue", mgr.GetPrequeueConfig)
	g.PUT("/prequeue", mgr.UpdatePrequeueConfig)
	g.GET("/model-download-limit", mgr.GetAdminModelDownloadLimitConfig)
	g.PUT("/model-download-limit", mgr.UpdateModelDownloadLimitConfig)
	g.GET("/pod-bandwidth", mgr.GetAdminPodBandwidthConfig)
	g.PUT("/pod-bandwidth", mgr.UpdateAdminPodBandwidthConfig)

	g.GET("/billing", mgr.GetBillingStatus)
	g.PUT("/billing", mgr.SetBillingStatus)
	g.POST("/billing/reconcile", mgr.TriggerBillingBaseLoop)
	g.POST("/billing/reset-all", mgr.ResetAllBillingBalances)
	g.POST("/billing/extra-balance-all", mgr.GrantAllUsersExtraBalance)
}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread frontend/src/routes/admin/cronjobs/-components/cronjob-card.tsx Outdated
Comment thread frontend/src/routes/admin/cronjobs/-components/cronjob-card.tsx Outdated
Comment thread frontend/src/services/api/file.ts Outdated
Comment on lines 121 to +129
{data?.map((item, index) => (
<TreeItem
level={0}
key={index}
currentPath={item.name}
currentPath={isadmin ? `admin-${item.name}` : item.name}
data={item}
ref={ref}
isrw={isrw}
isadmin={isadmin}
Comment thread frontend/src/utils/format.ts Outdated
Comment on lines +1266 to +1272
"storageGovernance.action.expand": "할당량 확장",
"storageGovernance.action.expandAndFreeze": "확장 후 동결",
"storageGovernance.action.expandFailed": "확장 실패",
"storageGovernance.action.freeze": "새 작업 동결",
"storageGovernance.action.freezeFailed": "동결 실패",
"storageGovernance.action.manualExpand": "수동 확장",
"storageGovernance.action.manualExpandAndFreeze": "수동 확장 후 동결",
Comment thread frontend/src/i18n/locales/ja/translation.json
Comment on lines 29 to +32
// 定义掩码常量
const MaskedAPIKeyPlaceholder = "********************************************"
const DefaultStorageDirectModelBaseURL = "http://192.168.5.68:30186/v1"

Comment thread backend/internal/util/quota.go
Signed-off-by: LeiXZ <2459605339@qq.com>
@LeiXZ
LeiXZ requested a lite review from Copilot August 9, 2026 14:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: LeiXZ <2459605339@qq.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@AkashiSensei

Copy link
Copy Markdown
Contributor

这个看起来比较复杂,麻烦师兄完善下 pr 描述,尤其是人工做了哪些检查和测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants