Detect and clean stale kind image stamps before building#12504
Open
caseydavenport wants to merge 3 commits intoprojectcalico:masterfrom
Open
Detect and clean stale kind image stamps before building#12504caseydavenport wants to merge 3 commits intoprojectcalico:masterfrom
caseydavenport wants to merge 3 commits intoprojectcalico:masterfrom
Conversation
If a Docker image gets pruned while its stamp file remains, Make thinks the image is up-to-date and skips the rebuild. This adds a validation step that removes stamps whose images no longer exist in Docker, then re-invokes Make so prerequisites are re-evaluated with accurate state.
Stamp rules now record the Docker image they track, so validate_stamps.sh can just read the file instead of deriving the image name from the stamp path via a brittle case statement.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the reliability of the local kind development workflow by preventing stale “image built” stamp/marker files from causing make kind-build-images / make kind-reload to incorrectly skip rebuilding images after Docker images have been pruned.
Changes:
- Adds a pre-build validation step (
validate_stamps.sh) to remove stamp/marker files whose corresponding Docker images no longer exist. - Refactors
kind-build-imagesinto a wrapper target that runs validation first, then invokes a sub-make (kind-build-images-run) so prerequisites are re-evaluated after any stamp removals.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib.Makefile |
Wraps kind image build in a validation + sub-make flow to ensure stale stamps don’t bypass rebuilds. |
hack/test/kind/validate_stamps.sh |
New script that maps stamp/marker files to Docker image refs and deletes stamps when images are missing. |
All callers (kind-up, kind-reload) already invoke kind-build-images with -j$(nproc), so the inner sub-make inherits the jobserver through MAKEFLAGS. Forcing -j again disconnects from the parent jobserver and emits a warning.
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.
If a Docker image gets pruned (or manually removed) while its Make stamp file remains,
kind-build-imagesthinks the image is up-to-date and skips the rebuild. This is a common footgun when iterating on kind clusters - youdocker system prune, thenmake kind-reloadsilently does nothing because the stamps still exist.This adds a
validate_stamps.shscript that runs before the build. It checks each stamp's corresponding Docker image and removes the stamp if the image is gone, so the subsequent Make invocation correctly rebuilds the missing images.