Repository navigation
fix(sync): make digest cache restore actually hit via restore-keys prefix fallback - #153
Merged
Merged
Conversation
Contributor
Author
合入后验证 + 更正一处分析更正:本 PR 原描述「缓存从未生效」不准确。 真正修掉的 bug(review 第 1 点的前缀碰撞,旧代码就存在):mindie 是 mindie-motor/mindiesd 的字符串前缀,mindie 的 restore 前缀匹配会串到别人的缓存归档(取「最近创建」那条,大概率不是自己的):
冷启动一次性代价:key 格式从 稳态验证(两个 run 间隔 11 分钟):
|
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.
问题(review 中发现,与 #152 无关)
digest 缓存的 restore/save key 对不上:
key: digest-cache-${{ matrix.src }},没有restore-keys→ 只做精确匹配key: digest-cache-${{ matrix.src }}-${{ github.run_id }}(if: always(),每 run 保存)save 的 key 永远带
-run_id后缀,restore 的精确匹配永远 miss,缓存从未生效过:CACHE_FILE每次从空文件开始 → docker.io 目的地的「cache 跳过」分支永远走不到quay/swr 目的地不受影响(走实时 inspect 比对跳过,不依赖此缓存)。
修复
restore 加前缀回退,分隔符用
#(src 字符集里不可能出现的字符):save key 顺手带上
run_attempt(同一 run re-run 时 key 不冲突,避免 save 撞 already exists——既有行为,顺手修掉):为什么分隔符必须用
#(review 指出)-/__都不行:src 之间互为字符串前缀,例如.../ascendhub/mindie是.../ascendhub/mindie-motor、.../ascendhub/mindiesd的前缀若 restore-keys 用
digest-cache-<mindie>,前缀回退会匹配到 mindie-motor/mindiesd 的 save key(多条 partial 命中时取最近创建)→ 取回别的 src 的归档,里面文件名是..._mindie-motor.json,当前 job 读..._mindie.json找不到 → 回落{}。不串数据(不损坏、不误跳过),但 mindie 的 docker.io 跳过经常失效,等于白修。用#后mindie#不可能是mindie-motor#...的前缀,48 个 src 互不干扰(已脚本断言全量无前缀碰撞)。效果
docker.io 目的地恢复设计意图:上次已同步且 digest 未变的 tag 直接走 cache 跳过,不再逐 tag 重推 manifest;定时 run 对 docker.io 的同步耗时和配额消耗显著下降。
注意:合入后第一次 run 是缓存冷启动(旧缓存 key 格式不匹配新前缀),docker.io 目的地会全量 re-copy 一次,之后恢复正常跳过。
与 #152 的关系
协同:#152 让同 src 串行,正好保证
digest-cache-<src>#的 save/restore 不跨 run 竞争。本分支已并入合入 #152 后的 main,无冲突。