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 2021/06/10 22:11:19 UTC

[GitHub] [airflow] jedcunningham commented on a change in pull request #16368: Don't show stale Serialized DAGs if they are deleted in DB

jedcunningham commented on a change in pull request #16368:
URL: https://github.com/apache/airflow/pull/16368#discussion_r649565547



##########
File path: airflow/models/dagbag.py
##########
@@ -199,7 +201,13 @@ def get_dag(self, dag_id, session: Session = None):
                     dag_id=dag_id,
                     session=session,
                 )
-                if sd_last_updated_datetime and sd_last_updated_datetime > self.dags_last_fetched[dag_id]:
+                if not sd_last_updated_datetime:
+                    self.log.warning("Serialized DAG does not exist for '%s'", dag_id)
+                    del self.dags[dag_id]
+                    del self.dags_last_fetched[dag_id]
+                    del self.dags_hash[dag_id]
+                    return None
+                elif sd_last_updated_datetime > self.dags_last_fetched[dag_id]:
                     self._add_dag_from_db(dag_id=dag_id, session=session)

Review comment:
       ```suggestion
                   
                   if sd_last_updated_datetime > self.dags_last_fetched[dag_id]:
                       self._add_dag_from_db(dag_id=dag_id, session=session)
   ```
   
   nit, since we short circuit




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