@@ -172,7 +172,7 @@ def create(self, *args, **kwargs):
172172
173173 def delete (self , * args , ** kwargs ):
174174 """Delete this application including all containers"""
175- for c in self .container_set .all ( ):
175+ for c in self .container_set .exclude ( type = 'run' ):
176176 c .destroy ()
177177 self ._clean_app_logs ()
178178 return super (App , self ).delete (* args , ** kwargs )
@@ -344,31 +344,28 @@ def run(self, user, command):
344344 # TODO: add support for interactive shell
345345 msg = "{} runs '{}'" .format (user .username , command )
346346 log_event (self , msg )
347- c_num = max ([c .num for c in self .container_set .filter (type = 'admin' )] or [0 ]) + 1
348- try :
349- # create database record for admin process
350- c = Container .objects .create (owner = self .owner ,
351- app = self ,
352- release = self .release_set .latest (),
353- type = 'admin' ,
354- num = c_num )
355- image = c .release .image + ':v' + str (c .release .version )
356-
357- # check for backwards compatibility
358- def _has_hostname (image ):
359- repo , tag = utils .parse_repository_tag (image )
360- return True if '/' in repo and '.' in repo .split ('/' )[0 ] else False
361-
362- if not _has_hostname (image ):
363- image = '{}:{}/{}' .format (settings .REGISTRY_HOST ,
364- settings .REGISTRY_PORT ,
365- image )
366- # SECURITY: shell-escape user input
367- escaped_command = command .replace ("'" , "'\\ ''" )
368- return c .run (escaped_command )
369- # always cleanup admin containers
370- finally :
371- c .delete ()
347+ c_num = max ([c .num for c in self .container_set .filter (type = 'run' )] or [0 ]) + 1
348+
349+ # create database record for run process
350+ c = Container .objects .create (owner = self .owner ,
351+ app = self ,
352+ release = self .release_set .latest (),
353+ type = 'run' ,
354+ num = c_num )
355+ image = c .release .image + ':v' + str (c .release .version )
356+
357+ # check for backwards compatibility
358+ def _has_hostname (image ):
359+ repo , tag = utils .parse_repository_tag (image )
360+ return True if '/' in repo and '.' in repo .split ('/' )[0 ] else False
361+
362+ if not _has_hostname (image ):
363+ image = '{}:{}/{}' .format (settings .REGISTRY_HOST ,
364+ settings .REGISTRY_PORT ,
365+ image )
366+ # SECURITY: shell-escape user input
367+ escaped_command = command .replace ("'" , "'\\ ''" )
368+ return c .run (escaped_command )
372369
373370
374371@python_2_unicode_compatible
0 commit comments