Service restart

Signed-off-by: Vladislav Karakozov <v.karakozov@yadro.com>
support/v0.36
Vladislav Karakozov 2023-02-07 13:13:57 +03:00 committed by Vlad K
parent 469ab4db43
commit 11d65091ad
4 changed files with 24 additions and 4 deletions

View File

@ -5,7 +5,7 @@ repos:
- id: black
language_version: python3.9
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)

View File

@ -9,7 +9,7 @@ requests==2.28.1
# Dev dependencies
black==22.8.0
bumpver==2022.1118
isort==5.10.1
isort==5.12.0
pre-commit==2.20.0
# Packaging dependencies

View File

@ -54,8 +54,8 @@ class ServiceAttributes(ParsedAttributes):
container_name: str
volume_name: Optional[str] = None
start_timeout: int = 60
stop_timeout: int = 60
start_timeout: int = 90
stop_timeout: int = 90
class DockerHost(Host):
@ -117,6 +117,18 @@ class DockerHost(Host):
timeout=service_attributes.stop_timeout,
)
def restart_service(self, service_name: str) -> None:
service_attributes = self._get_service_attributes(service_name)
client = self._get_docker_client()
client.restart(service_attributes.container_name)
self._wait_for_container_to_be_in_state(
container_name=service_attributes.container_name,
expected_state="running",
timeout=service_attributes.start_timeout,
)
def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None:
service_attributes = self._get_service_attributes(service_name)

View File

@ -104,6 +104,14 @@ class Host(ABC):
service_name: Name of the service to stop.
"""
@abstractmethod
def restart_service(self, service_name: str) -> None:
"""Restarts the service with specified name and waits until it starts.
The service must be hosted on this host.
Args:
service_name: Name of the service to restart.
"""
@abstractmethod
def delete_storage_node_data(self, service_name: str, cache_only: bool = False) -> None:
"""Erases all data of the storage node with specified name.