From 5e1a117ff37cdde742f7e7a6e74fdb4ec2cbbaf5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 16 Aug 2016 16:33:43 -0400 Subject: [PATCH] Delete the job first to prevent Kubernetes from starting another pod --- buildman/manager/executor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buildman/manager/executor.py b/buildman/manager/executor.py index 82a438fb5..a3e3c24c3 100644 --- a/buildman/manager/executor.py +++ b/buildman/manager/executor.py @@ -408,6 +408,12 @@ class KubernetesExecutor(BuilderExecutor): def stop_builder(self, builder_id): pods_path = '/api/v1/namespaces/%s/pods' % self.namespace + # Delete the job itself. + try: + yield From(self._request('DELETE', self._job_path(builder_id))) + except: + logger.exception('Failed to send delete job call for job %s', builder_id) + # Delete the pod(s) for the job. selectorString = "job-name=%s" % builder_id try: @@ -415,12 +421,6 @@ class KubernetesExecutor(BuilderExecutor): except: logger.exception("Failed to send delete pod call for job %s", builder_id) - # Delete the job itself. - try: - yield From(self._request('DELETE', self._job_path(builder_id))) - except: - logger.exception('Failed to send delete job call for job %s', builder_id) - class LogPipe(threading.Thread): """ Adapted from http://codereview.stackexchange.com/a/17959