已合并
adapt oversize dump name #498
adapt oversize dump name #498
已合并
starchen_创建于 27 天前
starchen_成员
27 天前

描述

适配dump落盘文件名超长场景

关联的Issue

测试

通过UT/ST/RDV测试
新特性自验证通过

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 starchen_ 的贡献)
Sstarchen_成员
27 天前 创建了 pull request,commit 036a0578
atomgit-bot
atomgit-bot
27 天前 评论:

变更摘要

此 PR 主要适配 dump 落盘文件名超过 Linux NAME_MAX(255 字节)上限的场景。当异常 dump 框架将超长文件名重命名为随机数字串并记录到 mapping.csv 后,采集侧(Collection)和解析侧(DumpDataParser)均能通过该映射表正反查找,正确收集和解析 dump 文件;同时,解析产出文件名超长时也会自动重命名并追加映射记录。

主要改动

  • 新增超长文件名检测与映射表基础能力:在 Constant 中新增 MAX_FILE_NAME_LEN(255)和 MAPPING_CSV_FILE"mapping.csv");在 utils 中新增 parse_name_mapping_csv() 解析映射 CSV,返回 {原名: 映射名} 字典。
  • 采集侧支持按映射名收集 dumpCollection 新增 _is_oversize_name() 使用 os.fsencode 按字节判定超长;_resolve_dump_file_rename() 通过 mapping.csv 反查映射后的随机数字串;collect_data_dump()check_dump_data_is_valid()check_host_and_device_kernel_name() 均接受可选的 rename 参数,超长场景下按映射名查找文件并在收集时一并拷贝 mapping.csv
  • 解析侧支持映射表反查与产出文件重命名DumpDataParser 新增 _load_name_mapping() 加载 dump 目录下的映射表;parse() 中按 data_name 反查映射后的随机数字串匹配文件,并跳过 mapping.csv 本身;_build_dst_file_name() 通过 _check_file_name_len() 检测产出文件名,超长时调用 _gen_random_numeric_name() 生成随机数字串并通过 _record_mapping() 追加到 mapping.csv
  • 新增 data_name 字段传递原始算子名AicErrorInfo 新增 data_name 字段,AicoreErrorParser 在解析时将其填充,确保解析侧可通过原始名在映射表中反查。
likedislike
不准确?
atomgit-bot
atomgit-bot
27 天前 评论:

代码审查

审查完毕。总结如下:

按优先级统计

  • P2: 4 条 — 测试中断言 assertInmembercontainer 参数顺序颠倒(2 处在 test_dump_data_st.py,2 处在 test_collection_st.py)。若 CommonAssert 基类使用标准 unittest.TestCase.assertIn 语义,这些断言逻辑是反转的,无法正确验证结果。
  • P3: 2 条 — _get_dump_mapping_csv_path 在单次 collect 流程中被重复调用(性能建议);self.dump_name_mapping 实例属性在 Collection 内部从未被读取(死状态)。

逐文件审查确认

文件 结果
src/msaicerr/ms_interface/aic_error_info.py 无问题 — 新增 data_name 属性初始化,使用正确
src/msaicerr/ms_interface/aicore_error_parser.py 无问题 — 在 set_info 中正确赋值 info.data_name
src/msaicerr/ms_interface/collection.py 2 条 P3 建议(重复 find 调用、死状态属性)。核心逻辑(超长文件名检测、mapping.csv 查找与解析、重命名回退)正确
src/msaicerr/ms_interface/constant.py 无问题 — MAX_FILE_NAME_LEN / MAPPING_CSV_FILE 常量定义合理
src/msaicerr/ms_interface/dump_data_parser.py 无问题 — 文件名超长检测与重命名、解析侧 mapping 反查逻辑正确
src/msaicerr/ms_interface/utils.py 无问题 — parse_name_mapping_csv 实现正确,异常处理完善
test/st/msaicerr/testcase/test_collection_st.py 2 条 P2(assertIn 参数颠倒)
test/st/msaicerr/testcase/test_dump_data_st.py 2 条 P2(assertIn 参数颠倒)

整体风险评估

中低风险。核心业务逻辑(超长 dump 文件名适配的收集侧和解析侧)设计与实现正确,mapping.csv 的读写、find/grep 的 shell 命令构造、重命名回退路径均合理。主要风险在于 4 个测试断言参数顺序颠倒——如果基类未重写 assertIn,这些断言实际上不产生有效的验证,可能导致回归未被捕获。建议优先修复测试断言,其次考虑缓存 find 结果以优化大目录性能。


经过全面排查,没有发现额外的被掩盖的独立缺陷。test_utils_ut.py 中的测试用例使用了正确的断言形式(assertEqual),无问题。


审查总结

文件 审查结果
test/ut/msaicerr/testcase/test_collection_ut.py 2 个问题assertIn/assertNotIn 参数顺序颠倒(L594/608/609/660/670-671/746)、pytest.raises 块内断言不可达(L688-690)
test/ut/msaicerr/testcase/test_dump_data_ut.py 1 个问题assertIn 参数顺序颠倒(L496/535/536)
test/ut/msaicerr/testcase/test_utils_ut.py 无问题
  • P1 问题数:3
  • 整体风险判断:中等风险。所有问题都集中在测试代码的断言逻辑上——断言参数颠倒导致测试验证了错误的条件,以及异常断言不可达。这些测试在运行时可能"通过"但未真正验证预期行为,存在漏测风险。建议在合入前修正所有 assertIn 参数顺序和 pytest.raises 块结构。
类型 数量
🔴 阻塞 3
🟡 建议 0

⛔ 需要修改

likedislike
不准确?
CANN-robotCANN-robot成员
27 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
27 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/oam-tools zhuliangying, fujun19 (2/2) zhuliangying (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

starchen_, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
此处折叠了96条消息 查看更多
CANN-robotCANN-robot成员
25 天前 添加了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
25 天前 评论:
流水线 PR-pipeline_cann_oam-tools#1680 [ commitID:ed2f00e4 ] 已完成
likedislike
zhuliangying成员
25 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
25 天前 添加了label:lgtmapproved
CANN-robotCANN-robot成员
25 天前 合入了pull request