fix(lambda): stop rejecting a foreign-platform image the daemon cannot describe (#3357)

* fix(lambda): stop rejecting a foreign-platform image the daemon cannot describe

Docker 29 makes the containerd image store its default, and there an image
inspect answers for the index rather than the variant that will run: an empty Os
and Architecture while no other variant of the tag is local, and the host's
variant once one is. ImageCacheService compared that answer with the requested
platform and threw, so every container started for another architecture failed
with "Docker image does not match requested platform" even though the pull had
selected the right variant.

Drop that comparison. The daemon enforces the platform where it counts, choosing
the variant to pull and the variant to create the container from, so resolving
the reference only has to hand back an id.

The integration test verified the platform through the same inspect, so it now
runs the container and reads uname -m, falling back to inspect where the host
cannot run another architecture.

* test(docker): fall back to inspect when the foreign-platform container never reports

awaitStatusCode throws when its timeout expires, so a container that starts but
hangs failed the test instead of reaching the inspect fallback the method
documents. The wait now treats a failure the same way it treats a nonzero exit.

Reading the logs is diagnostic on that path, so it reports a failed read in the
text it returns rather than throwing, as the sibling Docker tests already do.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-09-10 12:10:08 -04:00
1 parent 34be181c0c
commit 570f975829
3 files changed
+148 -11

No files matched your search

@@ -63,7 +63,7 @@ public class ImageCacheService {
}
InspectImageResponse localImage = inspectLocalImage(imageUri);
if (matchesPlatform(localImage, requestedPlatform)) {
resolvedImage = resolvedImageReference(imageUri, requestedPlatform, localImage);
resolvedImage = resolvedImageReference(imageUri, localImage);
resolvedImages.put(imageKey, resolvedImage);
LOG.infov("Image already present locally, skipping pull: {0}", imageUri);
return resolvedImage;
@@ -79,8 +79,7 @@ public class ImageCacheService {
pullImage.exec(new PullImageResultCallback())
.awaitCompletion(5, TimeUnit.MINUTES);
});
resolvedImage = resolvedImageReference(imageUri, requestedPlatform,
inspectLocalImage(imageUri));
resolvedImage = resolvedImageReference(imageUri, inspectLocalImage(imageUri));
resolvedImages.put(imageKey, resolvedImage);
LOG.infov("Image pulled successfully: {0}", imageUri);
return resolvedImage;
@@ -198,11 +197,19 @@ public class ImageCacheService {
&& parts[1].equals(image.getArch());
}
private static String resolvedImageReference(String imageUri, String platform,
InspectImageResponse image) {
if (!matchesPlatform(image, platform)) {
throw new DockerClientException(
"Docker image does not match requested platform " + platform + ": " + imageUri);
/**
* Resolves the reference the container is created from. Inspecting the image cannot confirm
* the platform on Docker 29, whose containerd image store is the default: for an image whose
* platform is not the host's it answers with an empty Os and Architecture until another
* variant of the same tag is present, and with the host's variant once one is, because the
* tag and its id both name the index rather than the variant that will run. Neither answer
* says anything about the variant the daemon selected. The platform is enforced by the daemon
* itself at both points that matter, choosing the variant to pull and choosing the variant to
* create the container from, so this only has to hand back an id.
*/
private static String resolvedImageReference(String imageUri, InspectImageResponse image) {
if (image == null) {
throw new DockerClientException("Docker did not report the image: " + imageUri);
}
String imageId = image.getId();
if (imageId == null || imageId.isBlank()) {