Delete the job first to prevent Kubernetes from starting another pod

This commit is contained in:
Joseph Schorr 2016-08-16 16:33:43 -04:00
parent 2caa82d091
commit 5e1a117ff3

View file

@ -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