ci: stop re-downloading SDK images after docker load - #4171
Conversation
Do you have any more concrete evidences? <.id> is used to verify the image integrity, if the <.id> is untrustable, I'd like to choose another method |
|
@zhijianli88 We are currently experiencing a lot of AI contributions, if you see anything like that just close it |
|
@zhijianli88 @John15321 this is documented upstream behavior: moby/moby#51934. Also this PR was purely from my own knowledge, though could be wrong, I have not used any AI 🙂 |
Make sense. However, the .id is used to ensure image integrity and your patch doesn't address this critical aspect |
5c8d628 to
d23cfd0
Compare
docker_image_from_buildcache() compares the local image ID against the .id file published in the buildcache. docker load derives its own image ID though, and it only matches the published one when both daemons use the same storage driver. Where they differ the comparison never succeeds, so every run_sdk_container -t invocation pulls the multi-GB tarball again even though the local image is fine. Remember which published ID the local image was loaded from and compare against that. The published .id is still fetched on every run, so an image rebuilt in the buildcache is still picked up, and the recorded local ID keeps a locally replaced image from passing as the loaded one. Fixes flatcar/Flatcar#2086 Signed-off-by: Satwik Sai Prakash Sahoo <sahoospsatwik@gmail.com>
d23cfd0 to
cc24ffc
Compare
My prev approach cached the loaded ID locally and returned early on it. I understood that once a local copy existed, the remote .id was never looked at again. Rebuilt image on bincache would have gone unnoticed In my second approach the remote .id is fetched on every run again and stays what we compare against. After a load I record two values in -.id.local, the published ID we loaded from & the ID our own daemon gave the image. it only treated as current when both still match, so the published ID still has to agree (no silent rebuild slips through) and the local ID catches the image being replaced underneath us. image_id == remote_id still runs first, so nothing changes where the IDs already line up. Only assumption dropped is that docker load reproduces the ID docker image inspect printed in CI, which is the part that doesn't hold across storage drivers. I hope this covers the integrity side properly now |
docker_image_from_buildcache()decides whether the local SDK image is current by comparing its image ID against the.idfile on bincache. that.idcomes fromdocker image inspectin CI, butdocker loadderives its own image ID on the consumer side and only matches when both daemons use the same storage driver. where they differ the check never passes, andrun_sdk_containerre-downloads the multi-GB tarball every time it creates a container.The earlier version of this PR cached the loaded ID locally and returned early on it, which skipped the remote
.identirely and would have missed a rebuilt image, so that's gone.The remote
.idis now fetched on every run and stays what we compare against. after a load,<name>-<version>.id.localrecords the published ID we loaded from plus the ID our own daemon assigned to the image. It only counts as current when both still match, published ID unchanged means bincache hasn't rebuilt it, local ID unchanged means nothing replaced it locally. the directimage_id == remote_idcomparison still runs first, so daemons where the IDs do line up are unaffected, and with no stamp file present the behaviour is what it is today.*.id.localis added gitignored sincerun_sdk_containerruns from the repo root.