Open
fix(repo): handle updates with no enabled plugin sources #187
fix(repo): handle updates with no enabled plugin sources #187
Open
2503_92678250Add on 1 day ago
2503_92678250
2503_92678250
1 day ago

Fixes #18.

当前 PR 是否有 AI 参与

  • Agent 平台信息:OpenAI Codex 0.171.0-alpha.13.2
  • 模型信息:GPT 6.2 Sol high Ultra Fast
  • Prompt 摘要:修正无启用插件源时的更新退出状态,保留缓存清理失败与活跃源下载语义,补充 repo set 创建缺失配置的回归测试。
  • 人工审阅:贡献者在提交前确认已审阅 v12 中 #18 的差异及本次兼容性增量,并批准发布。

变更

  • 空配置或源全部禁用时,oedp repo update 清理旧索引后返回成功,无需下载。
  • 更新未读到配置,或无启用源且清理失败时返回失败。至少成功下载一个索引时保留原成功行为。
  • 仅在 update 要求读到配置,保留 repo set 在目录可写时创建缺失配置的行为。

验证

  • 在当前 master 仅加入回归测试时,空配置、全禁用两个用例按预期失败;应用补丁后 119/119 通过,无跳过或错误。
  • 兼容修订恢复 repo set 创建缺失配置的行为。缓存权限错误由本地测试模拟。
  • 与 #41 的独立候选合用时 122/122 通过。本 PR 仅包含 #18 的修复。
likedislike
Merge blocked
2503_926782502503_92678250
1 day ago Created pull request, commit 191979c8
2503_926782502503_92678250
1 day ago Associated issue: oeDeploy插件源如果为空,或者所有插件源都disable,oedp repo update应该返回成功,网络延迟高的情况下,插件源索引更新失败,插件初始化失败,建议将超时时间改成可配置
atomgit-bot
atomgit-bot
1 day ago Comments:

变更摘要

本 PR 修正 oedp repo update 在“配置文件为空或所有插件源均被禁用”场景下的退出状态语义:此前这类情况会被判定为更新失败,现在则改为在成功清理旧索引缓存后返回成功,且不触发任何下载。核心改动集中在 RepoCmd 的 run_update、_read_repo_config 与 _cleanup_old_cache_files 三个方法:读取配置新增 required 参数以区分 update 与 set 的语义,缓存清理改为返回清理结果,并由 run_update 组合出完整的成功/失败判定;同时新增回归测试覆盖空配置、全禁用、清理失败、配置缺失或不可读等分支。

主要改动

  • 更新结果的判定逻辑调整:run_update 不再仅以 len(downloaded_files) > 0 作为成功条件,而是优先在至少下载一个索引时返回成功;否则要求缓存清理成功且所有配置分段的 enabled 均为假(fallback=True)才返回成功,并对 ValueError、configparser.InterpolationError 兜底返回失败。
  • 配置读取区分必需与可选:_read_repo_config 新增仅关键字参数 required,返回类型改为 Optional[configparser.ConfigParser];当 required=True 且 config.read 未读到文件时记录错误并返回 None,使 run_update 以 config is None 判断失败,而 repo set 继续沿用默认 required=False,保持目录可写时创建缺失配置的行为。
  • 缓存清理结果可感知:_cleanup_old_cache_files 的返回值由无返回改为 bool,内部用 cache_cleaned 标记单个文件删除失败,对 FileNotFoundError 直接跳过,目录列举异常时统一返回 False,供上层判定整体更新状态。
  • 新增回归测试文件:unittest/test_repo_no_enabled_sources.py 通过临时目录与 patch.multiple 替换 REPO_CONFIG_PATH、REPO_CACHE_DIR、PLUGIN_DETAILS_DIR,覆盖空配置与全禁用源返回成功且不调用下载、清理失败或缓存不可读返回失败、成功下载时清理失败仍为成功、配置缺失或不可读以及源配置格式异常不误报成功、repo set 创建缺失配置等用例。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
1 day ago Comments:

代码审查

审查结论

逐文件确认

  • oedp/src/commands/repo/repo_cmd.py:已审查(run_update 新判定、_read_repo_config 契约变更、_cleanup_old_cache_files 返回值改造,以及 _process_repositories、run_set 等调用链),发现问题 1 个 P2、1 个 P3。
  • unittest/test_repo_no_enabled_sources.py:已审查(10 个用例、setUp 的 patch 生命周期与 addCleanup 顺序、全局 os.listdir/os.remove patch 的作用域、重试次数 3 的断言、ConfigParser 用例的短路覆盖问题)。除上述与生产代码相关的问题外,测试文件本身未发现独立缺陷;但其中的畸形配置用例因不含 url 而存在覆盖盲区,已并入 P2 条目。

问题统计

  • P0:0
  • P1:0
  • P2:1(新增的 except 无法捕获 _process_repositories 中先抛出的 ValueError / InterpolationError,畸形 enabled 会以 traceback 形式崩溃,且回归测试未覆盖)
  • P3:2(Optional 契约只迁移了 run_update,兄弟调用点仍用真值判断;enabled 缺省语义三处不一致)

总体风险判断:核心目标(空配置/全禁用时 repo update 返回成功、仅成功下载保留原语义、清理失败才失败)在逻辑与测试上基本自洽,主线修复可信。主要残留风险集中在错误处理路径:畸形 enabled 值仍会以未捕获异常崩溃(且新测试给出虚假保障),以及空配置状态下 enabled 缺省语义在不同代码路径间不一致,建议在合并前至少确认并处理 P2 一条。

