@@ -766,8 +766,6 @@ def _wait_until_pods_are_ready(self, namespace, container, labels, desired): #
766766
767767 logger .info ("waiting for {} pods in {} namespace to be in services ({} timeout)" .format (desired , namespace , timeout )) # noqa
768768
769- # has timeout been increased or not within the loop
770- timeout_padded = False
771769 # Ensure the minimum desired number of pods are available
772770 while waited < timeout :
773771 count = 0 # ready pods
@@ -777,11 +775,7 @@ def _wait_until_pods_are_ready(self, namespace, container, labels, desired): #
777775 if pod ['status' ]['phase' ] == 'Pending' :
778776 reason , message = self ._pod_pending_status (pod )
779777 # If pulling an image is taking long then increase the timeout
780- if not timeout_padded :
781- pull = self ._handle_pod_long_image_pulling (pod , reason )
782- if pull :
783- timeout_padded = True
784- timeout += pull
778+ timeout += self ._handle_pod_long_image_pulling (pod , reason )
785779
786780 # handle errors and bubble up if need be
787781 self ._handle_pod_image_errors (pod , reason , message )
@@ -1411,6 +1405,10 @@ def _handle_pod_long_image_pulling(self, reason, pod):
14111405
14121406 Return value is an int that represents seconds
14131407 """
1408+ # only apply once
1409+ if getattr (self , '_handle_pod_long_image_pulling_applied' , False ):
1410+ return 0
1411+
14141412 if reason is not 'Pulling' :
14151413 return 0
14161414
@@ -1427,6 +1425,9 @@ def _handle_pod_long_image_pulling(self, reason, pod):
14271425 # add 10 minutes to timeout to allow a pull image operation to finish
14281426 logger .info ('Kubernetes has been pulling the image for {} seconds' .format (seconds )) # noqa
14291427 logger .info ('Increasing timeout by 10 minutes to allow a pull image operation to finish for pods in namespace {}' .format (namespace )) # noqa
1428+
1429+ # make it so function doesn't do processing again
1430+ setattr (self , '_handle_pod_long_image_pulling_applied' , True )
14301431 return 600
14311432
14321433 return 0
0 commit comments