Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit f7fb2f6

Browse files
helgikmala
authored andcommitted
fix(release): during cleanup let pod deletion 404 in case Kubernetes cleaned up as well (#1005)
Fixes #1002
1 parent e9352a3 commit f7fb2f6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

rootfs/api/models/release.py

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

251-
def cleanup_old(self):
251+
def cleanup_old(self): # noqa
252252
"""Cleanup all but the latest release from Kubernetes"""
253253
latest_version = 'v{}'.format(self.version)
254254
self.app.log(
@@ -307,7 +307,12 @@ def cleanup_old(self):
307307
if current_version == latest_version:
308308
continue
309309

310-
self._scheduler.delete_pod(self.app.id, pod['metadata']['name'])
310+
try:
311+
self._scheduler.delete_pod(self.app.id, pod['metadata']['name'])
312+
except KubeHTTPException as e:
313+
# Sometimes k8s will manage to remove the pod from under us
314+
if e.response.status_code == 404:
315+
continue
311316

312317
self._cleanup_deployment_secrets_and_configs(self.app.id)
313318

rootfs/scheduler/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ def cleanup_release(self, namespace, controller, timeout):
153153
if self.pod_deleted(pod):
154154
continue
155155

156-
self.delete_pod(namespace, pod['metadata']['name'])
156+
try:
157+
self.delete_pod(namespace, pod['metadata']['name'])
158+
except KubeHTTPException as e:
159+
# Sometimes k8s will manage to remove the pod from under us
160+
if e.response.status_code == 404:
161+
continue
157162

158163
def _get_deploy_steps(self, batches, tags):
159164
# if there is no batch information available default to available nodes for app

0 commit comments

Comments
 (0)