Implement shared idempotency, health-aware balancing and replica lifecycle checks
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
wanted = int(sys.argv[1])
|
||||
url = "http://127.0.0.1:" + os.environ.get("PUBLIC_PORT", "8083") + "/health/ready"
|
||||
deadline = time.monotonic() + 40
|
||||
seen = set()
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=2) as response:
|
||||
seen.add(response.headers["X-Instance-Id"])
|
||||
if len(seen) >= wanted:
|
||||
break
|
||||
except (urllib.error.URLError, TimeoutError):
|
||||
seen.clear()
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
raise SystemExit("LB did not expose enough healthy replicas")
|
||||
Reference in New Issue
Block a user