From 27dc7bb0673fc713c9517136a53aba5ca64eda01 Mon Sep 17 00:00:00 2001 From: "Kseniya A. Mikhaljova" Date: Fri, 23 Aug 2024 10:30:00 +0400 Subject: [PATCH] Updating README and watch first sleep interval --- README.md | 21 +++++++++++++++++++++ src/pipeline_watchdog/run.py | 6 +++--- tests/test_run.py | 18 ++++++++++++------ 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 07ae88c..01c4d13 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,27 @@ The configuration file supports variable interpolation. You can use a path to an For more information, refer to the [OmegaConf documentation](https://omegaconf.readthedocs.io/en/2.3_branch/usage.html#variable-interpolation). +## Usage + +You can find the watchdog service image on: +* for x86: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-x86) +* for arm64: [GitHub Packages](https://github.com/insight-platform/PipelineWatchdog/pkgs/container/pipeline-watchdog-arm64) + +Configuration of a docker service might be as follows +```yaml + pipeline-watchdog: + image: ghcr.io/insight-platform/pipeline-watchdog-:main + restart: unless-stopped + network_mode: host + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./config.yml:/app/config.yml + environment: + - LOGLEVEL=INFO + - CONFIG_FILE_PATH=/app/config.yml +``` + + ## Sample The sample demonstrates how to start the watchdog service with an example pipeline to watch the buffer and restart the SDK client based on configuration and buffer state. diff --git a/src/pipeline_watchdog/run.py b/src/pipeline_watchdog/run.py index 1117ff3..8d3cf7f 100644 --- a/src/pipeline_watchdog/run.py +++ b/src/pipeline_watchdog/run.py @@ -89,7 +89,7 @@ async def process_action( async def watch_queue(docker_client: DockerClient, buffer: str, config: QueueConfig): - await asyncio.sleep(config.cooldown) + await asyncio.sleep(config.polling_interval) while True: content = await get_metrics(buffer) @@ -108,7 +108,7 @@ async def watch_queue(docker_client: DockerClient, buffer: str, config: QueueCon async def watch_egress(docker_client: DockerClient, buffer: str, config: FlowConfig): - await asyncio.sleep(config.cooldown) + await asyncio.sleep(config.polling_interval) while True: content = await get_metrics(buffer) @@ -128,7 +128,7 @@ async def watch_egress(docker_client: DockerClient, buffer: str, config: FlowCon async def watch_ingress(docker_client: DockerClient, buffer: str, config: FlowConfig): - await asyncio.sleep(config.cooldown) + await asyncio.sleep(config.polling_interval) while True: content = await get_metrics(buffer) diff --git a/tests/test_run.py b/tests/test_run.py index cc353c2..81b11fb 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -291,7 +291,10 @@ async def test_watch_queue( await watch_queue(docker_client, watch_config.buffer, watch_config.queue) except asyncio.CancelledError: sleep_mock.assert_has_awaits( - [call(watch_config.queue.cooldown), call(watch_config.queue.cooldown)] + [ + call(watch_config.queue.polling_interval), + call(watch_config.queue.cooldown), + ] ) pass @@ -324,7 +327,7 @@ async def test_watch_queue_empty( except asyncio.CancelledError: sleep_mock.assert_has_awaits( [ - call(watch_config.queue.cooldown), + call(watch_config.queue.polling_interval), call(watch_config.queue.polling_interval), ] ) @@ -359,7 +362,10 @@ async def test_watch_egress( await watch_egress(docker_client, watch_config.buffer, watch_config.egress) except asyncio.CancelledError: sleep_mock.assert_has_awaits( - [call(watch_config.egress.cooldown), call(watch_config.egress.cooldown)] + [ + call(watch_config.egress.polling_interval), + call(watch_config.egress.cooldown), + ] ) pass @@ -395,7 +401,7 @@ async def test_watch_egress_message_just_sent( except asyncio.CancelledError: sleep_mock.assert_has_awaits( [ - call(watch_config.egress.cooldown), + call(watch_config.egress.polling_interval), call(watch_config.egress.polling_interval), ] ) @@ -433,7 +439,7 @@ async def test_watch_ingress( except asyncio.CancelledError: sleep_mock.assert_has_awaits( [ - call(watch_config.ingress.cooldown), + call(watch_config.ingress.polling_interval), call(watch_config.ingress.cooldown), ] ) @@ -475,7 +481,7 @@ async def test_watch_ingress_message_just_received( except asyncio.CancelledError: sleep_mock.assert_has_awaits( [ - call(watch_config.ingress.cooldown), + call(watch_config.ingress.polling_interval), call(watch_config.ingress.polling_interval), ] )