Files
ocdp-go/tasks/todo.md
Ivan087 47849042a7 feat: complete E2E deployment flow with storage layered config and values template versioning
- Instance deployment: charts browser, deploy modal, instances list
- Values Template version management (create/history/rollback)
- Storage layered config (cluster > workspace > shared priority)
- Cluster credential decryptIfNeeded for mixed encrypted/plaintext kubeconfig
- YAML syntax validation (client-side + server-side warning)
- Frontend: charts, instances, storage, templates, admin pages
- Backend: storage service, instance service, cluster service, helm client
- Multi-Tenant Kubeconfig.md: added by user
2026-04-30 16:31:00 +08:00

120 lines
6.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# OCDP E2E 部署流程 - 任务追踪
## 状态总览
- ✅ Phase 1: 诊断部署问题
- ✅ Phase 2: 完善 Admin 用户管理 UI
- ✅ Phase 3: 增强 Deploy ModalTemplate/Storage 选择器)
- ✅ Phase 4: E2E 端到端验证
- ✅ Bug Fix: frontend version → backend req.Tag 字段映射
- ✅ Bug Fix: registry 解密失败 graceful fallback
- ✅ Bug Fix: frontend registryId 字段缺失导致部署 API 失败
- ✅ Bug Fix: Artifact 类型过滤 (type==='chart') 不匹配问题
- ✅ Feature: 创建 Instances 列表页面查看部署状态
- ✅ Feature: Sidebar 添加 Deployments 导航项
- ✅ Bug Fix: values.yaml 未应用到 Helm releases (2026-04-22)
- ✅ Bug Fix: Cluster1 连接失败 — kubeconfig 明文绕过 AES-GCM 解密 (2026-04-22)
- ✅ Phase 5: Values Template 版本管理
- ✅ Phase 6: Storage 分层配置
- ✅ Testing Complete: Values Template E2E + Browser UI (2026-04-17)
## 当前里程碑
核心部署流程 + 配置管理完全打通2026-04-17
- Admin 创建 workspace → 创建 user ✓
- User 登录 → 浏览 Charts → 部署成功 → status=deployed ✓
- Chart 从 Harbor OCI 下载到 /tmp/charts/ ✓
- Helm release 部署到 K8s 集群 ✓
- **前端完整支持Charts 浏览器 + Deploy Modal + Instances 列表** ✓
- **Values Template 版本管理:创建/历史/回滚** ✓
- **Storage 分层配置cluster/workspace/shared 优先级解析** ✓
## 已完成清单
- [x] Backend: instance_dto.go - 添加 Version 字段Normalize() 兼容 version/tag
- [x] Backend: instance_handler.go - 添加 version 空值校验
- [x] Backend: authz.go - 修复 unused variable 编译错误
- [x] Backend: registry_repository.go - 修复 GetByID/GetByName schema 字段不匹配
- [x] Backend: registry_repository.go - 解密失败时返回空密码而非错误
- [x] Frontend: charts/page.tsx - 添加 Template 和 Storage 下拉选择器
- [x] Frontend: types.ts - 添加 registryId 字段到 CreateInstanceRequest
- [x] Frontend: charts/page.tsx - 修复 registryId 字段名registry_id → registryId
- [x] Frontend: instances/page.tsx - 新建 Instances 列表页面
- [x] Frontend: sidebar.tsx - 添加 Deployments 导航项
- [x] Bug Fix: values.yaml 未解析到 Values map (instance.go SetValuesYAML 添加 yaml.v3 parse)
- [x] Bug Fix: ListInstances API 响应缺少 Values 字段 (instance_handler.go 添加 Values 字段)
- [x] Tests: e2e_test.py - 完整 5 步 E2E 测试
- [x] Docs: tasks/lessons.md - 记录 Bug 的根因和修复
- [x] Phase 5: Values Template CRUD + 版本历史 + 回滚
- [x] Phase 6: Storage 分层配置 (cluster_id, ResolveStorageConfig, mergeStorageToValues, Layered Config UI)
## 待办事项
### Phase 5: Values Template 版本管理
- [x] 每次更新创建新版本
- [x] 查看版本历史
- [x] 回滚到历史版本
- 关键文件: `backend/internal/domain/service/values_template_service.go`, `frontend/src/app/templates/page.tsx`
### Phase 6: Storage 分层配置
- [x] Cluster-level 默认存储 (cluster_id 字段 + API 支持)
- [x] ResolveStorageConfig 优先级解析 (cluster > workspace > shared)
- [x] InstanceService 集成存储解析 (mergeStorageToValues)
- [x] Frontend Storage 页面增强 (Layered Config Tab, Cluster 选择器)
- [x] 前端 API 扩展 (storageApi.resolve)
- [x] 浏览器测试通过 (无 console errors)
- 关键文件: `backend/internal/domain/service/storage_service.go`, `backend/internal/domain/service/instance_service.go`, `frontend/src/app/storage/page.tsx`
## 浏览器测试结果 (2026-04-17)
### Phase 4 E2E 测试通过项目
1. ✅ 登录页面正常登录
2. ✅ Sidebar 导航显示 Deployments 项
3. ✅ Charts 页面加载 registries
4. ✅ 选择 registry 后显示 chart repos 列表
5. ✅ 点击 repo 后显示版本列表
6. ✅ Deploy Modal 打开,包含:
- Release Name 字段(自动填充)
- Cluster 选择器(显示 cluster1, cluster2
- Values Template 下拉(条件显示)
- Storage Backend 下拉(条件显示)
- Custom Values textarea
- Deploy/Cancel 按钮
7. ✅ 点击 Deploy 后请求发送到后端
8. ✅ Instances 页面正常显示:
- Cluster 选择器
- Deployment 列表
- Refresh 按钮
- New Deployment 按钮
### Phase 6 浏览器测试结果 (2026-04-17)
1. ✅ Storage 页面正常加载Add Storage 按钮可用
2. ✅ Monitoring 页面正常加载
3. ✅ Chart References 页面正常加载Add Chart Reference 按钮可用
4. ✅ Clusters 页面正常加载
5. ✅ 所有页面无 console errors
6. ✅ 截图已保存: storage_page.png, monitoring_page.png, chart_references_page.png
7. ✅ storage_backends/resolve API 返回 404 (预期行为,无默认存储配置)
### Bug Fix: values.yaml 未应用 (2026-04-22)
1. ✅ 登录 → 浏览 charts → 选择 charts/nginx
2. ✅ Deploy Modal: 填写 release name, 选择 cluster, 填写 `replicaCount: 9`
3. ✅ API 返回 `deployed` 状态
4.`ListInstances` API 返回 `values: {"replicaCount": 9}`
5.`helm get values <release>` 返回 `replicaCount: 9`
6.`install.Run()` 耗时 ~10-20s结果 `err=<nil>`
7. ✅ 测试脚本: `/tmp/test_values_final.py` (使用 charts/nginx chart)
### Bug Fix: YAML 解析失败静默忽略 (2026-04-22)
1. ✅ DB 确认 `nginx` 实例 `values=null`, `values_yaml='replicaCount=4'`(用户写错了语法)
2. ✅ Backend `SetValuesYAML()`: 解析失败时打印 WARNING 日志
3. ✅ Frontend: textarea onChange 客户端检测 `key=value` 模式,红色错误 + 禁用 Deploy 按钮
4. ✅ 测试脚本: `/tmp/test_values_browser.py`
### Bug Fix: Cluster1 连接失败 (2026-04-22)
1. ✅ 问题:前端 Deploy 后端报错 "no valid credentials found"
2. ✅ 根因cluster1 ca_data 存明文 kubeconfig但 GetByID 总是尝试 AES-GCM 解密 → 乱码
3. ✅ 修复cluster_repository.go 添加 decryptIfNeeded(),检测 apiVersion:/kind: 前缀跳过解密
4. ✅ 重建镜像 + 重启容器 + 挂载 kubeconfig 目录
5.`curl /clusters/{id}/health``{"healthy":true}`
6. ✅ E2E 浏览器测试deploy nginx → `status=deployed, values={"replicaCount": 9}`