Skip to content

feat(metadata): 支持将 Storage 和 Feature Flag 配置同步到 Consul 与 Redis - #11685

Closed
Zhaoyikaiii wants to merge 6 commits into
TencentBlueKing:masterfrom
Zhaoyikaiii:feat/featureflag_and_storage
Closed

feat(metadata): 支持将 Storage 和 Feature Flag 配置同步到 Consul 与 Redis#11685
Zhaoyikaiii wants to merge 6 commits into
TencentBlueKing:masterfrom
Zhaoyikaiii:feat/featureflag_and_storage

Conversation

@Zhaoyikaiii

@Zhaoyikaiii Zhaoyikaiii commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

变更内容

  • 基于最新的 master 重建 Storage 和 Feature Flag 配置相关改动
  • 新增 FeatureFlag 模型,并将迁移重建为 0274_feature_flag
  • 新增 Consul、Redis 配置读写能力,以及带鉴权的配置检查接口
  • 将 Storage 和 Feature Flag 数据同步到 Redis,并通过 Pub/Sub 通知 unify-query
  • 全量同步时清理 Redis 中已经失效的 Storage 配置键
  • 配置检查响应中对 Storage 密码进行脱敏,并移除原始 Redis 调试内容
  • 补充 Consul、Redis、失效键清理和 Pub/Sub 相关测试

背景与原因

feat/featureflag_and_storage 分支基于较旧的迁移图,同时混入了与本功能无关的测试环境兼容性改动。此外,原实现只写入 Redis,没有向 unify-query 订阅的频道发布通知,因此运行时配置更新后无法触发重新加载。

本 PR 仅保留 Storage 和 Feature Flag 相关范围,并基于最新主分支重新构建;同时统一 Redis 通知协议,使其与 unify-query 对应的 Provider 改动保持一致。

影响范围

  • 保留现有 Consul 配置能力
  • metadata 模块可以通过 Redis 写入和检查 Storage、Feature Flag 配置
  • Redis 中的配置更新或删除后,unify-query 可以收到运行时重新加载通知
  • Feature Flag 新迁移已衔接当前 metadata 迁移图

验证情况

  • 所有改动的 Python 文件均已通过 ruff check
  • 改动涉及的运行时模块已通过 Python 字节码编译检查
  • 已通过 git diff --check
  • 静态迁移图检查确认 0274_feature_flag 是 metadata 唯一的叶子迁移
  • 已尝试运行聚焦测试;当前检出环境无法初始化完整 Django 应用,原因是引用的 TencentBlueKing/bk-monitor-base 子模块不可用,且本地没有 MySQL 测试服务。相关 metadata 测试需要由 CI 在仓库支持的环境中执行。

@github-actions

Copy link
Copy Markdown

请在 PR 中添加项目标签,例如:project/monitorproject/apmproject/logproject/publicproject/aiops

@github-actions

Copy link
Copy Markdown

请在 PR 中添加类型标签,例如:fixfeatdocsstylerefactortestchoremerge, perf

@Zhaoyikaiii Zhaoyikaiii added feat A new feature. Correlates with MINOR in SemVer project/monitor project monitor labels Jul 28, 2026 — with ChatGPT Codex Connector
@Zhaoyikaiii Zhaoyikaiii changed the title feat(metadata): sync storage and feature flags to consul and redis feat(metadata): 支持将 Storage 和 Feature Flag 配置同步到 Consul 与 Redis Jul 28, 2026
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 8880e22354

ℹ️ 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 thread bkmonitor/metadata/models/storage.py
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/views.py
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/storage.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: ffd763d7a0

ℹ️ 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 thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/task/config_refresh.py
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py
Comment thread bkmonitor/metadata/models/storage.py
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: b5250944ba

ℹ️ 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 thread bkmonitor/metadata/models/feature_flag.py
Comment thread bkmonitor/metadata/resources/resources.py
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: d3b89eadcd

ℹ️ 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 thread bkmonitor/metadata/models/storage.py
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: 69ed5dcf5f

ℹ️ 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 thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
Comment thread bkmonitor/metadata/models/feature_flag.py Outdated
@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 17ebb881f3

ℹ️ 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".

@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

该组合 PR 已按职责拆分为两个独立 Draft PR:\n\n- Storage 生产链路:#11710\n- Feature Flag 生产链路:#11711\n\n原有 Review 结论继续作为拆分后的回归基线;后续分别在两个 PR 中完成 CI、人工 Review 与跨仓库联调。

@Zhaoyikaiii

Copy link
Copy Markdown
Collaborator Author

已由 #11710#11711 替代,关闭组合 Draft PR,保留历史供回溯。

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

Labels

feat A new feature. Correlates with MINOR in SemVer project/monitor project monitor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant