uranusjr commented on code in PR #27720:
URL: https://github.com/apache/airflow/pull/27720#discussion_r1027613221


##########
airflow/jobs/scheduler_job.py:
##########
@@ -1307,20 +1309,27 @@ def _schedule_dag_run(
 
         return callback_to_run
 
-    def _verify_integrity_if_dag_changed(self, dag_run: DagRun, session: 
Session) -> None:
-        """Only run DagRun.verify integrity if Serialized DAG has changed 
since it is slow"""
+    def _verify_integrity_if_dag_changed(self, dag_run: DagRun, session: 
Session) -> bool:
+        """
+        Only run DagRun.verify integrity if Serialized DAG has changed since 
it is slow.
+
+        Return True if we determine that DAG still exists.
+        """
         latest_version = 
SerializedDagModel.get_latest_version_hash(dag_run.dag_id, session=session)
         if dag_run.dag_hash == latest_version:
             self.log.debug("DAG %s not changed structure, skipping 
dagrun.verify_integrity", dag_run.dag_id)
-            return
+            return True
 
         dag_run.dag_hash = latest_version
 
         # Refresh the DAG
         dag_run.dag = self.dagbag.get_dag(dag_id=dag_run.dag_id, 
session=session)
+        if not dag_run.dag:
+            return False

Review Comment:
   Maybe this should be an exception (caught outside) instead; returning True 
and False doesn’t feel natural.
   
   Or maybe we should refactor the code around this to be
   
   ```python
   # This returns
   # a. DAG is it changed.
   # b. None if not changed.
   # c. None if the DAG is not found in DagBag, with a log message.
   refreshed_dag = self._get_changed_dag_()
   if refreshed_dag is not None:
       dag_run.dag = refreshed_dag
       dag_run.verify_integrity(session=session)
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to