Skip to content

Commit 331c47d

Browse files
authored
Merge pull request #942 from helgi/deployments_only
ref(*): make Deployments the only deploy strategy, no RC
2 parents 680469b + 859f273 commit 331c47d

21 files changed

Lines changed: 18 additions & 4874 deletions

rootfs/api/models/app.py

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,7 @@ def __str__(self):
123123

124124
def _get_job_id(self, container_type):
125125
app = self.id
126-
release = self.release_set.latest()
127-
128-
# see if there is a global or app specific setting to specify Deployments usage
129-
deployments = bool(release.config.values.get('DEIS_KUBERNETES_DEPLOYMENTS', settings.DEIS_KUBERNETES_DEPLOYMENTS)) # noqa
130-
131-
# deployments does not need version in the job
132-
if deployments:
133-
return "{app}-{container_type}".format(**locals())
134-
135-
version = "v{}".format(release.version)
136-
return "{app}-{version}-{container_type}".format(**locals())
126+
return "{app}-{container_type}".format(**locals())
137127

138128
def _get_command(self, container_type):
139129
"""
@@ -259,34 +249,17 @@ def restart(self, **kwargs): # noqa
259249
Wait until they are all drained away and RC / Deployment has gotten to a good state
260250
"""
261251
try:
262-
if kwargs.get('release', None) is None:
263-
release = self.release_set.latest()
264-
else:
265-
release = self.release_set.get(version=kwargs['release'])
266-
267-
# see if there is a global or app specific setting to specify Deployments usage
268-
deployments = bool(release.config.values.get('DEIS_KUBERNETES_DEPLOYMENTS', settings.DEIS_KUBERNETES_DEPLOYMENTS)) # noqa
269-
270-
if deployments:
271-
# Resolve single pod name if short form (cmd-1269180282-1nyfz) is passed
272-
if 'name' in kwargs and kwargs['name'].count('-') == 2:
273-
kwargs['name'] = '{}-{}'.format(kwargs['id'], kwargs['name'])
274-
else:
275-
# Resolve single pod name if short form (worker-asdfg) is passed
276-
if 'name' in kwargs and kwargs['name'].count('-') == 1:
277-
version = "v{}".format(release.version)
278-
kwargs['name'] = '{}-{}-{}'.format(kwargs['id'], version, kwargs['name'])
252+
# Resolve single pod name if short form (cmd-1269180282-1nyfz) is passed
253+
if 'name' in kwargs and kwargs['name'].count('-') == 2:
254+
kwargs['name'] = '{}-{}'.format(kwargs['id'], kwargs['name'])
279255

280256
# Iterate over RCs / RSs to get total desired count if not a single item
281257
desired = 1
282258
if 'name' not in kwargs:
283259
desired = 0
284260
labels = self._scheduler_filter(**kwargs)
285-
# fetch RS (which represent Deployments) / RCs
286-
if deployments:
287-
controllers = self._scheduler.get_replicasets(kwargs['id'], labels=labels)
288-
else:
289-
controllers = self._scheduler.get_rcs(kwargs['id'], labels=labels)
261+
# fetch RS (which represent Deployments)
262+
controllers = self._scheduler.get_replicasets(kwargs['id'], labels=labels)
290263

291264
for controller in controllers.json()['items']:
292265
desired += controller['spec']['replicas']
@@ -424,9 +397,6 @@ def _scale_pods(self, scale_types):
424397
# see if the app config has deploy timeout preference, otherwise use global
425398
deploy_timeout = release.config.values.get('DEIS_DEPLOY_TIMEOUT', settings.DEIS_DEPLOY_TIMEOUT) # noqa
426399

