Repository: deis/deis

Issue:
`deis scale` hangs - units are submitted, but not started
This is the `example-go` app deployed with `git push` and a Procfile as follows:

```
web: example-go
cmd: while true; do echo cmd; sleep 3; done
worker: while true; do echo worker; sleep 3; done
```

```
➜  example-go git:(master) deis scale web=6
Scaling processes... but first, coffee!
done in 161s
=== velvet-joyrider Processes

--- web:
web.1 up (v2)
web.2 up (v2)
web.3 up (v2)
web.4 up (v2)
web.5 up (v2)
web.6 up (v2)
➜  example-go git:(master) deis scale cmd=4
Scaling processes... but first, coffee!
```

Nothing happens. Controller doesn't show anything after receiving my request to scale them:

```
Dec 05 04:05:22 ip-10-21-1-149.ec2.internal sh[2770]: 10.21.2.5 "POST /v1/apps/velvet-joyrider/scale HTTP/1.0" 204 - "python-requests/2.3.0 CPython/2.7.6 Darwin/14.0.0"
Dec 05 04:05:22 ip-10-21-1-149.ec2.internal sh[2770]: 10.21.2.4 "GET /v1/apps/velvet-joyrider/containers HTTP/1.0" 200 - "python-requests/2.3.0 CPython/2.7.6 Darwin/14.0.0"
Dec 05 04:06:11 ip-10-21-1-149.ec2.internal sh[2770]: INFO velvet-joyrider: chris scaled containers cmd=4
```

Interestingly, the units are scheduled but not started:

```
velvet-joyrider_v2.cmd.1.service    4cf99223.../10.21.2.4   inactive    dead
velvet-joyrider_v2.cmd.2.service    d6b1651b.../10.21.2.5   inactive    dead
velvet-joyrider_v2.cmd.3.service    4cf99223.../10.21.2.4   inactive    dead
velvet-joyrider_v2.cmd.4.service    f9e954f6.../10.21.1.149 inactive    dead
velvet-joyrider_v2.web.1.service    4cf99223.../10.21.2.4   active      running
velvet-joyrider_v2.web.2.service    d6b1651b.../10.21.2.5   active      running
velvet-joyrider_v2.web.3.service    f9e954f6.../10.21.1.149 active      running
velvet-joyrider_v2.web.4.service    4cf99223.../10.21.2.4   active      running
velvet-joyrider_v2.web.5.service    d6b1651b.../10.21.2.5   active      running
velvet-joyrider_v2.web.6.service    f9e954f6.../10.21.1.149 active      running
```

Scaling the workers returned quickly (10s):

```
$ deis scale worker=3
Scaling processes... but first, coffee!
done in 10s
=== velvet-joyrider Processes

--- web:
web.1 up (v2)
web.2 up (v2)
web.3 up (v2)
web.4 up (v2)
web.5 up (v2)
web.6 up (v2)

--- cmd:
cmd.1 created (v2)
cmd.2 up (v2)
cmd.3 up (v2)
cmd.4 up (v2)

--- worker:
worker.1 up (v2)
worker.2 up (v2)
worker.3 up (v2)
```

Note that my `cmd`s now report as (mostly) up.



