[Bug]: gitfs with pygit2 >= 1.20 keeps deleted branches as saltenvs (fetch prune no longer used)
维护者通常 3 天内回复
已经有一个关联 PR 被合并了。
- #70768 来自 @aliassar —— 已合并
评估
调研方向
Start in salt/utils/gitfs.py and inspect the three pygit2.GIT_FETCH_PRUNE references in Pygit2._fetch, Pygit2.clean_stale_refs, and verify_pygit2. Check how pygit2.enums.FetchPrune.PRUNE is used and compare anonymous with authenticated remotes when pruning. Done when pygit2 1.20 or newer prunes deleted refs on fetch for both remote types, without requiring the git binary for the pygit2 provider.
由索引模型根据 Issue 内容生成。
描述
What happened?
pygit2 1.20.0 removed the old GIT_* constants, including GIT_FETCH_PRUNE (it's pygit2.enums.FetchPrune.PRUNE now, available since 1.14.0). salt/utils/gitfs.py still reads pygit2.GIT_FETCH_PRUNE in three places and treats the AttributeError as "this pygit2 is too old to prune":
Pygit2._fetchstops passingprune=toRemote.fetch().Pygit2.clean_stale_refsfalls back togit remote prunefor anonymous remotes, and for remotes with credentials it just logs "The installed version of pygit2 (...) does not support detecting stale refs for authenticated remotes" and returns[].verify_pygit2now requires thegitbinary to be on PATH, otherwise the pygit2 provider is rejected.
So with an authenticated gitfs/git_pillar remote (user/password or SSH key), a branch or tag deleted on the remote stays around as a saltenv forever.
Repro: I drove salt.utils.gitfs.Pygit2 directly against a local repo with master and feature branches, fetched, deleted feature in the remote, and fetched again. "Authenticated" means credentials/remotecallbacks are set the same way salt sets them for gitfs_user/gitfs_password.
pygit2 1.19.2 pygit2 1.20.0
--- anonymous remote --- anonymous remote
after deleting feature: ['base'] after deleting feature: ['base']
prune kwarg: [PRUNE, PRUNE] prune kwarg: [None, None]
--- authenticated remote --- authenticated remote
after deleting feature: ['base'] after deleting feature: ['base', 'feature']
prune kwarg: [PRUNE, PRUNE] prune kwarg: [None, None]
(The anonymous case still works on 1.20 only because it falls back to the git CLI.) Same result on pygit2 1.21.0 once the add_file problem from #70673 is out of the way.
The same debug message shows up in the log in #70298 (pygit2 1.20.0), and #70744 bumps pygit2 to >=1.21.0, so this will hit packaged installs soon.
Expected: pygit2 >= 1.20 prunes on fetch like older releases, and deleted branches stop being saltenvs.
Seen on 3008.x at 987eefd0f3. The code is the same on 3006.x, 3007.x and master, so any install that pulls in pygit2 >= 1.20 is affected.
Type of salt install
pip (git)
Major version
3008.x
What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)
Not OS specific (reproduced on macOS from a git checkout).
salt --versions-report output
Not from a packaged install. Relevant bits: salt 3008.x @ 987eefd0f3, Python 3.11, pygit2 1.20.0 (libgit2 1.9.6) and 1.21.0 (libgit2 1.9.7). pygit2 1.15.1 and 1.19.2 are fine.
- 主要语言
- Python
- 星标
- 15.8k
- 派生
- 5.6k
- 平均合并
- 5 天 9 小时
- 30 天内合并 PR
- 99
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
saltstack/salt 的其他 Issue
-
[Bug]: Scheduled returns scan all accepted minion keys causing extreme load可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug needs-triage
难度 2/5 1-3 小时 新手友好度 76/100
saltstack/salt#70789 · 1 条评论 ·
维护者通常 3 天内回复
-
[Bug]: pip.installed with upgrade=True upgrades a package but returns an empty changes dictionary可能已有人在做 @ITJamie 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 3 天内回复
-
[Bug]: Minion with file_client: local crashes on connect: 'AsyncPillar' object has no attribute 'aclose'可能已有人在做 @shawnrruss 于 9 天前认领。 未关闭bug needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
[Bug]: mine.update clear=True raises UnboundLocalError on the master and stores nothing可能已有人在做 @cestercian 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
saltstack/salt#70622 · 1 条评论 ·
维护者通常 3 天内回复
相似的 Issue
-
AI bug
难度 2/5 1-3 小时 新手友好度 68/100
AUTO-MAS-Project/AUTO-MAS#1960 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
btclib-org/btclib-wallet#872 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 87/100
btclib-org/btclib#3093 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 85/100
patrickballard/wheelgap#269 ·