ashb 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_r337479786
 
 

 ##########
 File path: airflow/contrib/operators/kubernetes_pod_operator.py
 ##########
 @@ -112,55 +113,55 @@ class KubernetesPodOperator(BaseOperator):  # pylint: 
disable=too-many-instance-
     """
     template_fields = ('cmds', 'arguments', 'env_vars', 'config_file')
 
+    @staticmethod
+    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
+        # Replace unsupported characters with dashes & trim at 63 chars (max 
allowed)
 
 Review comment:
   This comment probably doesn't reflect what make_safe_label_value does 
anymore so
   ```suggestion
           # Ensure that label is valid for Kube, and if not trucate/remove 
invalid chars and replace with short hash.
   ```

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


With regards,
Apache Git Services

Reply via email to