Skip to content

Commit d7e6740

Browse files
author
Matthew Fisher
committed
Merge pull request #1985 from johanneswuerbach/run-env
fix(controller): Use correct entrypoint for run
2 parents 8c069c9 + 8ddb7dc commit d7e6740

4 files changed

Lines changed: 17 additions & 6 deletions

File tree

controller/api/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,14 @@ def run(self, command):
496496
"""Run a one-off command"""
497497
image = self.release.image + ':v' + str(self.release.version)
498498
job_id = self._job_id
499+
entrypoint = '/bin/bash'
500+
if self.release.build.procfile:
501+
entrypoint = '/runner/init'
502+
command = "'{}'".format(command)
503+
else:
504+
command = "-c '{}'".format(command)
499505
try:
500-
rc, output = self._scheduler.run(job_id, image, command)
506+
rc, output = self._scheduler.run(job_id, image, entrypoint, command)
501507
return rc, output
502508
except Exception as e:
503509
err = '{} (run): {}'.format(job_id, e)

controller/scheduler/chaos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def destroy(self, name):
5454
raise RuntimeError
5555
return True
5656

57-
def run(self, name, image, command):
57+
def run(self, name, image, entrypoint, command):
5858
"""
5959
Run a one-off command
6060
"""

controller/scheduler/coreos.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ def _create_container(self, name, image, command, unit, **kwargs):
122122
l.update({'cpu': '-c {}'.format(cpu)})
123123
else:
124124
l.update({'cpu': ''})
125+
# should a special entrypoint be used
126+
entrypoint = kwargs.get('entrypoint')
127+
if entrypoint:
128+
l.update({'entrypoint': '{}'.format(entrypoint)})
125129
# construct unit from template
126130
for f in unit:
127131
f['value'] = f['value'].format(**l)
@@ -194,9 +198,10 @@ def _destroy_container(self, name):
194198
def _destroy_log(self, name):
195199
return self._delete_unit(name+'-log')
196200

197-
def run(self, name, image, command): # noqa
201+
def run(self, name, image, entrypoint, command): # noqa
198202
"""Run a one-off command"""
199-
self._create_container(name, image, command, copy.deepcopy(RUN_TEMPLATE))
203+
self._create_container(name, image, command, copy.deepcopy(RUN_TEMPLATE),
204+
entrypoint=entrypoint)
200205

201206
# wait for the container to get scheduled
202207
for _ in range(30):
@@ -316,6 +321,6 @@ def attach(self, name):
316321
{"section": "Unit", "name": "Description", "value": "{name} admin command"},
317322
{"section": "Service", "name": "ExecStartPre", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker pull $IMAGE"'''}, # noqa
318323
{"section": "Service", "name": "ExecStartPre", "value": '''/bin/sh -c "docker inspect {name} >/dev/null 2>&1 && docker rm -f {name} || true"'''}, # noqa
319-
{"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker run --name {name} --entrypoint=/bin/bash -a stdout -a stderr $IMAGE -c '{command}'"'''}, # noqa
324+
{"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker run --name {name} --entrypoint={entrypoint} -a stdout -a stderr $IMAGE {command}"'''}, # noqa
320325
{"section": "Service", "name": "TimeoutStartSec", "value": "20m"},
321326
]

controller/scheduler/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def destroy(self, name):
4444
"""
4545
return
4646

47-
def run(self, name, image, command):
47+
def run(self, name, image, entrypoint, command):
4848
"""
4949
Run a one-off command
5050
"""

0 commit comments

Comments
 (0)