Skip to content

feat: report why an artifact is being rebuilt on a cache miss - #10175

Open
peter-sanford wants to merge 1 commit into
GoogleContainerTools:mainfrom
peter-sanford:cache-miss-reason
Open

feat: report why an artifact is being rebuilt on a cache miss#10175
peter-sanford wants to merge 1 commit into
GoogleContainerTools:mainfrom
peter-sanford:cache-miss-reason

Conversation

@peter-sanford

Copy link
Copy Markdown

PR 1 — branch cache-miss-reason

Title: feat: report why an artifact is being rebuilt on a cache miss

Fixes #10174

What

Not found. Building says an artifact is being rebuilt but not why, so a
rebuild caused by a pruned image looks exactly like one caused by a source
change.

The cache lookup already distinguishes the two: it knows whether the artifact's
current hash had an entry in the artifact cache. This carries that into
needsBuilding as a typed reason and appends it to the existing line:

 - app: Not found. Building (no cached build for the current inputs)
 - api: Not found. Building (cached image is no longer available)

Notes for review

  • No new files, flags, lookups or I/O. The reason is derived from the cache
    entry the lookup already had in hand, so there is no behavioural change
    beyond the message.
  • The reason is a typed value, formatted at the point of printing, so tests
    assert on the enum rather than on prose.
  • The existing line is only ever suffixed, so anything matching on
    Not found. Building (including integration/build_test.go and
    integration/build_dependencies_test.go) keeps working.
  • The sample output in docs-v2/.../tutorials/artifact-dependencies.md is
    updated to match what the command now prints.

Testing

  • go test ./pkg/skaffold/build/cache/... — new coverage for the reason
    derivation and for the printed output end to end.
  • Full unit suite (./pkg/skaffold/... ./cmd/... ./hack/... ./pkg/webhook/...,
    -race -short) passes.
  • hack/boilerplate.sh, hack/check-schema-changes.sh, hack/check-samples.sh,
    hack/check-licenses.sh, hack/test-generated-proto.sh and the docs site
    build all pass.

"Not found. Building" gives no indication of whether an artifact's inputs
changed or whether its previously built image simply disappeared, which makes
an unexpected rebuild hard to diagnose.

The cache lookup already distinguishes those two cases: it knows whether the
artifact's current hash had an entry in the artifact cache. Carry that
distinction into needsBuilding as a typed reason and append it to the existing
line:

 - app: Not found. Building (no cached build for the current inputs)
 - app: Not found. Building (cached image is no longer available)

The reason is derived entirely from state the lookup already has, so this adds
no new files, flags, lookups or I/O.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Cache misses are reported with a reason

1 participant