#!/usr/bin/env python3 import os import time import urllib.request base = os.getenv('BASE_URL', 'http://localhost:8080') seen = set() for _ in range(180): try: with urllib.request.urlopen(base+'/health/ready', timeout=2) as r: seen.add(r.headers['X-Instance-Id']) if len(seen)>=2: print('Ready: two API instances through LB:', ', '.join(sorted(seen))) break except Exception: pass time.sleep(.5) else: raise SystemExit('Two ready instances not observed in readiness deadline')