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/15 17:06:47 UTC

[GitHub] [airflow] dimberman commented on a change in pull request #6340: [Airflow-5660] Try to find the task in DB before regressing to search…

dimberman commented on a change in pull request #6340: [Airflow-5660] Try to find the task in DB before regressing to search…
URL: https://github.com/apache/airflow/pull/6340#discussion_r335073047
 
 

 ##########
 File path: airflow/executors/kubernetes_executor.py
 ##########
 @@ -545,6 +545,26 @@ def _labels_to_key(self, labels):
             return None
 
         with create_session() as session:
+            # check if we can find the task directly before scanning
+            # every task with the execution_date
+            task = (
+                session
+                .query(TaskInstance)
+                .filter_by(task_id=task_id, dag_id=dag_id, execution_date=ex_time)
+                .first()
+            )
+            if task:
+                self.log.info(
+                    'Found matching task %s-%s (%s) with current state of %s',
+                    task.dag_id, task.task_id, task.execution_date, task.state
+                )
+                return (dag_id, task_id, ex_time, try_num)
+            else:
+                self.log.warning(
+                    "Unable to find Task in db directly for %s-%s (%s). Scan all tasks",
 
 Review comment:
   And add a link to k8s labeling guidelines?  https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

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