From 94d00b4c450391b655d38d7b58e63c565414306e Mon Sep 17 00:00:00 2001 From: Lu Baumann Date: Sun, 29 Sep 2024 20:11:53 +0000 Subject: [PATCH] added healthcheck ping retry logic --- docker-healthcheck.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker-healthcheck.py b/docker-healthcheck.py index b046567..5b71c57 100644 --- a/docker-healthcheck.py +++ b/docker-healthcheck.py @@ -29,7 +29,11 @@ def main() -> None: container = client.containers.get(container_id) container_status = container.attrs["State"]["Status"] if container_status in ["healthy", "running"]: - requests.post(checks[container_id]) + retry_count = 0 + while requests.post(checks[container_id]).content != b'OK': + if retry_count > 10: + print(f"error posting to '{container_id}' with url '{checks[container_id]}'") + retry_count += 1 else: requests.post( checks[container_id] + "/fail",