@@ -238,6 +238,9 @@ def _start_containers(self, to_add):
238238 """Creates and starts containers via the scheduler"""
239239 create_threads = []
240240 start_threads = []
241+ if not to_add :
242+ # do nothing if we didn't request any containers
243+ return
241244 for c in to_add :
242245 create_threads .append (threading .Thread (target = c .create ))
243246 start_threads .append (threading .Thread (target = c .start ))
@@ -278,32 +281,7 @@ def deploy(self, user, release, initial=False):
278281 n .save ()
279282 new .append (n )
280283
281- # create new containers
282- threads = []
283- for c in new :
284- threads .append (threading .Thread (target = c .create ))
285- [t .start () for t in threads ]
286- [t .join () for t in threads ]
287-
288- # check for containers that failed to create
289- if len (new ) > 0 and set ([c .state for c in new ]) != set ([Container .CREATED ]):
290- err = 'aborting, failed to create some containers'
291- log_event (self , err , logging .ERROR )
292- self ._destroy_containers (new )
293- raise RuntimeError (err )
294-
295- # start new containers
296- threads = []
297- for c in new :
298- threads .append (threading .Thread (target = c .start ))
299- [t .start () for t in threads ]
300- [t .join () for t in threads ]
301-
302- # check for containers that didn't come up correctly
303- if len (new ) > 0 and set ([c .state for c in new ]) != set ([Container .UP ]):
304- # report the deploy error
305- err = 'warning, some containers failed to start'
306- log_event (self , err , logging .WARNING )
284+ self ._start_containers (new )
307285
308286 # destroy old containers
309287 if existing :
0 commit comments