Discussion:
Actually, looks like all the units are crashing :(

```
Dec 05 04:21:34 ip-10-21-1-149.ec2.internal systemd[1]: Starting velvet-joyrider_v2.worker.3...
Dec 05 04:21:36 ip-10-21-1-149.ec2.internal sh[28994]: Pulling repository 10.21.1.149:5000/velvet-joyrider
Dec 05 04:21:38 ip-10-21-1-149.ec2.internal sh[28994]: Status: Image is up to date for 10.21.1.149:5000/velvet-joyrider:v2
Dec 05 04:21:38 ip-10-21-1-149.ec2.internal systemd[1]: Started velvet-joyrider_v2.worker.3.
Dec 05 04:21:39 ip-10-21-1-149.ec2.internal sh[29067]: bash: -c: line 0: syntax error near unexpected token `do'
Dec 05 04:21:39 ip-10-21-1-149.ec2.internal sh[29067]: bash: -c: line 0: `env while true; do echo worker; sleep 3; done'
Dec 05 04:21:39 ip-10-21-1-149.ec2.internal systemd[1]: velvet-joyrider_v2.worker.3.service: main process exited, code=exited, status=1/FAILURE
Dec 05 04:21:39 ip-10-21-1-149.ec2.internal docker[29139]: velvet-joyrider_v2.worker.3
Dec 05 04:21:39 ip-10-21-1-149.ec2.internal systemd[1]: Unit velvet-joyrider_v2.worker.3.service entered failed state.
Dec 05 04:21:44 ip-10-21-1-149.ec2.internal systemd[1]: velvet-joyrider_v2.worker.3.service holdoff time over, scheduling restart.
Dec 05 04:21:44 ip-10-21-1-149.ec2.internal systemd[1]: Stopping velvet-joyrider_v2.worker.3...
```

@bacongobbler It looks like this is a consequence of #2627 - users can not use complicated strings for their Proctypes. Is this intended?

Also, `deis info` seems to have no knowledge of the Proctypes, even though the builder identified them :(

```
➜  example-go git:(master) git push deis master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 283 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
-----> Go app detected
-----> Using go1.2.2
-----> Running: godep go install -tags heroku ./...
-----> Discovering process types
       Procfile declares types -> web, cmd, worker
-----> Compiled slug size is 1.7M

-----> Building Docker image
remote: Sending build context to Docker daemon   1.8 MB
remote: build context to Docker daemon
Step 0 : FROM deis/slugrunner
 ---> 2397d226bbb3
Step 1 : RUN mkdir -p /app
 ---> Running in 387cd5c251f2
 ---> 72f9247f248d
Removing intermediate container 387cd5c251f2
Step 2 : WORKDIR /app
 ---> Running in 1aee7429fa14
 ---> 19b241b1ca22
Removing intermediate container 1aee7429fa14
Step 3 : ENTRYPOINT /runner/init
 ---> Running in 6f243ccca2ad
 ---> 2155a2cfb8ce
Removing intermediate container 6f243ccca2ad
Step 4 : ADD slug.tgz /app
 ---> ade576af6b5f
Removing intermediate container 736002b44934
Step 5 : ENV GIT_SHA 71bc90b3ef81d7340d8bfb4972e87dff5b023ee1
 ---> Running in 13465628510b
 ---> d5c56935ed06
Removing intermediate container 13465628510b
Successfully built d5c56935ed06
-----> Pushing image to private registry

-----> Launching...
       done, velvet-joyrider:v4 deployed to Deis

       http://velvet-joyrider.demo.deis.io

       To learn more, use `deis help` or visit http://deis.io

To ssh://git@deis.demo.deis.io:2222/velvet-joyrider.git
   ad5e566..71bc90b  master -> master
```

```
➜  example-go git:(master) deis open
➜  example-go git:(master) deis ps
=== velvet-joyrider Processes

➜  example-go git:(master) deis scale web=3
Scaling processes... but first, coffee!
done in 31s
=== velvet-joyrider Processes

--- web:
web.1 up (v4)
web.2 up (v4)
web.3 up (v4)

➜  example-go git:(master) deis scale cmd=3
Scaling processes... but first, coffee!
done in 12s
=== velvet-joyrider Processes

--- web:
web.1 up (v4)
web.2 up (v4)
web.3 up (v4)

--- cmd:
cmd.1 up (v4)
cmd.2 up (v4)
cmd.3 up (v4)

➜  example-go git:(master) deis scale worker=3
Scaling processes... but first, coffee!
done in 13s
=== velvet-joyrider Processes

--- web:
web.1 up (v4)
web.2 up (v4)
web.3 up (v4)

--- cmd:
cmd.1 up (v4)
cmd.2 up (v4)
cmd.3 up (v4)

--- worker:
worker.1 up (v4)
worker.2 up (v4)
worker.3 up (v4)
```

```
$ deis info
=== velvet-joyrider Application
{
  "updated": "2014-12-05T04:38:17UTC",
  "uuid": "e1b8b27d-f9a3-4a18-9411-cb4a79a19f4a",
  "created": "2014-12-05T03:57:54UTC",
  "url": "velvet-joyrider.demo.deis.io",
  "owner": "chris",
  "id": "velvet-joyrider",
  "structure": {
    "worker": 3
  }
}

=== velvet-joyrider Processes

--- web:
web.1 up (v4)
web.2 up (v4)
web.3 up (v4)

--- cmd:
cmd.1 up (v4)
cmd.2 up (v4)
cmd.3 up (v4)

--- worker:
worker.1 up (v4)
worker.2 up (v4)
worker.3 up (v4)

=== velvet-joyrider Domains
No domains
```

#2627 also seems to have broken `example-ruby-sinatra`, for one, because we are using a bash-ism in its Procfile:

```
web: bundle exec ruby web.rb -p ${PORT:-5000}
```

This results in a major error with the app:

```
Dec 05 06:43:19 deis-3 sh[32272]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.2/lib/sinatra/main.rb:15:in `<class:Application>': missing argument: -p (OptionParser::MissingArgument)
Dec 05 06:43:19 deis-3 sh[32272]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.2/lib/sinatra/main.rb:4:in `<module:Sinatra>'
Dec 05 06:43:19 deis-3 sh[32272]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.2/lib/sinatra/main.rb:3:in `<top (required)>'
Dec 05 06:43:19 deis-3 sh[32272]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.2/lib/sinatra.rb:2:in `require'
Dec 05 06:43:19 deis-3 sh[32272]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.2/lib/sinatra.rb:2:in `<top (required)>'
Dec 05 06:43:19 deis-3 sh[32272]: from web.rb:1:in `require'
Dec 05 06:43:19 deis-3 sh[32272]: from web.rb:1:in `<main>'
Dec 05 06:43:19 deis-3 systemd[1]: triple-countess_v2.web.1.service: main process exited, code=exited, status=1/FAILURE
Dec 05 06:43:19 deis-3 systemd[1]: Unit triple-countess_v2.web.1.service entered failed state.
```


Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -476,7 +476,7 @@ def run(self, command):
                                    'to run this command')
         image = self.release.image
         job_id = self._job_id
-        entrypoint = '/bin/sh'
+        entrypoint = '/bin/bash'
         # if this is a procfile-based app, switch the entrypoint to slugrunner's default
         # FIXME: remove slugrunner's hardcoded entrypoint
         if self.release.build.procfile and \


Test patch:
diff --git a/controller/api/tests/test_container.py b/controller/api/tests/test_container.py
--- a/controller/api/tests/test_container.py
+++ b/controller/api/tests/test_container.py
@@ -499,12 +499,12 @@ def test_run_command_good(self):
                                      num=1)
         rc, output = c.run('echo hi')
         self.assertEqual(rc, 0)
-        self.assertEqual(json.loads(output)['entrypoint'], '/bin/sh')
+        self.assertEqual(json.loads(output)['entrypoint'], '/bin/bash')
         # docker image workflow
         build.dockerfile = None
         build.sha = None
         rc, output = c.run('echo hi')
-        self.assertEqual(json.loads(output)['entrypoint'], '/bin/sh')
+        self.assertEqual(json.loads(output)['entrypoint'], '/bin/bash')
         # procfile workflow
         build.sha = 'somereallylongsha'
         rc, output = c.run('echo hi')
diff --git a/docs/contributing/testing.rst b/docs/contributing/testing.rst
--- a/docs/contributing/testing.rst
+++ b/docs/contributing/testing.rst
@@ -96,7 +96,7 @@ test-integration.sh
     >>> Preparing test environment <<<
 
     DEIS_ROOT=/Users/matt/Projects/src/github.com/deis/deis
-    DEIS_TEST_APP=example-dockerfile-http
+    DEIS_TEST_APP=example-go
     ...
     >>> Running integration suite <<<
 
diff --git a/tests/bin/test-setup.sh b/tests/bin/test-setup.sh
--- a/tests/bin/test-setup.sh
+++ b/tests/bin/test-setup.sh
@@ -18,7 +18,7 @@ echo "DEIS_ROOT=$DEIS_ROOT"
 export PATH=${GOPATH}/bin:$PATH
 
 # the application under test
-export DEIS_TEST_APP=${DEIS_TEST_APP:-example-dockerfile-http}
+export DEIS_TEST_APP=${DEIS_TEST_APP:-example-go}
 echo "DEIS_TEST_APP=$DEIS_TEST_APP"
 
 # SSH key name used for testing
diff --git a/tests/utils/itutils.go b/tests/utils/itutils.go
--- a/tests/utils/itutils.go
+++ b/tests/utils/itutils.go
@@ -312,7 +312,6 @@ func GetRandomApp() string {
 		"example-python-flask",
 		"example-ruby-sinatra",
 		"example-scala",
-		"example-dockerfile-http",
 	}
 	return apps[rand.Intn(len(apps))]
 }