From 5c8d62848fce778bbaf5f3990dbd242462a0e607 Mon Sep 17 00:00:00 2001 From: Satwik Sai Prakash Sahoo Date: Fri, 31 Jul 2026 06:14:22 +0530 Subject: [PATCH] ci: cache loaded image ID to prevent redundant SDK downloads 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 --- ci-automation/ci_automation_common.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ci-automation/ci_automation_common.sh b/ci-automation/ci_automation_common.sh index 1ded3d1e36f..d7e22c12b04 100644 --- a/ci-automation/ci_automation_common.sh +++ b/ci-automation/ci_automation_common.sh @@ -235,6 +235,17 @@ function docker_image_from_buildcache() { if [[ -n "${local_image}" ]] ; then local image_id="" image_id=$($docker image inspect "${local_image}" | jq -r '.[].Id' | sed 's/^sha256://') + + local local_id_file="${name}-${version}.local-id" + if [[ -f "${local_id_file}" ]] ; then + local cached_id="" + cached_id=$(cat "${local_id_file}") + if [[ "${image_id}" = "${cached_id}" ]] ; then + echo "Local image is up-to-date (cached ID match)" >&2 + return + fi + fi + local remote_id="" remote_id=$(curl --fail --silent --show-error --location --retry-delay 1 \ --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 \ @@ -270,6 +281,17 @@ function docker_image_from_buildcache() { zstd -d -c ${tgz} | $docker load rm "${tgz}" + + local loaded_image="" + if image_exists_locally "${name}" "${version}" ; then + loaded_image="${name}:${version}" + elif image_exists_locally "${CONTAINER_REGISTRY}/${name}" "${version}" ; then + loaded_image="${CONTAINER_REGISTRY}/${name}:${version}" + fi + if [[ -n "${loaded_image}" ]] ; then + local local_id_file="${name}-${version}.local-id" + $docker image inspect "${loaded_image}" | jq -r '.[].Id' | sed 's/^sha256://' > "${local_id_file}" + fi } # --