ci: cache loaded image ID to prevent redundant SDK downloads - #4171
Open
satwiksps wants to merge 1 commit into
Open
ci: cache loaded image ID to prevent redundant SDK downloads#4171satwiksps wants to merge 1 commit into
satwiksps wants to merge 1 commit into
Conversation
The remote .id file on bincache is generated from `docker image inspect` during CI at build time but `docker save` followed by `docker load` on a different Docker daemon produce a different image ID for the same image content. This causes `docker_image_from_buildcache()` to consider locally loaded image as "outdated" every invocation, triggering redundant multi-GB tarball download each time `run_sdk_container -t` is run. Caching the actual image ID produced by `docker load` into a local `.local-id` file. On subsequent runs, compare against the cached ID first before falling back to the remote .id file. Fixes flatcar/Flatcar#2086 Signed-off-by: Satwik Sai Prakash Sahoo <sahoospsatwik@gmail.com>
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.
docker_image_from_buildcache()compares the local image ID against the.idfile hosted onbincache.flatcar-linux.net, this.idfile is generated at build time fromdocker image inspectin CI. But adocker save/docker loadround-trip can produce a different image ID on the consumer's Docker daemon (e.g., due to different Docker versions or storage drivers between CI and the developer's machine). So the ID comparison always fails, andrun_sdk_container -tre-downloads the multi-GB SDK tarball on every single invocation even when the local image is perfectly valid.what I did in this PR is after a successful
docker load, cache the actual loaded image ID to a local<name>-<version>.local-idfile. on subsequent runs,docker_image_from_buildcache()checks this local cache first, if current image ID matches the cached ID, the image is considered up-to-date and the download is skipped. existing remote.idcomparison is preserved as a fallback for environments where the save/load round-trip is stable like when CI and the developer use the same Docker version