Fixed abort logic
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-04-19 16:43:42 +02:00
parent d8d20f0a78
commit e11b41f67a

View File

@ -213,10 +213,14 @@ class JobView(FlaskView):
else:
raise
if r.status.phase not in ['Succeeded', 'Failed']:
r = requests.post(f"http://{r.status.pod_ip}:{self.CONTROLLER_HTTP_PORT}/abort")
r.raise_for_status()
self._k8s_wait_pod_phase(pod_name, ['Succeeded', 'Failed'])
if r.status.phase == 'Running':
try:
r = requests.post(f"http://{r.status.pod_ip}:{self.CONTROLLER_HTTP_PORT}/abort")
r.raise_for_status()
self._k8s_wait_pod_phase(pod_name, ['Succeeded', 'Failed'])
except requests.exceptions.ConnectionError:
# Ignore failure to abort, k8s will kill the pod anyways
pass
try:
k8s.corev1api.delete_namespaced_pod(pod_name, current_app.config['WORKING_NAMESPACE'])