Skip to content

client: add reset option for local cache exporter#6612

Open
jirimoravcik wants to merge 1 commit intomoby:masterfrom
jirimoravcik:feat-add-local-cache-reset
Open

client: add reset option for local cache exporter#6612
jirimoravcik wants to merge 1 commit intomoby:masterfrom
jirimoravcik:feat-add-local-cache-reset

Conversation

@jirimoravcik
Copy link
Copy Markdown

@jirimoravcik jirimoravcik commented Mar 25, 2026

Add reset=true attribute to the local cache exporter that removes unreferenced blobs from the cache directory after export, preventing unbounded growth.

The logic is very simple:

  1. Go through the index.json to get all the referenced manifests
  2. Create a set of referenced blobs (check each referenced manifest)
  3. Walk all the blobs in the cache directory, if there's a blob that is not referenced by any manifest, flag it for deletion
  4. Delete all blobs flagged for deletion

I think cleanup could also work as the attribute name.

Resolves #1896

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reset=true option to the local cache exporter so exported cache directories can be cleaned up (unreferenced blobs removed) after export, preventing unbounded growth. This fits into the client-side cache export flow that already updates the local index.json after a solve.

Changes:

  • Parse a new reset attribute for type=local cache exports and trigger a post-export cleanup.
  • Implement resetCacheStore to compute referenced blobs from index.json and delete unreferenced blobs.
  • Add unit + integration tests and document the new option in README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
client/solve.go Parses reset attr, tracks stores to reset, and implements blob cleanup after export.
client/solve_resetcache_test.go Unit tests for resetCacheStore behavior (currently image-manifest oriented).
client/client_test.go Integration test for reset=true behavior with local cache export.
README.md Documents the new reset=<true|false> option for local cache exporter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add `reset=true` attribute to the local cache exporter that removes
unreferenced blobs from the cache directory after export, preventing
unbounded growth.

Signed-off-by: Jiří Moravčík <jiri.moravcik@gmail.com>
@jirimoravcik jirimoravcik force-pushed the feat-add-local-cache-reset branch from d06efaa to 20a5427 Compare March 25, 2026 20:29
@jirimoravcik
Copy link
Copy Markdown
Author

Fixed the lint, other errors seem to be 50x responses from DockerHub API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cache cleanup option to local cache exporter

2 participants