Lee-W commented on code in PR #66948:
URL: https://github.com/apache/airflow/pull/66948#discussion_r3246796974


##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -411,17 +406,29 @@ def deactivate_stale_dags(
     ):
         """Detect and deactivate DAGs which are no longer present in files."""
         to_deactivate = set()
-        bundle_names = {b.name for b in self._dag_bundles}
+        active_bundles = set(
+            
session.scalars(select(DagBundleModel.name).where(DagBundleModel.active.is_(True))).all()
+        )
         query = select(
             DagModel.dag_id,
             DagModel.bundle_name,
             DagModel.fileloc,
             DagModel.last_parsed_time,
             DagModel.relative_fileloc,
-        ).where(~DagModel.is_stale, DagModel.bundle_name.in_(bundle_names))
+        ).where(~DagModel.is_stale)
         dags_parsed = session.execute(query)
 
         for dag in dags_parsed:
+            # DAGs whose bundle has been removed from config (bundle no longer 
active) are stale —
+            # the processor has stopped parsing their files, so the time-based 
check below would never fire.
+            if dag.bundle_name not in active_bundles:
+                self.log.info(
+                    "Deactivating DAG %s. Its bundle %s is no longer active.",
+                    dag.dag_id,

Review Comment:
    
   ```suggestion
               # Dags whose bundle has been removed from config (bundle no 
longer active) are stale —
               # the processor has stopped parsing their files, so the 
time-based check below would never fire.
               if dag.bundle_name not in active_bundles:
                   self.log.info(
                       "Deactivating Dag %s. Its bundle %s is no longer 
active.",
                       dag.dag_id,
   ```



##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -411,17 +406,29 @@ def deactivate_stale_dags(
     ):
         """Detect and deactivate DAGs which are no longer present in files."""
         to_deactivate = set()
-        bundle_names = {b.name for b in self._dag_bundles}
+        active_bundles = set(
+            
session.scalars(select(DagBundleModel.name).where(DagBundleModel.active.is_(True))).all()
+        )

Review Comment:
   we use "not" in the following operations. should we just make it something 
like this
   ```suggestion
           inactive_bundles = set(
               
session.scalars(select(DagBundleModel.name).where(DagBundleModel.active.is_(False))).all()
           )
   ```



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