Skip to content

[WIP]--story=134475022 add project/env#561

Open
silenceper wants to merge 3 commits into
TencentBlueKing:masterfrom
silenceper:f-add-project-env
Open

[WIP]--story=134475022 add project/env#561
silenceper wants to merge 3 commits into
TencentBlueKing:masterfrom
silenceper:f-add-project-env

Conversation

@silenceper

@silenceper silenceper commented May 28, 2026

Copy link
Copy Markdown
Collaborator

分项目和环境带来的好处:

1、同个业务不同服务可以根据项目进行分配、同个项目也可以根据环境进行分类。环境概念已基本成为配置中心共识概念;
2、后续 模板可以作为穿透不同环境的配置

界面参考

image

问题:无法直接移除业务,因为进程和配置管理还是有这个能力的

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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`,密钥授权范围跟随项目 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 将 credential_scopes 纳入项目作用域

这里把 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_scopescredentials 一起加 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`,事件订阅按环境隔离 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 不要把 events 全部收紧为 EnvScope

events 当前不只承载发布/客户端这类环境级事件,还承载 ApplicationCredentialEvent 等项目级资源变更(pkg/dal/table/event.goEventResource 枚举);按这里的 EnvScope 方案最终给所有事件强制 environment_id 会让 app/credential 变更事件要么无法写入,要么被错误绑定到某个环境,进而导致缓存刷新和凭证事件消费丢失或串环境。这里应拆分为 MixedScope/nullable env,或按 resource 类型定义不同 scope。

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +400 to +401
AND (project_id = ? OR project_id IS NULL)
AND (environment_id = ? OR environment_id IS NULL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 限制 NULL 兼容只用于默认作用域

按这里的过渡查询条件,新建的非默认 project/env 读取 EnvScope 表时也会命中所有尚未回填的历史 NULL 行;在回填完成前只要用户创建非默认环境并列配置/发布,就会把默认环境的存量配置暴露到该环境,违背前文“旧数据只解析到 default project/default environment”的隔离边界。建议把 IS NULL 兼容条件仅用于解析到默认 project/env 的旧路径,或在新作用域查询中完全禁止匹配 NULL

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +273 to +278
1. 先创建 projects/environments 表和默认 project/env
2. 再给各业务数据表新增 project_id/environment_id 可空字段
3. 按表、按主键范围小批量回填,不使用单个长事务覆盖全表
4. 回填 SQL 幂等,可重复执行;失败后重跑不产生重复默认项目或默认环境
5. 数据量较大时记录迁移进度,允许暂停、恢复、重跑
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 将 id_generators 初始化加入迁移步骤

按现有 data-service 迁移习惯,新建业务表不会依赖自增主键,而是同时向 id_generators 写入对应资源(例如新增 processesconfig_instances 的迁移都会这么做);这里的 projects/environments 后续创建默认 scope 和用户新建项目/环境也会需要分配 ID。若迁移步骤只要求建表和默认数据补齐,遗漏 id_generators 资源初始化/回滚,服务侧调用 ID 生成器时会因找不到 projects/environments 资源而无法创建项目或环境,请把这一步明确纳入 migrate up/down

Useful? React with 👍 / 👎.

@tencentblueking-adm

tencentblueking-adm commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

2 participants