fix: generate cn monitor service like dn/log#601
Merged
loveRhythm1990 merged 1 commit intoJul 14, 2026
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
heni02
approved these changes
Jul 13, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #600
What this PR does / why we need it:
CNSet 开启
exportToPrometheus: true+promDiscoveryScheme: Service时,Prometheus(通过 ServiceMonitor / VMServiceScrape)无法发现 CN的 metrics target,而 DN/Log 可以正常被发现。
根因:CNSet 的
syncService(pkg/controllers/cnset/resource.go)只在已有的 SQL Service 上打了prometheus.io/scrape/prometheus.io/portannotation,但从未给任何 Service 加上metric端口。基于 Service 的 Prometheus 发现机制(如ServiceMonitor)根本不读
prometheus.io/*annotation——它是按 label selector 匹配 Service,再按端口名(metric)在spec.ports里查找。由于没有任何 Service 暴露
metric端口,CN 从未被发现,尽管 CN 进程本身已经在:7001正确暴露了 metrics。DNSet 和 LogSet 没有这个问题——它们已经会创建独立的
*-dn-metric/*-log-metricClusterIP Service,带metric:7001端口。本 PR 让 CNSet 对齐 DNSet/LogSet 的实现:
pkg/controllers/cnset/controller.go)新增syncMetricService,创建/reconcile 一个独立的<cn>-cn-metricClusterIP Service,带
metric:7001端口(照抄dnset/controller.go的syncMetricService实现)Finalize中一并清理PromDiscoveredByService()为真时给这个 Service 打prometheus.io/scrape/portannotation,跟 DN/Log行为保持一致,也兼容仍在用 annotation-based scrape 的环境——但这两条 annotation 对 ServiceMonitor 发现机制不是必需的
exportToPrometheus关闭时,主 SQL Service 的 annotation 清理此前只删了prometheus.io/scrape,遗漏了prometheus.io/port;现在两者都会被删除Special notes for your reviewer:
exportToPrometheus/promDiscoveryScheme取值),跟现有 DNSet/LogSet 行为一致——只有annotation 是有条件的。如果 reviewer 认为 CN 应该在没开 metrics 时完全不创建这个 Service,可以在这里讨论是否要让 CN 的行为跟 DN/Log
出现分歧
ServiceMonitor/VMServiceScrape这类CRD(已做过全仓库搜索确认),本次修复不涉及;用户需要自行确保现有 ServiceMonitor 的 selector 能覆盖 CNSet 的
matrixorigin.io/*标签,并且 endpoint 用
metric这个端口名ProxySet存在同样的问题(在已有 Service 上打 annotation,没有创建独立 metric Service),本 PR 未处理,如有需要可以后续单独提 PRdocs/dev/issue-600-cn-metrics-service.mdAdditional documentation (e.g. design docs, usage docs, etc.):
Not Available