24
24
NO_RESPONSE_ERROR_MESSAGE = "Failed request with no response"
25
25
CONNECTION_ERROR_MESSAGE = "Failed request due to connection failure"
26
26
NOT_READY_ERROR_MESSAGE = "GitHub runner manager service not ready"
27
+ # For request that modifies the runner, GitHub runner manager service might need to wait for
28
+ # reconcile to finish before processing the request, hence the long timeout for write-level
29
+ # requests.
30
+ WRITE_TIMEOUT = 60 * 20
31
+ READ_TIMEOUT = 60 * 5
27
32
28
33
29
34
def catch_requests_errors (func : Callable ) -> Callable :
@@ -124,7 +129,7 @@ def check_runner(self) -> dict[str, str]:
124
129
The information on the runners.
125
130
"""
126
131
self .wait_till_ready ()
127
- response = self ._request (_HTTPMethod .GET , "/runner/check" , timeout = 600 )
132
+ response = self ._request (_HTTPMethod .GET , "/runner/check" , timeout = READ_TIMEOUT )
128
133
runner_info = json .loads (response .text )
129
134
runner_info ["runners" ] = tuple (runner_info ["runners" ])
130
135
runner_info ["busy_runners" ] = tuple (runner_info ["busy_runners" ])
@@ -140,7 +145,7 @@ def flush_runner(self, busy: bool = False) -> None:
140
145
"""
141
146
self .wait_till_ready ()
142
147
params = {"flush-busy" : str (busy )}
143
- self ._request (_HTTPMethod .POST , "/runner/flush" , params = params , timeout = 600 )
148
+ self ._request (_HTTPMethod .POST , "/runner/flush" , params = params , timeout = WRITE_TIMEOUT )
144
149
145
150
def health_check (self ) -> None :
146
151
"""Request a health check on the runner manager service.
@@ -153,7 +158,7 @@ def health_check(self) -> None:
153
158
API requests.
154
159
"""
155
160
try :
156
- response = self ._request (_HTTPMethod .GET , "/health" , timeout = 60 )
161
+ response = self ._request (_HTTPMethod .GET , "/health" , timeout = READ_TIMEOUT )
157
162
except requests .HTTPError as err :
158
163
raise RunnerManagerServiceNotReadyError (NOT_READY_ERROR_MESSAGE ) from err
159
164
except requests .ConnectionError as err :
0 commit comments