@@ -122,48 +122,37 @@ def types(self):
122122 def _get_command (self , container_type ):
123123 """
124124 Return the kubernetes "container arguments" to be sent off to the scheduler.
125-
126- In reality this is the command that the user it attempting to run.
127125 """
128- try :
129- # FIXME: remove slugrunner's hardcoded entrypoint
130- release = self . release_set . filter ( failed = False ). latest ()
126+ release = self . release_set . filter ( failed = False ). latest ()
127+ if release is not None and release . build is not None :
128+ # dockerfile or container image
131129 if release .build .dockerfile or not release .build .sha :
132- cmd = release .build .procfile [container_type ]
133- # if the entrypoint is `/bin/bash -c`, we want to supply the list
134- # as a script. Otherwise, we want to send it as a list of arguments.
135- if self ._get_entrypoint (container_type ) == ['/bin/bash' , '-c' ]:
136- return [cmd ]
137- else :
138- return cmd .split ()
139-
140- return ['start' , container_type ]
141- # if the key is not present or if a parent attribute is None
142- except (KeyError , TypeError , AttributeError ):
143- # handle special case for Dockerfile deployments
144- return [] if container_type == 'cmd' else ['start' , container_type ]
130+ # has profile
131+ if release .build .procfile and container_type in release .build .procfile :
132+ cmd = release .build .procfile [container_type ]
133+ # if the entrypoint is `/bin/bash -c`, we want to supply the list
134+ # as a script. Otherwise, we want to send it as a list of arguments.
135+ if self ._get_entrypoint (container_type ) == ['/bin/bash' , '-c' ]:
136+ return [cmd ]
137+ else :
138+ return cmd .split ()
139+ return []
145140
146141 def _get_entrypoint (self , container_type ):
147142 """
148143 Return the kubernetes "container command" to be sent off to the scheduler.
149-
150- In this case, it is the entrypoint for the docker image. Because of Heroku compatibility,
151- Any containers that are not from a buildpack are run under /bin/bash.
152144 """
153- # handle special case for Dockerfile deployments
154145 if container_type == 'cmd' :
155146 return []
156-
157- # if this is a procfile-based app, switch the entrypoint to slugrunner's default
158- # FIXME: remove slugrunner's hardcoded entrypoint
147+ entrypoint = ['/bin/bash' , '-c' ]
159148 release = self .release_set .filter (failed = False ).latest ()
160149 if release .build .procfile \
161150 and release .build .sha \
162151 and not release .build .dockerfile :
163- entrypoint = [ '/runner/init' ]
164- else :
165- entrypoint = [ '/bin/bash' , '-c' ]
166-
152+ if container_type in release . build . procfile :
153+ entrypoint = [ container_type ]
154+ else :
155+ entrypoint = [ 'launcher' ]
167156 return entrypoint
168157
169158 def _refresh_certificate (self , certs_auto_enabled , hosts ):
@@ -576,12 +565,6 @@ def _scale_pods(self, scale_types):
576565 release = self .release_set .filter (failed = False ).latest ()
577566 app_settings = self .appsettings_set .latest ()
578567 volumes = Volume .objects .filter (app = self , path__isnull = False )
579- # use slugrunner image for app if buildpack app otherwise use normal image
580- if release .build .type == 'buildpack' :
581- image = next (filter (lambda item : item ['name' ] == release .build .stack ,
582- settings .SLUGRUNNER_IMAGES ))['image' ]
583- else :
584- image = release .image
585568
586569 tasks = []
587570 for scale_type , replicas in scale_types .items ():
@@ -594,7 +577,7 @@ def _scale_pods(self, scale_types):
594577 self ._scheduler .scale ,
595578 namespace = self .id ,
596579 name = self ._get_job_id (scale_type ),
597- image = image ,
580+ image = release . image ,
598581 entrypoint = self ._get_entrypoint (scale_type ),
599582 command = self ._get_command (scale_type ),
600583 ** data
@@ -670,27 +653,17 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
670653 # Check if any proc type has a Deployment in progress
671654 self ._check_deployment_in_progress (deploys , force_deploy )
672655
673- # use slugrunner image for app if buildpack app otherwise use normal image
674- if release .build .type == 'buildpack' :
675- image = next (filter (lambda item : item ['name' ] == release .build .stack ,
676- settings .SLUGRUNNER_IMAGES ))['image' ]
677- else :
678- image = release .image
679-
680656 try :
681657 # create the application config in k8s (secret in this case) for all deploy objects
682658 self .set_application_config (release )
683- # only buildpack apps need access to object storage
684- if release .build .type == 'buildpack' :
685- self .create_object_store_secret ()
686659
687660 # gather all proc types to be deployed
688661 tasks = [
689662 functools .partial (
690663 self ._scheduler .deploy ,
691664 namespace = self .id ,
692665 name = self ._get_job_id (scale_type ),
693- image = image ,
666+ image = release . image ,
694667 entrypoint = self ._get_entrypoint (scale_type ),
695668 command = self ._get_command (scale_type ),
696669 ** kwargs
@@ -903,12 +876,6 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
903876 raise DryccException ('No build associated with this release to run this command' )
904877
905878 app_settings = self .appsettings_set .latest ()
906- # use slugrunner image for app if buildpack app otherwise use normal image
907- if release .build .type == 'buildpack' :
908- image = next (filter (lambda item : item ['name' ] == release .build .stack ,
909- settings .SLUGRUNNER_IMAGES ))['image' ]
910- else :
911- image = release .image
912879 volume_list = []
913880 if volumes :
914881 volume_objs = Volume .objects .filter (app = release .app , name__in = volumes .keys ())
@@ -928,7 +895,7 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits):
928895 exit_code , output = self ._scheduler .run (
929896 self .id ,
930897 name ,
931- image ,
898+ release . image ,
932899 self ._get_entrypoint (scale_type ),
933900 [command ],
934901 ** data
@@ -1029,16 +996,7 @@ def _build_env_vars(self, release):
1029996 settings .DRYCC_DATETIME_FORMAT ))
1030997 }
1031998
1032- # Check if it is a slug builder image.
1033- if release .build .type == 'buildpack' :
1034- # overwrite image so slugrunner image is used in the container
1035- default_env ['SLUG_URL' ] = release .image
1036- default_env ['BUILDER_STORAGE' ] = settings .APP_STORAGE
1037- default_env ['DRYCC_MINIO_SERVICE_HOST' ] = settings .MINIO_HOST
1038- default_env ['DRYCC_MINIO_SERVICE_PORT' ] = settings .MINIO_PORT
1039-
1040- if release .build .sha :
1041- default_env ['SOURCE_VERSION' ] = release .build .sha
999+ default_env ['SOURCE_VERSION' ] = release .build .sha
10421000
10431001 # fetch application port and inject into ENV vars as needed
10441002 port = release .get_port ()
@@ -1319,11 +1277,3 @@ def set_application_config(self, release):
13191277 self ._scheduler .secret .create (self .id , secret_name , secrets_env , labels = labels )
13201278 else :
13211279 self ._scheduler .secret .update (self .id , secret_name , secrets_env , labels = labels )
1322-
1323- def create_object_store_secret (self ):
1324- try :
1325- self ._scheduler .secret .get (self .id , 'objectstorage-keyfile' )
1326- except KubeException :
1327- secret = self ._scheduler .secret .get (
1328- settings .WORKFLOW_NAMESPACE , 'objectstorage-keyfile' ).json ()
1329- self ._scheduler .secret .create (self .id , 'objectstorage-keyfile' , secret ['data' ])
0 commit comments