fix: 避免引擎日志重复写入 - #849
Merged
dengyh merged 1 commit intoAug 3, 2026
Merged
Conversation
There was a problem hiding this comment.
Review Summary
✨ 整体改动清晰合理。通过将 pipeline、bamboo_engine、pipeline_engine 的 propagate 设为 False,解决了日志重复写入 root handler 的问题(这些 logger 已显式包含 root handler,无需再通过 propagation 再写一次)。
移除 empty-handlers fallback 也是安全的:pipeline.eri.log 在非 DATABASE 模式下 handlers 被清空后,仍通过 propagate: True 向父级 pipeline logger 传递,最终到达 root handler。
测试覆盖充分,验证了核心场景(每条日志只写一次 root handler、DATABASE 模式保留 context handler、PaaS3 模式移除 context handler)。
无 Critical 或 Important 级别问题。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #849 +/- ##
===========================================
+ Coverage 83.60% 83.62% +0.02%
===========================================
Files 324 324
Lines 20722 20724 +2
===========================================
+ Hits 17324 17330 +6
+ Misses 3398 3394 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
问题原因
bamboo_engine、pipeline_engine和pipeline在自身绑定rootHandler 后仍向父 logger 传播,导致同一个 Handler 沿 logger 继承链被重复调用。PaaS3 日志模式下,pipeline.eri.log的数据库 Handler 被移除后又补上rootHandler,最多会将同一条日志写入三次。修改内容
bamboo_engine、pipeline_engine和pipeline设为对应日志链路的传播终点。pipeline.eri.log使用空 Handler 并传播到pipeline,避免重复绑定root。影响范围
仅调整 Python logging Handler 的传播路径,不修改日志内容、级别、格式、Trace 信息、节点信息或日志查询接口。合法的重复业务日志不会被过滤。
该修复与 master PR #848 内容一致,本 PR 基于最新
develop单独创建,避免引入 master/develop 间的其他提交差异。验证
pytest tests/project_settings tests/engine/task/test_node_log.py -q --no-cov:25 passed。pre-commit run --files config/default.py tests/project_settings/test_logging_settings.py:全部通过。