From 3d91dcd3add8896c0e0540e32c99dae58ba10da7 Mon Sep 17 00:00:00 2001 From: Amit Srivastava Date: Fri, 3 Nov 2017 13:50:06 -0700 Subject: [PATCH] Check if the cached temp conf file still exists before using it. On some systems older unused temp files get cleaned up regularly. So, we cannot rely on the availability of the temp_files in long running processes. --- config/kube_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/kube_config.py b/config/kube_config.py index 9a99ecf7..84913317 100644 --- a/config/kube_config.py +++ b/config/kube_config.py @@ -49,7 +49,7 @@ def _create_temp_file_with_content(content): # Because we may change context several times, try to remember files we # created and reuse them at a small memory cost. content_key = str(content) - if content_key in _temp_files: + if content_key in _temp_files and os.path.isfile(_temp_files[content_key]): return _temp_files[content_key] _, name = tempfile.mkstemp() _temp_files[content_key] = name