Fix container image detection for aarch64 (#5898)

This commit is contained in:
Stefan Agner 2025-05-20 10:24:27 +02:00 committed by GitHub
parent 2eb9ec20d6
commit bac7c21fe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -455,11 +455,11 @@ class DockerInterface(JobGroup, ABC):
self, self,
version: AwesomeVersion, version: AwesomeVersion,
expected_image: str, expected_image: str,
expected_arch: CpuArch | None = None, expected_cpu_arch: CpuArch | None = None,
) -> None: ) -> None:
"""Check we have expected image with correct arch.""" """Check we have expected image with correct arch."""
expected_image_arch = ( expected_image_cpu_arch = (
str(expected_arch) if expected_arch else self.sys_arch.supervisor str(expected_cpu_arch) if expected_cpu_arch else self.sys_arch.supervisor
) )
image_name = f"{expected_image}:{version!s}" image_name = f"{expected_image}:{version!s}"
if self.image == expected_image: if self.image == expected_image:
@ -478,13 +478,22 @@ class DockerInterface(JobGroup, ABC):
image_arch = f"{image_arch}/{image.attrs['Variant']}" image_arch = f"{image_arch}/{image.attrs['Variant']}"
# If we have an image and its the right arch, all set # If we have an image and its the right arch, all set
if MAP_ARCH[expected_image_arch] == image_arch: # It seems that newer Docker version return a variant for arm64 images.
# Make sure we match linux/arm64 and linux/arm64/v8.
expected_image_arch = MAP_ARCH[expected_image_cpu_arch]
if image_arch.startswith(expected_image_arch):
return return
_LOGGER.info(
"Image %s has arch %s, expected %s. Reinstalling.",
image_name,
image_arch,
expected_image_arch,
)
# We're missing the image we need. Stop and clean up what we have then pull the right one # We're missing the image we need. Stop and clean up what we have then pull the right one
with suppress(DockerError): with suppress(DockerError):
await self.remove() await self.remove()
await self.install(version, expected_image, arch=expected_image_arch) await self.install(version, expected_image, arch=expected_image_cpu_arch)
@Job( @Job(
name="docker_interface_update", name="docker_interface_update",