added healthcheck ping retry logic

This commit is contained in:
Lu Baumann 2024-09-29 20:11:53 +00:00
parent af88f9de6e
commit 94d00b4c45

View File

@ -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",