cache lookahead - part 2#674
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
18ced15 to
ceed92c
Compare
|
Code Review Overall this is clean and well-motivated. Moving dryrun to after the lookahead phase is the right call — it lets the plan output carry actual cache hit/miss annotations, and the golden test approach gives solid end-to-end coverage for this. Potential bug: command index misalignment in
If In practice Unused golden file
Minor: global-var DI for Using a package-level No concerns with the |
f83d378 to
0bf55fa
Compare
GetCommand returns nil for deprecated instructions like MAINTAINER, causing newStageBuilder to produce a shorter s.cmds than stage.Commands. This creates an index skew: optimize writes stageCacheInfo at s.cmds positions while RenderStages reads it at stage.Commands positions, so a MAINTAINER before a cached RUN prints the wrong cache key and panics out-of-bounds on the last command. Keeping nil entries in s.cmds fixes the alignment; loops that call methods on commands already guard nil or are updated here to do so.
The lookahead phase calls NewLayerCache inside the per-stage loop, creating a fresh cache client for every stage. This breaks FakeLayerCache in tests (the key sequence resets to position 0 for each stage) and wastes a connection in production. A single client is correct: the lookahead is one logical query.
0bf55fa to
3b334f0
Compare
Description
Moves the dryrun render output to after the cache lookahead phase. This makes it possible to include cache hit/miss results in the dryrun plan output, and enables golden tests to verify cache lookahead behaviour end-to-end.
Adds the first golden test for cache lookahead (
test_issue_mz334).Submitter Checklist
Release Notes
No user-facing changes.