类型 数量
🔴 阻塞 0
🟡 建议 1

💬 仅评论

likedislike
Incorrect?
openeuler-ci-botopeneuler-ci-botCollaborators
1 day ago Set MrRlu,solarhu,Gemshunter,yangzhao_kl,hjx_gitff,byrobins,luanjianhai,snoweay,lostway1 as approver
openeuler-ci-botopeneuler-ci-botCollaborators
1 day ago Added label: sig/sig-ops
openeuler-ci-bot
openeuler-ci-botCollaborators
1 day ago Comments:

Welcome To openEuler Community

Hey @2503_92678250 , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: sig-ops ,
and any of the maintainers: @Gemshunter, @MrRlu, @byrobins, @hjx_gitff, @lostway1, @luanjianhai, @snoweay, @solarhu, @yangzhao_kl ,
and any of the committers: @dingjiahuichina, @randy1568 .

likedislike
openeuler-ci-botopeneuler-ci-botCollaborators
1 day ago Added label: openeuler-cla/yes
openeuler-ci-bot
openeuler-ci-botCollaborators
1 day ago Comments:

CLA Signature Pass

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

likedislike
openeuler-botopeneuler-botCollaborators
1 day ago Added label: ci_processing
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/oeDeploy/5

likedislike
openeuler-botopeneuler-botCollaborators
1 day ago Removed label: ci_processing
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:
Check Name Build Result 详情 Build Details
check_package_license ⚠WARNING • 仓库copyright检查未通过: 缺少项目级Copyright声明文件 #5
check_code ❌FAILED • CodeCheck服务内部错误(500),请联系CI管理员
check_sca ✅SUCCESS
x86_64 check_build ✅SUCCESS #5
aarch64 check_build ✅SUCCESS #5
likedislike
openeuler-botopeneuler-botCollaborators
1 day ago Added label: ci_failed
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:

@2503_92678250

likedislike
2503_92678250
2503_92678250
1 day ago Comments:

/retest

likedislike
openeuler-botopeneuler-botCollaborators
1 day ago Removed label: ci_failed
openeuler-botopeneuler-botCollaborators
1 day ago Added label: ci_processing
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:

门禁正在运行, 您可以通过以下链接查看实时门禁检查结果.
若您对门禁结果含义不清晰或者遇到问题不知如何解决,可参考门禁指导手册
门禁入口及编码规范检查: multiarch/openeuler/trigger/oeDeploy/6

likedislike
atomgit-bot
atomgit-bot1 day agoStart code review1
oedp/src/commands/repo/repo_cmd.py
@@ -117,0 +118,4 @@
118+ for section in config.sections()
119+ )
120+ except (ValueError, configparser.InterpolationError):
121+ return False
atomgit-bot
atomgit-bot1 day agoComments:

🟡 Medium Priority

变更点:run_update 新增了 except (ValueError, configparser.InterpolationError)(第 115-121 行)来兜住畸形 enabled 值,使 oedp repo update 干净地返回 False。

受影响路径:第 110 行先调用 _process_repositories(config),其第 291-293 行用无 fallback 的 config.getboolean(section, 'enabled') 求值同一个选项;由于条件链是 has_option('enabled') and has_option('url') and getboolean(...),只有 url 存在时才会真正执行 getboolean。

失败模式:当 repo.conf 写成 [x]\nurl = https://...\nenabled = invalid(或 enabled = %(undefined)s)时,_process_repositories 先抛出 ValueError / InterpolationMissingOptionError,它是在新增的 try 之前抛出的,因此新加的 except 完全捕获不到;异常一路冒泡到 oedp/src/parsers/oedp_parser.py:73(args.func(args) 外层无 try,注释明确写“不需要处理异常”),用户看到的是 Python traceback 而不是“更新失败”的退出码,正是本 PR 想消除的形态。

测试侧证据:新增的 test_malformed_source_does_not_report_success(unittest/test_repo_no_enabled_sources.py:89-96)四个用例都不带 url,命中第 292 行 has_option(section, 'url') 的短路,因此永远不会走到 getboolean,这条崩溃路径没有覆盖面,测试给出的“畸形配置不报成功”保障是虚假的。

建议:在 _process_repositories 中解析 enabled 时加 try/except(ValueError, configparser.Error),捕获后记录错误并 continue;或把第 110 行的 self._process_repositories(config) 调用也纳入 try 范围,保证畸形配置统一返回 False 而不是抛 traceback。并给 unittest/test_repo_no_enabled_sources.py 增加 url = ... + enabled = invalid 的用例覆盖该路径。

likedislike
Incorrect?
openeuler-botopeneuler-botCollaborators
1 day ago Removed label: ci_processing
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:
Check Name Build Result 详情 Build Details
check_package_license ⚠WARNING • 仓库copyright检查未通过: 缺少项目级Copyright声明文件 #6
check_code ❌FAILED • CodeCheck服务内部错误(500),请联系CI管理员
check_sca ✅SUCCESS
x86_64 check_build ✅SUCCESS #6
aarch64 check_build ✅SUCCESS #6
likedislike
openeuler-botopeneuler-botCollaborators
1 day ago Added label: ci_failed
openeuler-bot
openeuler-botCollaborators
1 day ago Comments:

@2503_92678250

likedislike