@@ -123,6 +123,24 @@ def _get_command(self, container_type):
123123 # handle special case for Dockerfile deployments
124124 return '' if container_type == 'cmd' else 'start {}' .format (container_type )
125125
126+ def _get_command_run (self , command ):
127+ # SECURITY: shell-escape user input
128+ command = command .replace ("'" , "'\\ ''" )
129+
130+ # if this is a procfile-based app, switch the entrypoint to slugrunner's default
131+ # FIXME: remove slugrunner's hardcoded entrypoint
132+ release = self .release_set .latest ()
133+ if release .build .procfile and \
134+ release .build .sha and not \
135+ release .build .dockerfile :
136+ entrypoint = '/runner/init'
137+ command = "'{}'" .format (command )
138+ else :
139+ entrypoint = '/bin/bash'
140+ command = "-c '{}'" .format (command )
141+
142+ return entrypoint , command
143+
126144 def log (self , message , level = logging .INFO ):
127145 """Logs a message in the context of this application.
128146
@@ -555,35 +573,22 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
555573 raise DeisException ('No build associated with this release to run this command' )
556574
557575 # TODO: add support for interactive shell
558- # SECURITY: shell-escape user input
559- command = command .replace ("'" , "'\\ ''" )
560-
561- # if this is a procfile-based app, switch the entrypoint to slugrunner's default
562- # FIXME: remove slugrunner's hardcoded entrypoint
563- if release .build .procfile and \
564- release .build .sha and not \
565- release .build .dockerfile :
566- entrypoint = '/runner/init'
567- command = "'{}'" .format (command )
568- else :
569- entrypoint = '/bin/bash'
570- command = "-c '{}'" .format (command )
576+ entrypoint , command = self ._get_command_run (command )
571577
572578 name = self ._get_job_id ('run' ) + '-' + pod_name ()
573-
574- msg = "{} on {} runs '{}'" .format (user .username , name , command )
575- log_event (self , msg )
579+ log_event (self , "{} on {} runs '{}'" .format (user .username , name , command ))
576580
577581 kwargs = {
578582 'memory' : release .config .memory ,
579583 'cpu' : release .config .cpu ,
580584 'tags' : release .config .tags ,
581585 'envs' : release .config .values ,
582586 'version' : "v{}" .format (release .version ),
587+ 'build_type' : release .build .type ,
583588 }
584589
585590 try :
586- rc , output = self ._scheduler .run (
591+ exit_code , output = self ._scheduler .run (
587592 self .id ,
588593 name ,
589594 release .image ,
@@ -592,7 +597,7 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
592597 ** kwargs
593598 )
594599
595- return rc , output
600+ return exit_code , output
596601 except Exception as e :
597602 err = '{} (run): {}' .format (name , e )
598603 log_event (self , err , logging .ERROR )
@@ -615,7 +620,7 @@ def list_pods(self, *args, **kwargs):
615620 if p ['metadata' ]['labels' ]['type' ] == 'run' :
616621 continue
617622
618- state = self ._scheduler .resolve_state (p )
623+ state = self ._scheduler ._pod_state (p ). name
619624
620625 # follows kubelete convention - these are hidden unless show-all is set
621626 if state in ['down' , 'crashed' ]:
0 commit comments