@@ -171,7 +171,7 @@ def scale(self, namespace, name, image, entrypoint, command, **kwargs):
171171 kwargs ['previous_replicas' ] = current
172172 self .wait_until_ready (namespace , name , ** kwargs )
173173
174- def in_progress (self , namespace , name , deploy_timeout , batches , replicas , tags ):
174+ def in_progress (self , namespace , name , timeout , batches , replicas , tags ):
175175 """
176176 Determine if a Deployment has a deploy in progress
177177
@@ -207,7 +207,7 @@ def in_progress(self, namespace, name, deploy_timeout, batches, replicas, tags):
207207 containers = deployment ['spec' ]['template' ]['spec' ]['containers' ]
208208
209209 # calculate base deploy timeout
210- deploy_timeout = self ._deploy_probe_timeout ( deploy_timeout , namespace , labels , containers )
210+ deploy_timeout = self .pod . deploy_probe_timeout ( timeout , namespace , labels , containers )
211211
212212 # a rough calculation that figures out an overall timeout
213213 steps = self ._get_deploy_steps (batches , tags )
@@ -304,7 +304,7 @@ def wait_until_ready(self, namespace, name, **kwargs):
304304
305305 current = int (kwargs .get ('previous_replicas' , 0 ))
306306 batches = kwargs .get ('deploy_batches' , None )
307- deploy_timeout = kwargs .get ('deploy_timeout' , 120 )
307+ timeout = kwargs .get ('deploy_timeout' , 120 )
308308 tags = kwargs .get ('tags' , {})
309309 steps = self ._get_deploy_steps (batches , tags )
310310 batches = self ._get_deploy_batches (steps , replicas )
@@ -320,7 +320,7 @@ def wait_until_ready(self, namespace, name, **kwargs):
320320 return
321321
322322 # calculate base deploy timeout
323- deploy_timeout = self ._deploy_probe_timeout ( deploy_timeout , namespace , labels , containers )
323+ deploy_timeout = self .pod . deploy_probe_timeout ( timeout , namespace , labels , containers )
324324
325325 # a rough calculation that figures out an overall timeout
326326 timeout = len (batches ) * deploy_timeout
@@ -351,3 +351,26 @@ def wait_until_ready(self, namespace, name, **kwargs):
351351 ready , _ = self .are_replicas_ready (namespace , name )
352352 if not ready :
353353 self .pod ._handle_not_ready_pods (namespace , labels )
354+
355+ def _get_deploy_steps (self , batches , tags ):
356+ # if there is no batch information available default to available nodes for app
357+ if not batches :
358+ # figure out how many nodes the application can go on
359+ steps = len (self .node .get (labels = tags ).json ()['items' ])
360+ else :
361+ steps = int (batches )
362+
363+ return steps
364+
365+ def _get_deploy_batches (self , steps , desired ):
366+ # figure out what kind of batches the deploy is done in - 1 in, 1 out or higher
367+ if desired < steps :
368+ # do it all in one go
369+ batches = [desired ]
370+ else :
371+ # figure out the stepped deploy count and then see if there is a leftover
372+ batches = [steps for n in set (range (1 , (desired + 1 ))) if n % steps == 0 ]
373+ if desired - sum (batches ) > 0 :
374+ batches .append (desired - sum (batches ))
375+
376+ return batches
0 commit comments