Skip to content

Commit 4bfc8e6

Browse files
committed
chore(controller): remove default proc cmd
1 parent 40e42a6 commit 4bfc8e6

8 files changed

Lines changed: 65 additions & 88 deletions

File tree

rootfs/api/models/app.py

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
290290
if prev_release.build.type != release.build.type:
291291
structure = self.structure.copy()
292292
# zero out canonical pod counts
293-
for proctype in ['cmd', 'web']:
294-
if proctype in structure:
293+
for proctype in structure.keys():
294+
if proctype == "web":
295295
structure[proctype] = 0
296296
# update with the default process type.
297297
structure.update(self._default_structure(release))
@@ -365,15 +365,15 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
365365
self.log(err, logging.ERROR)
366366
raise ServiceUnavailable(err) from e
367367
for procfile_type, value in deploys.items():
368-
if procfile_type in ("web", "cmd"): # http
368+
if procfile_type == "web": # http
369369
target_port = int(value.get('envs', {}).get('PORT', 5000))
370370
self._create_default_ingress(procfile_type, target_port)
371371
service = self.service_set.filter(procfile_type=procfile_type).first()
372372
if not service:
373373
continue
374374
if prev_release and prev_release.build:
375375
continue
376-
if procfile_type in ("web", "cmd"):
376+
if procfile_type == "web":
377377
self._verify_http_health(service, **deploys[procfile_type])
378378
else:
379379
self._verify_tcp_health(service, **deploys[procfile_type])
@@ -659,13 +659,13 @@ def _get_command(self, container_type):
659659
if release.build.dockerfile or not release.build.sha:
660660
# has profile
661661
if release.build.procfile and container_type in release.build.procfile:
662-
cmd = release.build.procfile[container_type]
662+
command = release.build.procfile[container_type]
663663
# if the entrypoint is `/bin/bash -c`, we want to supply the list
664664
# as a script. Otherwise, we want to send it as a list of arguments.
665665
if self._get_entrypoint(container_type) == ['/bin/sh', '-c']:
666-
return [cmd]
666+
return [command]
667667
else:
668-
return cmd.split()
668+
return command.split()
669669
return []
670670

671671
def _get_stack(self, release):
@@ -764,9 +764,8 @@ def _scale(self, user, structure, release, app_settings): # noqa
764764
# test for available process types
765765
available_process_types = release.build.procfile or {}
766766
for container_type in structure:
767-
if container_type == 'cmd':
768-
continue # allow docker cmd types in case we don't have the image source
769-
767+
if self._get_stack(release) == "container":
768+
continue # allow container types in case we don't have the image source
770769
if container_type not in available_process_types:
771770
raise NotFound(
772771
'Container type {} does not exist in application'.format(container_type))
@@ -957,28 +956,12 @@ def _check_deployment_in_progress(self, deploys, release, force_deploy=False):
957956
@staticmethod
958957
def _default_structure(release):
959958
"""Scale to default structure based on release type"""
960-
# If web in procfile then honor it
961-
if release.build.procfile and 'web' in release.build.procfile:
962-
structure = {'web': 1}
963-
964-
# if there is no SHA, assume a docker image is being promoted
965-
elif not release.build.sha:
966-
structure = {'cmd': 1}
967-
968-
# if a dockerfile, assume docker workflow
969-
elif release.build.dockerfile:
970-
structure = {'cmd': 1}
971-
972-
# if a procfile exists without a web entry and dockerfile, assume heroku workflow
973-
# and return empty structure as only web type needs to be created by default and
974-
# other types have to be manually scaled
975-
elif release.build.procfile and 'web' not in release.build.procfile:
959+
if release.build.sha and not release.build.dockerfile and \
960+
(release.build.procfile and 'web' not in release.build.procfile):
976961
structure = {}
977-
978962
# default to heroku workflow
979963
else:
980964
structure = {'web': 1}
981-
982965
return structure
983966

