You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/10/21 13:46:09 UTC

[GitHub] [airflow] dimberman commented on a change in pull request #6377: AIRFLOW-5589 monitor pods by labels instead of names

dimberman commented on a change in pull request #6377: AIRFLOW-5589 monitor pods by labels instead of names
URL: https://github.com/apache/airflow/pull/6377#discussion_r337026044
 
 

 ##########
 File path: airflow/contrib/operators/kubernetes_pod_operator.py
 ##########
 @@ -23,6 +25,28 @@
 from airflow.utils.state import State
 
 
+def create_labels_for_pod(context):
+    """
+    Generate labels for the pod s.t. we can track it in case of Operator crash
+    :param context:
+    :return:
+    """
+    labels = {
+        'dag_id': context['dag'].dag_id,
+        'task_id': context['task'].task_id,
+        'exec_date': context['ts']
+    }
+    # In the case of sub dags this is just useful
+    if context['dag'].parent_dag:
+        labels['parent_dag_id'] = context['dag'].parent_dag.dag_id
 
 Review comment:
   I'm thinking it's just a "nice" thing to have. Unless there's a rare race condition of people subDagging the same DAG at exactly the same time (which I highly doubt)
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services