mik-laj commented on a change in pull request #7261: [AIRFLOW-6641] Better 
diagnostics for kubernetes flaky tests
URL: https://github.com/apache/airflow/pull/7261#discussion_r370961585
 
 

 ##########
 File path: tests/runtime/kubernetes/test_kubernetes_executor.py
 ##########
 @@ -92,18 +96,39 @@ def monitor_task(self, host, execution_date, dag_id, 
task_id, expected_final_sta
                 tries += 1
             except requests.exceptions.ConnectionError as e:
                 check_call(["echo", "api call failed. trying again. error 
{}".format(e)])
-
+        if state != expected_final_state:
+            print("The expected state is wrong {} != {} 
(expected)!".format(state, expected_final_state))
+            self.dump_kubernetes_logs()
         self.assertEqual(state, expected_final_state)
 
-        # Maybe check if we can retrieve the logs, but then we need to extend 
the API
+    def dump_kubernetes_logs(self):
+        if os.environ.get('ENABLE_KIND_CLUSTER') == 'true':
+            self.dump_kind_logs()
+
+    def dump_kind_logs(self):
+        tempdir_path = mkdtemp()
 
 Review comment:
   I think it's better to use `tempfile.TemporaryDirectory`. Using mkdtemp is 
an old approach and is often dangerous because the file is not deleted 
automatically. This is a small nit in tests, but there was one issues that 
caught my eye.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to