Vamsi-klu commented on code in PR #68518:
URL: https://github.com/apache/airflow/pull/68518#discussion_r3709981770
##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -299,6 +299,16 @@ class DagFileProcessorManager(LoggingMixin):
factory=_config_get_factory("dag_processor", "file_parsing_sort_mode")
)
+ dag_discovery_safe_mode: bool = attrs.field(
+ factory=_config_bool_factory("core", "DAG_DISCOVERY_SAFE_MODE")
+ )
+ """Resolved once per process so file discovery and the deactivation scan
use the same value.
+
+ When ``False`` the keyword heuristic is bypassed and every Python file is
scanned -- this must
+ apply consistently to discovery (:meth:`_find_files_in_bundle`) and to the
set of observed
+ filelocs (:meth:`_get_observed_filelocs`); otherwise freshly-parsed
keyword-less Dags are
+ deactivated right after being parsed (issue #66104)."""
Review Comment:
Done in a45c514830, collapsed to the suggested one-line docstring.
---
Drafted-by: Claude Code (Fable 5); reviewed by @Vamsi-klu before posting
##########
airflow-core/src/airflow/dag_processing/manager.py:
##########
@@ -925,8 +935,19 @@ def _find_files_in_bundle(self, bundle: BaseDagBundle) ->
list[Path]:
"""Get relative paths for dag files from bundle dir."""
# Build up a list of Python files that could contain DAGs
self.log.info("Searching for files in %s at %s", bundle.name,
bundle.path)
- rel_paths = [Path(x).relative_to(bundle.path) for x in
list_py_file_paths(bundle.path)]
- self.log.info("Found %s files for bundle %s", len(rel_paths),
bundle.name)
+ rel_paths = [
+ Path(x).relative_to(bundle.path)
+ for x in list_py_file_paths(bundle.path,
safe_mode=self.dag_discovery_safe_mode)
+ ]
+ # Logging the effective safe_mode makes a misconfigured dag-processor
diagnosable: a
+ # component left at the default safe_mode=True silently skips
keyword-less files even
+ # when the deployment set core.dag_discovery_safe_mode=False elsewhere
(issue #66104).
Review Comment:
Removed in a45c514830, the log line covers it.
---
Drafted-by: Claude Code (Fable 5); reviewed by @Vamsi-klu before posting
--
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]