mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-22 00:26:29 +00:00
Add jobs to docker supervisor and use group wait (#4520)
This commit is contained in:
parent
f30d21361f
commit
07c2178ae1
@ -334,11 +334,7 @@ class DockerInterface(JobGroup):
|
|||||||
|
|
||||||
return _container_state_from_model(docker_container)
|
return _container_state_from_model(docker_container)
|
||||||
|
|
||||||
@Job(
|
@Job(name="docker_interface_attach", limit=JobExecutionLimit.GROUP_WAIT)
|
||||||
name="docker_interface_attach",
|
|
||||||
limit=JobExecutionLimit.GROUP_ONCE,
|
|
||||||
on_condition=DockerJobError,
|
|
||||||
)
|
|
||||||
async def attach(
|
async def attach(
|
||||||
self, version: AwesomeVersion, *, skip_state_event_if_down: bool = False
|
self, version: AwesomeVersion, *, skip_state_event_if_down: bool = False
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -454,11 +450,7 @@ class DockerInterface(JobGroup):
|
|||||||
|
|
||||||
return b""
|
return b""
|
||||||
|
|
||||||
@Job(
|
@Job(name="docker_interface_cleanup", limit=JobExecutionLimit.GROUP_WAIT)
|
||||||
name="docker_interface_cleanup",
|
|
||||||
limit=JobExecutionLimit.GROUP_ONCE,
|
|
||||||
on_condition=DockerJobError,
|
|
||||||
)
|
|
||||||
def cleanup(self, old_image: str | None = None) -> Awaitable[None]:
|
def cleanup(self, old_image: str | None = None) -> Awaitable[None]:
|
||||||
"""Check if old version exists and cleanup."""
|
"""Check if old version exists and cleanup."""
|
||||||
return self.sys_run_in_executor(
|
return self.sys_run_in_executor(
|
||||||
|
@ -8,8 +8,7 @@ from awesomeversion.awesomeversion import AwesomeVersion
|
|||||||
import docker
|
import docker
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from ..coresys import CoreSysAttributes
|
from ..exceptions import DockerError
|
||||||
from ..exceptions import DockerError, DockerJobError
|
|
||||||
from ..jobs.const import JobExecutionLimit
|
from ..jobs.const import JobExecutionLimit
|
||||||
from ..jobs.decorator import Job
|
from ..jobs.decorator import Job
|
||||||
from .const import PropagationMode
|
from .const import PropagationMode
|
||||||
@ -18,7 +17,7 @@ from .interface import DockerInterface
|
|||||||
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
_LOGGER: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
class DockerSupervisor(DockerInterface):
|
||||||
"""Docker Supervisor wrapper for Supervisor."""
|
"""Docker Supervisor wrapper for Supervisor."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -45,11 +44,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|||||||
if mount.get("Destination") == "/data"
|
if mount.get("Destination") == "/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
@Job(
|
@Job(name="docker_supervisor_attach", limit=JobExecutionLimit.GROUP_WAIT)
|
||||||
name="docker_supervisor_attach",
|
|
||||||
limit=JobExecutionLimit.GROUP_ONCE,
|
|
||||||
on_condition=DockerJobError,
|
|
||||||
)
|
|
||||||
async def attach(
|
async def attach(
|
||||||
self, version: AwesomeVersion, *, skip_state_event_if_down: bool = False
|
self, version: AwesomeVersion, *, skip_state_event_if_down: bool = False
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -81,6 +76,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|||||||
ipv4=self.sys_docker.network.supervisor,
|
ipv4=self.sys_docker.network.supervisor,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Job(name="docker_supervisor_retag", limit=JobExecutionLimit.GROUP_WAIT)
|
||||||
def retag(self) -> Awaitable[None]:
|
def retag(self) -> Awaitable[None]:
|
||||||
"""Retag latest image to version."""
|
"""Retag latest image to version."""
|
||||||
return self.sys_run_in_executor(self._retag)
|
return self.sys_run_in_executor(self._retag)
|
||||||
@ -100,6 +96,7 @@ class DockerSupervisor(DockerInterface, CoreSysAttributes):
|
|||||||
f"Can't retag Supervisor version: {err}", _LOGGER.error
|
f"Can't retag Supervisor version: {err}", _LOGGER.error
|
||||||
) from err
|
) from err
|
||||||
|
|
||||||
|
@Job(name="docker_supervisor_update_start_tag", limit=JobExecutionLimit.GROUP_WAIT)
|
||||||
def update_start_tag(self, image: str, version: AwesomeVersion) -> Awaitable[None]:
|
def update_start_tag(self, image: str, version: AwesomeVersion) -> Awaitable[None]:
|
||||||
"""Update start tag to new version."""
|
"""Update start tag to new version."""
|
||||||
return self.sys_run_in_executor(self._update_start_tag, image, version)
|
return self.sys_run_in_executor(self._update_start_tag, image, version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user