work around a bug in the k8s client that leaves trash in /tmp

This commit is contained in:
Ryan Petrello 2019-10-25 21:16:11 -04:00
parent 98d3f3dc8a
commit 3094b67664
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -4,6 +4,7 @@ import importlib
import sys
import traceback
from kubernetes.config import kube_config
from awx.main.tasks import dispatch_startup, inform_cluster_of_shutdown
@ -107,6 +108,14 @@ class TaskWorker(BaseWorker):
for callback in body.get('errbacks', []) or []:
callback['uuid'] = body['uuid']
self.perform_work(callback)
finally:
# It's frustrating that we have to do this, but the python k8s
# client leaves behind cacert files in /tmp, so we must clean up
# the tmpdir per-dispatcher process every time a new task comes in
try:
kube_config._cleanup_temp_files()
except Exception:
logger.exception('failed to cleanup k8s client tmp files')
for callback in body.get('callbacks', []) or []:
callback['uuid'] = body['uuid']