Skip to content

Commit

Permalink
Always pass explicit architecture of installed add-ons (#4786)
Browse files Browse the repository at this point in the history
* Pass architecture of installed add-on on update

When using multi-architecture container images, the architecture of the
add-on is not passed to Docker in all cases. This causes the
architecture of the Supervisor container to be used, which potentially
is not supported by the add-on in question.

This commit passes the architecture of the add-on to Docker, so that
the correct image is pulled.

* Call update with architecture

* Also pass architecture on add-on restore

* Fix pytest
  • Loading branch information
agners authored Dec 21, 2023
1 parent 3cc6bd1 commit 3e760f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions supervisor/addons/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ async def update(self) -> asyncio.Task | None:
store = self.addon_store.clone()

try:
await self.instance.update(store.version, store.image)
await self.instance.update(store.version, store.image, arch=self.arch)
except DockerError as err:
raise AddonsError() from err

Expand Down Expand Up @@ -1209,12 +1209,14 @@ def _extract_tarfile():
await self.instance.import_image(image_file)
else:
with suppress(DockerError):
await self.instance.install(version, restore_image)
await self.instance.install(
version, restore_image, self.arch
)
await self.instance.cleanup()
elif self.instance.version != version or self.legacy:
_LOGGER.info("Restore/Update of image for addon %s", self.slug)
with suppress(DockerError):
await self.instance.update(version, restore_image)
await self.instance.update(version, restore_image, self.arch)
self._check_ingress_port()

# Restore data and config
Expand Down
12 changes: 10 additions & 2 deletions supervisor/docker/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,11 @@ async def run(self) -> None:
on_condition=DockerJobError,
)
async def update(
self, version: AwesomeVersion, image: str | None = None, latest: bool = False
self,
version: AwesomeVersion,
image: str | None = None,
latest: bool = False,
arch: CpuArch | None = None,
) -> None:
"""Update a docker image."""
image = image or self.image
Expand All @@ -613,7 +617,11 @@ async def update(

# Update docker image
await self.install(
version, image=image, latest=latest, need_build=self.addon.latest_need_build
version,
image=image,
latest=latest,
arch=arch,
need_build=self.addon.latest_need_build,
)

@Job(
Expand Down
2 changes: 1 addition & 1 deletion tests/addons/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def test_image_added_removed_on_update(
await coresys.addons.update(TEST_ADDON_SLUG)
build.assert_not_called()
install.assert_called_once_with(
AwesomeVersion("10.0.0"), "test/amd64-my-ssh-addon", False, None
AwesomeVersion("10.0.0"), "test/amd64-my-ssh-addon", False, "amd64"
)

assert install_addon_ssh.need_update is False
Expand Down

0 comments on commit 3e760f0

Please sign in to comment.