1212from tornado .ioloop import IOLoop
1313from tornado .log import app_log
1414
15- from .utils import rendezvous_rank
15+ from .utils import rendezvous_rank , KUBE_REQUEST_TIMEOUT
1616
1717
1818class Build :
@@ -186,6 +186,7 @@ def get_affinity(self):
186186 dind_pods = self .api .list_namespaced_pod (
187187 self .namespace ,
188188 label_selector = "component=dind,app=binder" ,
189+ _request_timeout = KUBE_REQUEST_TIMEOUT ,
189190 )
190191
191192 if self .sticky_builds and dind_pods :
@@ -304,7 +305,11 @@ def submit(self):
304305 )
305306
306307 try :
307- ret = self .api .create_namespaced_pod (self .namespace , self .pod )
308+ ret = self .api .create_namespaced_pod (
309+ self .namespace ,
310+ self .pod ,
311+ _request_timeout = KUBE_REQUEST_TIMEOUT ,
312+ )
308313 except client .rest .ApiException as e :
309314 if e .status == 409 :
310315 # Someone else created it!
@@ -320,10 +325,11 @@ def submit(self):
320325 w = watch .Watch ()
321326 try :
322327 for f in w .stream (
323- self .api .list_namespaced_pod ,
324- self .namespace ,
325- label_selector = "name={}" .format (self .name ),
326- timeout_seconds = 30 ,
328+ self .api .list_namespaced_pod ,
329+ self .namespace ,
330+ label_selector = "name={}" .format (self .name ),
331+ timeout_seconds = 30 ,
332+ _request_timeout = KUBE_REQUEST_TIMEOUT ,
327333 ):
328334 if f ['type' ] == 'DELETED' :
329335 self .progress ('pod.phasechange' , 'Deleted' )
@@ -348,11 +354,13 @@ def stream_logs(self):
348354 """Stream a pod's logs"""
349355 app_log .info ("Watching logs of %s" , self .name )
350356 for line in self .api .read_namespaced_pod_log (
351- self .name ,
352- self .namespace ,
353- follow = True ,
354- tail_lines = self .log_tail_lines ,
355- _preload_content = False ):
357+ self .name ,
358+ self .namespace ,
359+ follow = True ,
360+ tail_lines = self .log_tail_lines ,
361+ _request_timeout = (3 , None ),
362+ _preload_content = False ,
363+ ):
356364 if self .stop_event .is_set ():
357365 app_log .info ("Stopping logs of %s" , self .name )
358366 return
@@ -382,7 +390,9 @@ def cleanup(self):
382390 self .api .delete_namespaced_pod (
383391 name = self .name ,
384392 namespace = self .namespace ,
385- body = client .V1DeleteOptions (grace_period_seconds = 0 ))
393+ body = client .V1DeleteOptions (grace_period_seconds = 0 ),
394+ _request_timeout = KUBE_REQUEST_TIMEOUT ,
395+ )
386396 except client .rest .ApiException as e :
387397 if e .status == 404 :
388398 # Is ok, someone else has already deleted it
0 commit comments