fix: resolve deployment API errors and enable E2E deployment flow

Backend fixes:
- instance_dto: add Version field with Normalize() to support both 'version'
  and 'tag' field names from frontend
- instance_handler: add version empty validation before creating instance
- authz.go: fix unused variable compilation error
- registry_repository: fix GetByID/GetByName to use correct DB schema
  (add workspace_id, owner_id, is_shared fields); decrypt password
  gracefully when encryption key mismatches instead of returning error

Frontend:
- charts/page: add Template and Storage dropdown selectors to Deploy Modal

Testing:
- add e2e_test.py: 5-step Playwright E2E test (admin login → create
  workspace → create user → user login → deploy chart)
- add tasks/lesson.md: document 4 bug root causes and fixes
- add tasks/todo.md: track implementation progress
- add PLAN_E2E_DEPLOYMENT.md: comprehensive implementation plan

Verification: confirmed deployment creates instance with status=deployed,
chart downloads from Harbor OCI to /tmp/charts/, Helm release deploys to K8s
This commit is contained in:
Ivan087
2026-04-16 18:39:23 +08:00
parent ef961d4ade
commit 985369d40f
9 changed files with 813 additions and 17 deletions

45
tasks/todo.md Normal file
View File

@ -0,0 +1,45 @@
# 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
- 🔄 Phase 5: Values Template 版本管理 (P2)
- 🔄 Phase 6: Storage 分层配置 (P2)
## 当前里程碑
核心部署流程已打通2026-04-16
- Admin 创建 workspace → 创建 user ✓
- User 登录 → 浏览 Charts → 部署成功 → status=deployed ✓
- Chart 从 Harbor OCI 下载到 /tmp/charts/ ✓
- Helm release 部署到 K8s 集群 ✓
## 待办事项
### Phase 5: Values Template 版本管理
- [ ] 每次更新创建新版本
- [ ] 查看版本历史
- [ ] 回滚到历史版本
- 关键文件: `backend/internal/domain/service/values_template_service.go`, `frontend/src/app/templates/page.tsx`
### Phase 6: Storage 分层配置
- [ ] Cluster-level 默认存储
- [ ] Workspace-level 存储覆盖
- [ ] User Override 最高优先级
- 关键文件: `backend/internal/domain/service/storage_service.go`, `frontend/src/app/storage/page.tsx`
## 完成清单
- [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] Tests: e2e_test.py - 完整 5 步 E2E 测试
- [x] Docs: tasks/lessons.md - 记录 4 个 Bug 的根因和修复