You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jedcunningham (via GitHub)" <gi...@apache.org> on 2023/03/11 19:08:53 UTC

[GitHub] [airflow] jedcunningham commented on a diff in pull request #29929: Adding more information to kubernetes executor logs

jedcunningham commented on code in PR #29929:
URL: https://github.com/apache/airflow/pull/29929#discussion_r1133135031


##########
airflow/executors/kubernetes_executor.py:
##########
@@ -347,7 +356,12 @@ def run_next(self, next_job: KubernetesJobType) -> None:
         )
         # Reconcile the pod generated by the Operator and the Pod
         # generated by the .cfg file
-        self.log.info("Creating kubernetes pod for job is %s, with pod name %s", key, pod.metadata.name)
+        self.log.info(
+            "Creating kubernetes pod for job is %s, with pod name %s, annotations: %s",
+            key,
+            pod.metadata.name,
+            annotations_to_str(pod.metadata.annotations),
+        )

Review Comment:
   Don't need it here, this already has the key which contains basically the same info:
   
   ```
   Creating kubernetes pod for job is TaskInstanceKey(dag_id='simple', task_id='world', run_id='manual__2023-03-11T18:59:19.375564+00:00', try_number=1, map_index=-1), with pod name simple-world-58639fac88a74c38a2499d288b40e874
   ```



##########
tests/executors/test_kubernetes_executor.py:
##########
@@ -1253,6 +1253,21 @@ def test_supports_pickling(self):
     def test_supports_sentry(self):
         assert not KubernetesExecutor.supports_sentry
 
+    def test_annotations_to_str(self):
+        executor = self.kubernetes_executor
+        executor.scheduler_job_id = "modified"

Review Comment:
   ```suggestion
   ```



##########
airflow/kubernetes/kubernetes_helper_functions.py:
##########
@@ -119,3 +120,7 @@ def annotations_to_key(annotations: dict[str, str]) -> TaskInstanceKey:
         try_number=try_number,
         map_index=map_index,
     )
+
+
+def annotations_to_str(annotations: dict[str, str]) -> str:
+    return json.dumps(annotations)

Review Comment:
   I'm a little torn on adding them on every line in the first place, as we already have an INFO that correlates the pod_id to the TI.



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org