427-
# see if there is a global or app specific setting to specify Deployments usage
428-
deployments = bool(envs.get('DEIS_KUBERNETES_DEPLOYMENTS', settings.DEIS_KUBERNETES_DEPLOYMENTS)) # noqa
429-
430400
tasks = []
431401
for scale_type, replicas in scale_types.items():
432402
# only web / cmd are routable
@@ -449,7 +419,6 @@ def _scale_pods(self, scale_types):
449419
'build_type': release.build.type,
450420
'healthcheck': release.config.healthcheck,
451421
'routable': routable,
452-
'deployments': deployments,
453422
'deploy_batches': batches,
454423
'deploy_timeout': deploy_timeout,
455424
}
@@ -493,9 +462,6 @@ def deploy(self, release, force_deploy=False):
493462
# see if the app config has deploy batch preference, otherwise use global
494463
batches = release.config.values.get('DEIS_DEPLOY_BATCHES', settings.DEIS_DEPLOY_BATCHES)
495464

496-
# see if there is a global or app specific setting to specify Deployments usage
497-
deployments = bool(release.config.values.get('DEIS_KUBERNETES_DEPLOYMENTS', settings.DEIS_KUBERNETES_DEPLOYMENTS)) # noqa
498-
499465
# see if the app config has deploy timeout preference, otherwise use global
500466
deploy_timeout = release.config.values.get('DEIS_DEPLOY_TIMEOUT', settings.DEIS_DEPLOY_TIMEOUT) # noqa
501467

@@ -529,7 +495,6 @@ def deploy(self, release, force_deploy=False):
529495
'deploy_batches': batches,
530496
'deploy_timeout': deploy_timeout,
531497
'deployment_history_limit': deployment_history,
532-
'deployments': deployments,
533498
'release_summary': release.summary
534499
}
535500

@@ -570,7 +535,7 @@ def deploy(self, release, force_deploy=False):
570535
self.verify_application_health(**kwargs)
571536

572537
# cleanup old release objects from kubernetes
573-
release.cleanup_old(deployments)
538+
release.cleanup_old()
574539

575540
def _default_structure(self, release):
576541
"""Scale to default structure based on release type"""

rootfs/api/models/release.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def delete(self, *args, **kwargs):
246246
finally:
247247
super(Release, self).delete(*args, **kwargs)
248248

249-
def cleanup_old(self, deployment=False):
249+
def cleanup_old(self):
250250
"""Cleanup all but the latest release from Kubernetes"""
251251
latest_version = 'v{}'.format(self.version)
252252
self.app.log(
@@ -307,8 +307,7 @@ def cleanup_old(self, deployment=False):
307307

308308
self._scheduler.delete_pod(self.app.id, pod['metadata']['name'])
309309

310-
if deployment:
311-
self._cleanup_deployment_secrets_and_configs(self.app.id)
310+
self._cleanup_deployment_secrets_and_configs(self.app.id)
312311

313312
def _cleanup_deployment_secrets_and_configs(self, namespace):
314313
"""
@@ -374,11 +373,6 @@ def _delete_release_in_scheduler(self, namespace, version):
374373
pass
375374

376375
def deployment_in_progress(self, namespace, name):
377-
# see if there is a global or app specific setting to specify Deployments usage
378-
deployments = bool(self.config.values.get('DEIS_KUBERNETES_DEPLOYMENTS', settings.DEIS_KUBERNETES_DEPLOYMENTS)) # noqa
379-
if not deployments:
380-
return False
381-
382376
try:
383377
ready, _ = self._scheduler.are_deployment_replicas_ready(namespace, name)
384378
return not ready

rootfs/api/settings/production.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,6 @@
270270
# where it roughly goes BATCHES * TIMEOUT = global timeout
271271
DEIS_DEPLOY_TIMEOUT = os.environ.get('DEIS_DEPLOY_TIMEOUT', 120)
272272

273-
# If the k8s Deployments object should be used instead of ReplicationController
274-
DEIS_KUBERNETES_DEPLOYMENTS = bool(os.environ.get('DEIS_KUBERNETES_DEPLOYMENTS', False))
275-
276273
KUBERNETES_DEPLOYMENTS_REVISION_HISTORY_LIMIT = os.environ.get('KUBERNETES_DEPLOYMENTS_REVISION_HISTORY_LIMIT', None) # noqa
277274

278275
# How long k8s waits for a pod to finish work after a SIGTERM before sending SIGKILL

rootfs/api/tests/deployments/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)