984967
def _scheduler_filter(self, **kwargs):
@@ -1132,13 +1115,13 @@ def _gather_app_settings(self, release, app_settings, process_type, replicas, vo
11321115
# create image pull secret if needed
11331116
image_pull_secret_name = self.image_pull_secret(self.id, config.registry, release.image)
11341117

1135-
# only web / cmd are routable
1136-
# http://docs.drycc.cc/en/latest/using_drycc/process-types/#web-vs-cmd-process-types
1137-
routable = True if process_type in ['web', 'cmd'] and app_settings.routable else False
1118+
# only web is routable
1119+
# https://www.drycc.cc/applications/managing-app-processes/#default-process-types
1120+
routable = True if process_type == 'web' and app_settings.routable else False
11381121

11391122
healthcheck = config.get_healthcheck().get(process_type, {})
1140-
if not healthcheck and process_type in ['web', 'cmd']:
1141-
healthcheck = config.get_healthcheck().get('web/cmd', {})
1123+
if not healthcheck and process_type == 'web':
1124+
healthcheck = config.get_healthcheck().get('web', {})
11421125
volumes_info = [{
11431126
"name": _.name,
11441127
"claimName": _.name,

rootfs/api/models/config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def _migrate_legacy_healthcheck(self):
5555
success_threshold = int(self.values.get('HEALTHCHECK_SUCCESS_THRESHOLD', 1))
5656
failure_threshold = int(self.values.get('HEALTHCHECK_FAILURE_THRESHOLD', 3))
5757

58-
self.healthcheck['web/cmd'] = {}
59-
self.healthcheck['web/cmd']['livenessProbe'] = {
58+
self.healthcheck['web'] = {}
59+
self.healthcheck['web']['livenessProbe'] = {
6060
'initialDelaySeconds': delay,
6161
'timeoutSeconds': timeout,
6262
'periodSeconds': period_seconds,
@@ -67,7 +67,7 @@ def _migrate_legacy_healthcheck(self):
6767
}
6868
}
6969

70-
self.healthcheck['web/cmd']['readinessProbe'] = {
70+
self.healthcheck['web']['readinessProbe'] = {
7171
'initialDelaySeconds': delay,
7272
'timeoutSeconds': timeout,
7373
'periodSeconds': period_seconds,
@@ -86,7 +86,7 @@ def get_healthcheck(self):
8686
'livenessProbe' in self.healthcheck.keys() or
8787
'readinessProbe' in self.healthcheck.keys()
8888
):
89-
return {'web/cmd': self.healthcheck}
89+
return {'web': self.healthcheck}
9090
return self.healthcheck
9191

9292
def _set_cpu_memory(self):
@@ -205,9 +205,9 @@ def set_healthcheck(self, previous_config):
205205
# TODO: This is required for backward compatibility and can be
206206
# removed in next major version change.
207207
if 'livenessProbe' in data.keys() or 'readinessProbe' in data.keys():
208-
data = {'web/cmd': data.copy()}
208+
data = {'web': data.copy()}
209209
if 'livenessProbe' in new_data.keys() or 'readinessProbe' in new_data.keys(): # noqa
210-
new_data = {'web/cmd': new_data.copy()}
210+
new_data = {'web': new_data.copy()}
211211

212212
# remove config keys if a null value is provided
213213
for key, value in new_data.items():

rootfs/api/models/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _namespace(self):
8585
return self.app.id
8686

8787
def _svc_name(self, canary):
88-
if self.procfile_type in ("web", "cmd"):
88+
if self.procfile_type == 'web':
8989
svc_name = self.app.id
9090
else:
9191
svc_name = "{}-{}".format(self.app.id, self.procfile_type)

rootfs/api/tests/test_build.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ def test_build_default_containers(self, mock_requests):
113113
response = self.client.post(url, body)
114114
self.assertEqual(response.status_code, 201, response.data)
115115

116-
url = "/v2/apps/{app_id}/pods/cmd".format(**locals())
116+
url = "/v2/apps/{app_id}/pods/web".format(**locals())
117117
response = self.client.get(url)
118118
self.assertEqual(response.status_code, 200, response.data)
119119
self.assertEqual(len(response.data['results']), 1)
120120
container = response.data['results'][0]
121-
self.assertEqual(container['type'], 'cmd')
121+
self.assertEqual(container['type'], 'web')
122122
self.assertEqual(container['release'], 'v2')
123123
# pod name is auto generated so use regex
124-
self.assertRegex(container['name'], app_id + '-cmd-[0-9]{1,10}-[a-z0-9]{5}')
124+
self.assertRegex(container['name'], app_id + '-web-[0-9]{1,10}-[a-z0-9]{5}')
125125

126126
# post an image as a build with a procfile
127127
app_id = self.create_app()
@@ -160,15 +160,15 @@ def test_build_default_containers(self, mock_requests):
160160
response = self.client.post(url, body)
161161
self.assertEqual(response.status_code, 201, response.data)
162162

163-
url = "/v2/apps/{app_id}/pods/cmd".format(**locals())
163+
url = "/v2/apps/{app_id}/pods/web".format(**locals())
164164
response = self.client.get(url)
165165
self.assertEqual(response.status_code, 200, response.data)
166166
self.assertEqual(len(response.data['results']), 1)
167167
container = response.data['results'][0]
168-
self.assertEqual(container['type'], 'cmd')
168+
self.assertEqual(container['type'], 'web')
169169
self.assertEqual(container['release'], 'v2')
170170
# pod name is auto generated so use regex
171-
self.assertRegex(container['name'], app_id + '-cmd-[0-9]{1,10}-[a-z0-9]{5}')
171+
self.assertRegex(container['name'], app_id + '-web-[0-9]{1,10}-[a-z0-9]{5}')
172172

173173
# start with a new app
174174
app_id = self.create_app()
@@ -187,15 +187,15 @@ def test_build_default_containers(self, mock_requests):
187187
response = self.client.post(url, body)
188188
self.assertEqual(response.status_code, 201, response.data)
189189

190-
url = "/v2/apps/{app_id}/pods/cmd".format(**locals())
190+
url = "/v2/apps/{app_id}/pods/web".format(**locals())
191191
response = self.client.get(url)
192192
self.assertEqual(response.status_code, 200, response.data)
193193
self.assertEqual(len(response.data['results']), 1)
194194
container = response.data['results'][0]
195-
self.assertEqual(container['type'], 'cmd')
195+
self.assertEqual(container['type'], 'web')
196196
self.assertEqual(container['release'], 'v2')
197197
# pod name is auto generated so use regex
198-
self.assertRegex(container['name'], app_id + '-cmd-[0-9]{1,10}-[a-z0-9]{5}')
198+
self.assertRegex(container['name'], app_id + '-web-[0-9]{1,10}-[a-z0-9]{5}')
199199

200200
# start with a new app
201201
app_id = self.create_app()
@@ -298,19 +298,13 @@ def test_build_forgotten_procfile(self, mock_requests):
298298
url = "/v2/apps/{app_id}/pods/web".format(**locals())
299299
response = self.client.get(url)
300300
self.assertEqual(response.status_code, 200, response.data)
301-
self.assertEqual(len(response.data['results']), 0)
302-
303-
# verify cmd is there
304-
url = "/v2/apps/{app_id}/pods/cmd".format(**locals())
305-
response = self.client.get(url)
306-
self.assertEqual(response.status_code, 200, response.data)
307301
self.assertEqual(len(response.data['results']), 1)
308302

309303
# look at the app structure
310304
url = "/v2/apps/{app_id}".format(**locals())
311305
response = self.client.get(url)
312306
self.assertEqual(response.status_code, 200, response.data)
313-
self.assertEqual(response.json()['structure'], {'cmd': 1, 'web': 0, 'worker': 0})
307+
self.assertEqual(response.json()['structure'], {'web': 1, 'worker': 0})
314308

315309
@override_settings(DRYCC_DEPLOY_PROCFILE_MISSING_REMOVE=False)
316310
def test_build_no_remove_process(self, mock_requests):

rootfs/api/tests/test_canary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def pre_data(self):
5353
# add canary
5454
self.client.post(
5555
f'/v2/apps/{app_id}/settings',
56-
{'canaries': ["cmd"]}
56+
{'canaries': ["web"]}
5757
)
5858
# add v3 release
5959
url = f'/v2/apps/{app_id}/builds'

rootfs/api/tests/test_healthchecks.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,32 @@ def test_config_healthchecks(self, mock_requests):
7575
Test that healthchecks can be applied
7676
"""
7777
app_id = self.create_app()
78-
readiness_probe = {'healthcheck': {'web/cmd': {'readinessProbe':
79-
{'httpGet': {'port': 5000}}}}}
80-
78+
readiness_probe = {
79+
'healthcheck': {'web': {'readinessProbe': {'httpGet': {'port': 5000}}}}
80+
}
8181
response = self.client.post(
8282
'/v2/apps/{app_id}/config'.format(**locals()),
8383
readiness_probe)
8484
self.assertEqual(response.status_code, 201, response.data)
85-
self.assertIn('readinessProbe', response.data['healthcheck']['web/cmd'])
85+
self.assertIn('readinessProbe', response.data['healthcheck']['web'])
8686
self.assertEqual(response.data['healthcheck'], readiness_probe['healthcheck'])
8787

88-
liveness_probe = {'healthcheck': {'web/cmd': {'livenessProbe':
88+
liveness_probe = {'healthcheck': {'web': {'livenessProbe':
8989
{'httpGet': {'port': 5000},
9090
'successThreshold': 1}}}}
9191
response = self.client.post(
9292
'/v2/apps/{app_id}/config'.format(**locals()),
9393
liveness_probe)
9494
self.assertEqual(response.status_code, 201, response.data)
95-
self.assertIn('livenessProbe', response.data['healthcheck']['web/cmd'])
95+
self.assertIn('livenessProbe', response.data['healthcheck']['web'])
9696
self.assertEqual(
97-
response.data['healthcheck']['web/cmd']['livenessProbe'],
98-
liveness_probe['healthcheck']['web/cmd']['livenessProbe'])
97+
response.data['healthcheck']['web']['livenessProbe'],
98+
liveness_probe['healthcheck']['web']['livenessProbe'])
9999
# check that the readiness probe is still there too!
100-
self.assertIn('readinessProbe', response.data['healthcheck']['web/cmd'])
100+
self.assertIn('readinessProbe', response.data['healthcheck']['web'])
101101
self.assertEqual(
102-
response.data['healthcheck']['web/cmd']['readinessProbe'],
103-
readiness_probe['healthcheck']['web/cmd']['readinessProbe'])
102+
response.data['healthcheck']['web']['readinessProbe'],
103+
readiness_probe['healthcheck']['web']['readinessProbe'])
104104

105105
# check that config fails if trying to unset non-existing healthcheck
106106
response = self.client.post(
@@ -111,15 +111,15 @@ def test_config_healthchecks(self, mock_requests):
111111
# remove a probeType
112112
response = self.client.post(
113113
'/v2/apps/{app_id}/config'.format(**locals()),
114-
{'healthcheck': {'web/cmd': {'livenessProbe': None}}})
114+
{'healthcheck': {'web': {'livenessProbe': None}}})
115115
self.assertEqual(response.status_code, 201, response.data)
116-
self.assertNotIn('livenessProbe', response.data['healthcheck']['web/cmd'])
117-
self.assertIn('readinessProbe', response.data['healthcheck']['web/cmd'])
116+
self.assertNotIn('livenessProbe', response.data['healthcheck']['web'])
117+
self.assertIn('readinessProbe', response.data['healthcheck']['web'])
118118

119119
# check that config fails if trying to unset non-existing probeType
120120
response = self.client.post(
121121
'/v2/apps/{app_id}/config'.format(**locals()),
122-
{'healthcheck': {'web/cmd': {'livenessProbe': None}}})
122+
{'healthcheck': {'web': {'livenessProbe': None}}})
123123
self.assertEqual(response.status_code, 422, response.data)
124124

125125
# check that config fails if trying to unset non-existing probeType
@@ -131,9 +131,9 @@ def test_config_healthchecks(self, mock_requests):
131131
# check that config fails if trying to unset non-existing probeType
132132
response = self.client.post(
133133
'/v2/apps/{app_id}/config'.format(**locals()),
134-
{'healthcheck': {'web/cmd': None}})
134+
{'healthcheck': {'web': None}})
135135
self.assertEqual(response.status_code, 201, response.data)
136-
self.assertNotIn('web/cmd', response.data['healthcheck'])
136+
self.assertNotIn('web', response.data['healthcheck'])
137137

138138
# post a new build
139139
response = self.client.post(
@@ -151,23 +151,23 @@ def test_config_healthchecks_validations(self, mock_requests):
151151
# Set a probe different from liveness/readiness
152152
response = self.client.post(
153153
'/v2/apps/{app_id}/config'.format(**locals()),
154-
{'healthcheck': json.dumps({'web/cmd': {'testProbe':
154+
{'healthcheck': json.dumps({'web': {'testProbe':
155155
{'httpGet': {'port': '50'}, 'initialDelaySeconds': "1"}}})}
156156
)
157157
self.assertEqual(response.status_code, 400, response.data)
158158

159159
# Set one of the values that require a numeric value to a string
160160
response = self.client.post(
161161
'/v2/apps/{app_id}/config'.format(**locals()),
162-
{'healthcheck': json.dumps({'web/cmd': {'livenessProbe':
162+
{'healthcheck': json.dumps({'web': {'livenessProbe':
163163
{'httpGet': {'port': '50'}, 'initialDelaySeconds': "t"}}})}
164164
)
165165
self.assertEqual(response.status_code, 400, response.data)
166166

167167
# Don't set one of the mandatory value
168168
response = self.client.post(
169169
'/v2/apps/{app_id}/config'.format(**locals()),
170-
{'healthcheck': json.dumps({'web/cmd': {'livenessProbe':
170+
{'healthcheck': json.dumps({'web': {'livenessProbe':
171171
{'httpGet': {'path': '/'}, 'initialDelaySeconds': 1}}})}
172172
)
173173
self.assertEqual(response.status_code, 400, response.data)
@@ -176,7 +176,7 @@ def test_config_healthchecks_validations(self, mock_requests):
176176
# Don't set one of the mandatory value
177177
response = self.client.post(
178178
'/v2/apps/{app_id}/config'.format(**locals()),
179-
{'healthcheck': {'web/cmd': {'livenessProbe':
179+
{'healthcheck': {'web': {'livenessProbe':
180180
{'httpGet': {'path': '/', 'port': 5000},
181181
'successThreshold': 5}}}}
182182
)
@@ -199,7 +199,7 @@ def test_config_healthchecks_legacy(self, mock_requests):
199199
# this gets migrated to the new healtcheck format
200200
self.assertNotIn('HEALTHCHECK_URL', response.data['values'])
201201
# legacy defaults
202-
expected = {'web/cmd': {
202+
expected = {'web': {
203203
'livenessProbe': {
204204
'initialDelaySeconds': 50,
205205
'timeoutSeconds': 50,
@@ -240,7 +240,7 @@ def test_config_healthchecks_legacy(self, mock_requests):
240240
self.assertEqual(response.status_code, 201, response.data)
241241
# this gets migrated to the new healtcheck format
242242
self.assertNotIn('HEALTHCHECK_INITIAL_DELAY', response.data['values'])
243-
expected['web/cmd']['livenessProbe'] = {
243+
expected['web']['livenessProbe'] = {
244244
'initialDelaySeconds': 25,
245245
'timeoutSeconds': 10,
246246
'periodSeconds': 5,
@@ -250,6 +250,6 @@ def test_config_healthchecks_legacy(self, mock_requests):
250250
'path': '/health'
251251
}
252252
}
253-
expected['web/cmd']['readinessProbe'] = expected['web/cmd']['livenessProbe']
253+
expected['web']['readinessProbe'] = expected['web']['livenessProbe']
254254
actual = app.config_set.latest().healthcheck
255255
self.assertEqual(expected, actual)

0 commit comments

Comments
 (0)