[WIP]--story=134475022 add project/env#561
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aaad3413a6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| | `template_sets` | ProjectScope | 新增 `project_id` | | ||
| | `template_revisions` | ProjectScope | 新增 `project_id` | | ||
| | `template_variables` | ProjectScope | 新增 `project_id` | | ||
| | `credentials` | ProjectScope | 新增 `project_id`,密钥授权范围跟随项目 | |
There was a problem hiding this comment.
这里把 credentials 设为 ProjectScope,但遗漏了 credential_scopes;现有 credential_scopes 表保存的是按 app 名匹配的授权规则(见 cmd/data-service/db-migration/migrations/sql/20230418102723_add_credential_up.sql 和删除 app 时按 scope.Spec.CredentialScope.Split() 的 appName 清理规则),一旦允许不同项目下存在同名 app,仍按 biz_id + app_name 解释这些 scope 会把凭证授权串到其它项目。请把 credential_scopes 与 credentials 一起加 project_id 并在匹配、删除和事件刷新路径中按项目过滤。
Useful? React with 👍 / 👎.
| | `current_released_instances` | EnvScope | 新增 `project_id`、`environment_id` | | ||
| | `clients` / `client_events` | EnvScope | 新增 `project_id`、`environment_id` | | ||
| | `client_querys` | EnvScope | 新增 `project_id`、`environment_id` | | ||
| | `events` | EnvScope | 新增 `project_id`、`environment_id`,事件订阅按环境隔离 | |
There was a problem hiding this comment.
events 当前不只承载发布/客户端这类环境级事件,还承载 Application 和 CredentialEvent 等项目级资源变更(pkg/dal/table/event.go 的 EventResource 枚举);按这里的 EnvScope 方案最终给所有事件强制 environment_id 会让 app/credential 变更事件要么无法写入,要么被错误绑定到某个环境,进而导致缓存刷新和凭证事件消费丢失或串环境。这里应拆分为 MixedScope/nullable env,或按 resource 类型定义不同 scope。
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01cbf77971
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| AND (project_id = ? OR project_id IS NULL) | ||
| AND (environment_id = ? OR environment_id IS NULL) |
There was a problem hiding this comment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fcd3411cb8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 1. 先创建 projects/environments 表和默认 project/env | ||
| 2. 再给各业务数据表新增 project_id/environment_id 可空字段 | ||
| 3. 按表、按主键范围小批量回填,不使用单个长事务覆盖全表 | ||
| 4. 回填 SQL 幂等,可重复执行;失败后重跑不产生重复默认项目或默认环境 | ||
| 5. 数据量较大时记录迁移进度,允许暂停、恢复、重跑 | ||
| ``` |
There was a problem hiding this comment.
按现有 data-service 迁移习惯,新建业务表不会依赖自增主键,而是同时向 id_generators 写入对应资源(例如新增 processes、config_instances 的迁移都会这么做);这里的 projects/environments 后续创建默认 scope 和用户新建项目/环境也会需要分配 ID。若迁移步骤只要求建表和默认数据补齐,遗漏 id_generators 资源初始化/回滚,服务侧调用 ID 生成器时会因找不到 projects/environments 资源而无法创建项目或环境,请把这一步明确纳入 migrate up/down。
Useful? React with 👍 / 👎.
分项目和环境带来的好处:
1、同个业务不同服务可以根据项目进行分配、同个项目也可以根据环境进行分类。环境概念已基本成为配置中心共识概念;
2、后续 模板可以作为穿透不同环境的配置
界面参考
问题:无法直接移除业务,因为进程和配置管理还是有这个能力的