def condition(): sys.stderr.write("Waiting for SQLServer to boot...\n") booted = False for _ in xrange(10): try: pyodbc.connect(conn, timeout=30) booted = True except pyodbc.Error as e: sys.stderr.write(str(e) + '\n') time.sleep(3) if not booted: raise RetryError("SQLServer failed to boot!") sys.stderr.write("SQLServer boot complete.\n")
def condition(): sys.stderr.write("Waiting for ZK to boot...\n") booted = False for _ in xrange(3): try: out = ZookeeperCheck._send_command('ruok', HOST, PORT, 500) out.seek(0) if out.readline() != 'imok': raise ZKConnectionFailure() booted = True except ZKConnectionFailure: time.sleep(1) if not booted: raise RetryError("Zookeeper failed to boot!") sys.stderr.write("ZK boot complete.\n")
def condition(): sys.stderr.write("Waiting for CoreDNS to boot...") booted = False for _ in xrange(10): try: res = requests.get(URL) # create some metrics by using dig subprocess.check_call(DIG_ARGS, env=env) res.raise_for_status() booted = True break except Exception: time.sleep(1) if not booted: raise RetryError("CoreDNS failed to boot!") sys.stderr.write("CoreDNS boot complete.\n")
def condition_non_tls(): sys.stderr.write("Waiting for ZK to boot...\n") booted = False dummy_instance = {'host': HOST, 'port': PORT, 'timeout': 500} for _ in range(10): try: out = ZookeeperCheck('zk', {}, [dummy_instance])._send_command('ruok') out.seek(0) if out.readline() != 'imok': raise ZKConnectionFailure() booted = True break except ZKConnectionFailure: time.sleep(1) if not booted: raise RetryError("Zookeeper failed to boot!") sys.stderr.write("ZK boot complete.\n")
def __call__(self): """Wait for the slave to connect to the master""" master = redis.Redis(**self.master_data) replica = redis.Redis(**self.replica_data) for _ in range(self.attempts): try: if (master.ping() and replica.ping() and master.info().get('connected_slaves') and replica.info().get('master_link_status') != 'down'): break except redis.ConnectionError: pass time.sleep(self.wait) else: raise RetryError('Redis cluster boot timed out!\n' 'Master: {}\n' 'Replica: {}'.format(master, replica))