Skip to content

fix(ko): prefer remote base images and don't cache failed lookups - #7275

Merged
caarlos0 merged 1 commit into
goreleaser:mainfrom
mrueg:fix/ko-base-image-remote-first
Nov 10, 2026
Merged

caarlos0 merged 1 commit into
goreleaser:mainfrom
mrueg:fix/ko-base-image-remote-first

Conversation

@mrueg

@mrueg mrueg commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

What

  • The ko base image is now fetched from its registry first. The local Docker daemon is only used as a fallback when the remote fetch fails, so images that only exist locally (the use case from feat: support ko loading base image from daemon #6233) keep working.
  • Failed base image lookups are no longer stored in the base image cache.

Why

  • Since feat: support ko loading base image from daemon #6233 the daemon was checked first, so a stale local copy of e.g. cgr.dev/chainguard/static silently ended up in released images instead of the published one. A daemon image is also single-platform, which doesn't fit multi-platform builds.
  • desc.Image() / desc.ImageIndex() results were cached before checking the error, so a failed lookup stored nil, and the next lookup of the same image would panic on cached.(build.Result).

The base image resolution moved into getBaseImage/fetchBaseImage so it can be tested directly. Docs updated to describe the new precedence.

🤖 Generated with Claude Code

The local Docker daemon was queried before the registry, so a stale
local copy of a base image (e.g. cgr.dev/chainguard/static) would be
used for releases instead of the published one. The daemon is now only
used as a fallback when the image can't be fetched remotely, so
images that only exist locally keep working.

Also stop storing failed lookups in the base image cache, which could
lead to a panic on the next lookup of the same image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 4, 2026

@caarlos0 caarlos0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actionable findings from static review of 7ea80eb. Both independent leaf checks completed (maintainer and adversarial verify-only).

The claimed existing nil-cache panic is not supported by the pinned go-containerregistry v0.22.1 implementation: the image/index conversions admitted by the media-type guards return wrappers without errors. The new connection-failure test exercises an error path that already returned before cache insertion; it does not demonstrate that claimed panic fix. This does not invalidate the separate registry-first change.

Verification limits: no builds, tests, or PR-code execution were permitted. The reported checks contain only WIP (passed), not build/test results. Runtime behavior and build/test status remain unverified; this is not an approval.

– Copilot, on behalf of Carlos

@caarlos0
caarlos0 enabled auto-merge November 10, 2026 17:45
@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.63%. Comparing base (b8f79e0) to head (7ea80eb).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
internal/pipe/ko/ko.go 96.29% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7275   +/-   ##
=======================================
  Coverage   91.63%   91.63%           
=======================================
  Files         192      192           
  Lines       16108    16112    +4     
=======================================
+ Hits        14760    14765    +5     
+ Misses       1348     1347    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@caarlos0
caarlos0 added this pull request to the merge queue Nov 10, 2026
Merged via the queue into goreleaser:main with commit a8f1c1e Nov 10, 2026
19 checks passed
@github-actions github-actions Bot added this to the v2.18.0 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址