Supervisor image handler (#2757)

This commit is contained in:
Pascal Vizeli 2021-03-26 15:21:54 +01:00 committed by GitHub
parent 900b785789
commit 98f8e032e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 3 deletions

View File

@ -14,6 +14,7 @@ from .const import (
ATTR_DEBUG_BLOCK,
ATTR_DIAGNOSTICS,
ATTR_FORCE_SECURITY,
ATTR_IMAGE,
ATTR_LAST_BOOT,
ATTR_LOGGING,
ATTR_TIMEZONE,
@ -69,14 +70,24 @@ class CoreConfig(FileConfiguration):
@property
def version(self) -> AwesomeVersion:
"""Return config version."""
"""Return supervisor version."""
return self._data[ATTR_VERSION]
@version.setter
def version(self, value: AwesomeVersion) -> None:
"""Set config version."""
"""Set supervisor version."""
self._data[ATTR_VERSION] = value
@property
def image(self) -> Optional[str]:
"""Return supervisor image."""
return self._data.get(ATTR_IMAGE)
@image.setter
def image(self, value: str) -> None:
"""Set supervisor image."""
self._data[ATTR_IMAGE] = value
@property
def wait_boot(self) -> int:
"""Return wait time for auto boot stages."""

View File

@ -467,6 +467,9 @@ class DockerInterface(CoreSysAttributes):
raise DockerError() from err
for image in images_list:
if origin.id == image.id:
continue
with suppress(docker.errors.DockerException, requests.RequestException):
_LOGGER.info("Cleanup images: %s", image.tags)
self.sys_docker.images.remove(image.id, force=True)

View File

@ -102,6 +102,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
if start_tag != "latest":
continue
docker_image.tag(start_image, start_tag)
docker_image.tag(start_image, version.string)
except (docker.errors.DockerException, requests.RequestException) as err:
_LOGGER.error("Can't fix start tag: %s", err)

View File

@ -46,7 +46,7 @@ class Supervisor(CoreSysAttributes):
_LOGGER.critical("Can't setup Supervisor Docker container!")
with suppress(DockerError):
await self.instance.cleanup()
await self.instance.cleanup(old_image=self.sys_config.image)
@property
def connectivity(self) -> bool:
@ -161,6 +161,7 @@ class Supervisor(CoreSysAttributes):
raise SupervisorUpdateError() from err
else:
self.sys_config.version = version
self.sys_config.image = self.sys_updater.image_supervisor
self.sys_config.save_data()
self.sys_create_task(self.sys_core.stop())

View File

@ -140,6 +140,7 @@ SCHEMA_SUPERVISOR_CONFIG = vol.Schema(
vol.Optional(
ATTR_VERSION, default=AwesomeVersion(SUPERVISOR_VERSION)
): version_tag,
vol.Optional(ATTR_IMAGE): docker_image,
vol.Optional(
ATTR_ADDONS_CUSTOM_LIST,
default=["https://github.com/hassio-addons/repository"],