Skip to content

Commit cf9d7da

Browse files
authored
Enable retries for readiness check (#38)
* Enable retries for health check. * Add maximum retries for health check. * Remove blocking wait for readiness request.
1 parent a15be01 commit cf9d7da

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

rayvens/core/common.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,18 @@ def get_run_mode(camel_mode, check_port):
4444
def _wait_for_ready_integration(mode, integration):
4545
server_address = mode.server_address(integration)
4646
health_check_address = f"{server_address}/q/health"
47+
48+
healthy_integration = False
49+
max_retries = 100
4750
while True:
48-
response = requests.get(health_check_address, timeout=(5, None))
51+
try:
52+
response = requests.get(health_check_address, timeout=(5, 5))
53+
except requests.exceptions.ConnectionError:
54+
time.sleep(1)
55+
max_retries -= 1
56+
if max_retries == 0:
57+
break
58+
continue
4959
json_response = json.loads(response.content)
5060
all_routes_are_up = True
5161
for check in json_response['checks']:
@@ -63,9 +73,12 @@ def _wait_for_ready_integration(mode, integration):
6373
route_index += 1
6474
route = f'route:route{route_index}'
6575
if all_routes_are_up:
76+
healthy_integration = True
6677
break
6778
time.sleep(1)
6879

80+
return healthy_integration
81+
6982

7083
# Wait for an integration to reach its running state and not only that but
7184
# also be in a state where it can immediately execute incoming requests.
@@ -84,9 +97,14 @@ def await_start(mode, integration):
8497
print('Integration did not start correctly.')
8598

8699
# Perform health check and wait for integration to be ready.
87-
_wait_for_ready_integration(mode, integration)
100+
healthy_integration = _wait_for_ready_integration(mode, integration)
101+
102+
if healthy_integration:
103+
print(f'Integration {integration.integration_name} is healthy.')
104+
return integration_is_running
88105

89-
return integration_is_running
106+
print(f'Integration {integration.integration_name} is not healthy.')
107+
return False
90108

91109

92110
@ray.remote(num_cpus=0)

rayvens/core/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def run(self):
9595
self.queue.put(line.strip())
9696
time.sleep(0.1)
9797

98-
print("[Log thread] Kamel command logging terminated.")
98+
print("[Logging thread] Kamel command logging terminated.")
9999

100100

101101
def print_log_from_queue(subprocess_name, queue, with_output):

0 commit comments

Comments
 (0)