feat: bcs-bkcmdb-synchronizer日志优化及本地缓存自动清理#3835
Open
yuyudeqiu wants to merge 7 commits into
Open
Conversation
1. remove redundant 'Successfully converted string to int64' logs 2. merge whitelist and blacklist logs into a single line in synchronizer and handler
Added clusterUid and bkBizID to various logs in handler.go to improve traceability.
- 在 internal/pkg/common 中添加泛型 Deref 和 Ptr 函数,用于安全处理指针并防止 panic。 - 完善 cmdbClient 各个方法的日志,增加 bkBizID、IDs、Kind、名称等上下文信息。 - 在日志输出和函数参数中使用 common.Deref 提升安全性。 - 注意:CreateBcsPod 和 DeleteBcsPod 目前仅记录数据条数 (data_nums),详细日志建议在调用方记录。
… up orphaned SQLite cache files
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.
概述
针对
bcs-bkcmdb-synchronizer服务进行了一系列日志优化,减少无效日志噪音、补全关键上下文信息,同时新增本地 SQLite 缓存的自动清理机制,提升可观测性与运维效率。
变更内容
1. SQLite / GORM 日志等级控制
SynchronizerConfig中新增SqlLogLevel配置项,支持通过配置控制 GORM SQL 日志等级。sqlite.Open/sqlite.New,接收并传递日志等级,默认屏蔽大量 SQL 查询输出。2. 删除冗余日志
"Successfully converted string to int64"等仅在成功时打印的冗余日志,改为只在出错时记录。
3. 黑白名单日志合并
synchronizer.go和handler.go中分两行打印的whiteList/blackList日志合并为一行输出,减少日志条数。
4. 完善 CMDB API 调用日志
internal/pkg/common中新增泛型Deref/Ptr工具函数,用于安全处理指针,防止 panic。cmdb.go各 API 方法的日志内容,补充BizID、ClusterID、NamespaceID、PodName、Ref、Kind、IDs等关键字段,便于快速定位问题。BizID、NamespaceID、Workload 引用及 Pod IP 信息。5. Handler 日志补充集群信息
handler.go关键日志中增加clusterUid和bkBizID字段,确保每条消息都能追溯到具体的集群和业务。
6. 本地缓存自动清理(CleanLocalCache)
CleanLocalCache配置项(环境变量:synchronizer_cleanLocalCache),支持开关控制。cleanupLocalCaches方法:扫描数据目录,删除不在当前工作列表中的孤立.db文件。