Skip to content

Commit 60c6a5f

Browse files
committed
fix(procfile): route the traffic to web proctype always if its present in procfile
1 parent 3d3676b commit 60c6a5f

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

rootfs/api/models/app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,14 @@ def _check_deployment_in_progress(self, deploys, force_deploy=False):
627627

628628
def _default_structure(self, release):
629629
"""Scale to default structure based on release type"""
630+
# If web in procfile then honor it
631+
if release.build.procfile and 'web' in release.build.procfile:
632+
structure = {'web': 1}
633+
630634
# if there is no SHA, assume a docker image is being promoted
631-
if not release.build.sha:
635+
elif not release.build.sha:
632636
structure = {'cmd': 1}
633637

634-
elif release.build.procfile and 'web' in release.build.procfile:
635-
structure = {'web': 1}
636-
637638
# if a dockerfile, assume docker workflow
638639
elif release.build.dockerfile:
639640
structure = {'cmd': 1}

rootfs/api/tests/test_build.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,29 @@ def test_build_default_containers(self, mock_requests):
122122
# pod name is auto generated so use regex
123123
self.assertRegex(container['name'], app_id + '-cmd-[0-9]{8,10}-[a-z0-9]{5}')
124124

125+
# post an image as a build with a procfile
126+
app_id = self.create_app()
127+
# post an image as a build
128+
url = "/v2/apps/{app_id}/builds".format(**locals())
129+
body = {
130+
'image': 'autotest/example',
131+
'procfile': {
132+
'web': 'node worker.js'
133+
}
134+
}
135+
response = self.client.post(url, body)
136+
self.assertEqual(response.status_code, 201, response.data)
137+
138+
url = "/v2/apps/{app_id}/pods/web".format(**locals())
139+
response = self.client.get(url)
140+
self.assertEqual(response.status_code, 200, response.data)
141+
self.assertEqual(len(response.data['results']), 1)
142+
container = response.data['results'][0]
143+
self.assertEqual(container['type'], 'web')
144+
self.assertEqual(container['release'], 'v2')
145+
# pod name is auto generated so use regex
146+
self.assertRegex(container['name'], app_id + '-web-[0-9]{8,10}-[a-z0-9]{5}')
147+
125148
# start with a new app
126149
app_id = self.create_app()
127150
# post a new build with procfile

0 commit comments

Comments
 (0)