Repository navigation
Conversation
4b1de2c to
8881392
Compare
52db297 to
8b6bae0
Compare
shahar1
left a comment
There was a problem hiding this comment.
Thanks for working through the earlier points. All four are addressed at 821aa2b: the forced read for unknown names is throttled, teams are checked before any rows are written, the body is corrected, and template signing is retried. The reload design and the tests read well. One new minor point is inline, about the per-check import-error cleanup.
Smaller observations
- See the inline comment on
airflow-core/src/airflow/dag_processing/bundles/manager.py:615. - Process: the
backport-to-v3-4-testlabel is still on the PR. Aspotiuknoted, this is a new feature that changes the unreleased2027-02-28supervisor schema version, and the Task SDK onmainnow requiresapache-airflow-core>=3.5.0. It should ship in 3.5 only. I'll remove the label.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The findings
below are observations, not blockers; an Apache Airflow
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Airflow handles maintainer review:
Contributing guide.
With configuration reload enabled, every check deleted import errors again for each bundle ever removed, so the cleanup grew with every removal and repeated every few seconds. Errors published after a bundle is deactivated by a processor that has not seen the removal are left until an unfiltered Dag processor restarts.
|
My concern is how "reload mode" is put into the code. The code makes it a condition that call sites check, not a thing that is modelled. I would prefer it be done by modelling the source as an object and giving consumers a resolved context. Add a private interface with two implementations (static vs reloadable) as mentioned in the inline comment. The source is chosen once per process and owns the accepted snapshot, the throttle and the miss cache.
|
Reload mode was a condition that call sites checked, and the cached configuration was mutated in place, so a second cache entry could drift with its own throttle and run the command again. A source chosen once per process now owns the accepted list, the throttle and the cache of missing names, and parsing processes receive a typed per-bundle context that the Go and TypeScript schemas can describe. The Dag processor also parses at startup only the bundles it has written to the database. Co-authored-by: Cursor <[email protected]>
…ag-bundle-config Co-authored-by: Cursor <[email protected]> # Conflicts: # airflow-core/src/airflow/dag_processing/bundles/manager.py # airflow-core/tests/unit/dag_processing/bundles/test_dag_bundle_manager.py
Celery workers run the stale bundle version cleanup for their whole life, but a new DagBundlesManager only copies the bundle list the process already holds and never reads the command or secret again. Bundles added after the worker started were never cleaned up. Co-authored-by: Cursor <[email protected]>
When no importer registry was cached, for example for a removed bundle, the callback and parse checks fell back to the Task SDK registry, which reads dag_bundle_config_list directly. Now that the key honours _cmd and _secret, a failing command ran on every callback regardless of bundle_refresh_check_interval, and a successful one could build importers from a list the Dag processor had not accepted. Co-authored-by: Cursor <[email protected]>
| def is_bundle_config_reload_enabled() -> bool: | ||
| """Return whether this process reads the bundle configuration again from a command or secrets backend.""" | ||
| return isinstance(_get_bundle_config_source(), _ReloadingBundleConfigSource) |
There was a problem hiding this comment.
I don’t think we need to send a context in static mode (and change the parsing path). We can add parse_context(name) -> BundleParseContext | None to the source. The static source returns None, so the static path stays exactly as it is today. The reloading source returns the accepted context. The same goes for the HTTP-mode guard and _reconcile_bundles (source.reconcilable). The call sites then ask the source what to do, instead of what it is, and is_bundle_config_reload_enabled can go. I'd rather this land in this PR than in a follow-up since the follow-up would touch the same call sites again.
There was a problem hiding this comment.
Got it, thanks, I have done as mentioned.
| def _get_bundle_config_reload_option() -> tuple[str, str] | None: | ||
| section, key = "dag_processor", "dag_bundle_config_list" | ||
| env_key = "AIRFLOW__DAG_PROCESSOR__DAG_BUNDLE_CONFIG_LIST" | ||
| if env_key in os.environ: | ||
| return None | ||
| for suffix in ("cmd", "secret"): | ||
| env_option = f"{env_key}_{suffix.upper()}" | ||
| if env_option in os.environ: | ||
| return suffix, os.environ[env_option] | ||
| if ConfigParser.has_option(conf, section, key): | ||
| return None | ||
| for suffix in ("cmd", "secret"): | ||
| option = f"{key}_{suffix}" | ||
| if ConfigParser.has_option(conf, section, option): | ||
| return suffix, ConfigParser.get(conf, section, option) | ||
| return None |
There was a problem hiding this comment.
This is still a copy from AirflowConfigParser. Expose a supported helper in the shared configuration module that returns the _cmd/_secret source for an option, and build the reloading source from that.
There was a problem hiding this comment.
Removed the copy. Now, get_dynamic_option_reader() and _get_bundle_config_source() builds the reloading source
| if is_bundle_config_reload_enabled(): | ||
| bundle_config = self._dag_bundle_manager.get_bundle_parse_context(dag_file.bundle_name) |
There was a problem hiding this comment.
get_bundle_parse_context() still raises ValueError for a name that isn't configured. If a callback file for a bundle removed in that check is still queued, the main loop crashes here. Purge _callback_to_execute for removed bundles, or handle the error, and add a test either way.
There was a problem hiding this comment.
Thanks, this was an good fine, I missed it.
Also added specific tests so not miss in future
|
|
||
| bundles = list(DagBundlesManager().get_all_dag_bundles()) | ||
| manager = DagBundlesManager() | ||
| manager.get_all_bundle_names() |
There was a problem hiding this comment.
This is too unobvious. Give the manager an explicit refresh() instead.
There was a problem hiding this comment.
Got it, i was reluctant on previously adding explicit refresh as public, but as per your shared model, I have refactored into interface and classes, and replaced this
…-bundle-config # Conflicts: # task-sdk/src/airflow/sdk/coordinators/_subprocess.py # task-sdk/src/airflow/sdk/execution_time/schema/versions/v2027_02_28.py
Duplicating AirflowConfigParser lookup precedence in the Dag bundle manager risked drifting from shared configuration semantics, while boolean reload checks forced call sites to inspect the source type instead of delegating behavior. Implicitly refreshing inside get_all_bundle_names() also hid side effects from callers, and queued callbacks for bundles removed during reconciliation could still raise ValueError in the parsing loop.
Avoid adding new public classes or methods to AirflowConfigParser and DagBundlesManager where an internal shared configuration helper and the private bundle config source already cover every production caller.
A bad reload must leave running processors on the last adopted configuration without exposing sensitive input or making parsers and health probes depend on another read. Keep maintenance work bounded so bundle removal does not hold the processor loop.
| class _StaticBundleConfigSource: | ||
| """The bundle configuration of this process, read from ``dag_bundle_config_list`` on first use.""" | ||
|
|
||
| reconcilable: ClassVar[bool] = False |
There was a problem hiding this comment.
This now decides a lot of things. I’m thinking we can do it somehow like this
class _BaseLifecycle:
def __init__(self, processor: DagFileProcessorManager) -> None: ...
def check_supported(self) -> None: ...
def reconcile(self, known_files: dict[str, set[DagFileInfo]]) -> None: ...
def cleanup(self) -> None: ...
class _BaseBundleConfigSource:
lifecycle_class: ClassVar[type[_BaseBundleLifecycle]]
def parse_context(self, name: str) -> BundleParseContext | None: ...
def get_bundle_teams(self) -> dict[str, str | None]: ...
class _StaticBundleConfigSource(_BaseBundleConfigSource):
class lifecycle_class(_BaseLifecycle): ...
# Implementat methods...
class _ReloadingBundleConfigSource(_BaseBundleConfigSource):
class lifecycle_class(_BaseLifecycle): ...
# Implementat methods...this would gather logic all onto the bundle config source classes instead of scattered around with a flag check. It’s also clearer that the static and reloading sources are two separate things, reloading does not subclass (“is kind of”) static.
There was a problem hiding this comment.
Got it, this is inline with interface and then multiple impl in future. I have followed the model in the PR. _BaseBundleConfigSource is the base with two impl, one static and one dynamic.
One diff is that, in the impl, the lifecycle classes are module level classes that lifecycle class refers to, rather than nested classes.
…-bundle-config # Conflicts: # airflow-core/src/airflow/api/common/airflow_health.py # airflow-core/src/airflow/dag_processing/manager.py # go-sdk/pkg/execution/genmodels/models.gen.go # scripts/ci/prek/check_security_doc_constants.py
Review feedback asked for reload mode to be modelled rather than checked at each call site. The configuration source is chosen once per process, so the Dag processor, health checks and parsing can ask it what to do instead of testing whether reload is enabled.
The bundle lifecycle only needs to decide whether a processor reconciles bundles and sweeps import errors. Leaving the reconciliation and the import-error sweep on the Dag processor keeps each algorithm in one place, next to the queues it updates, and keeps processor maintenance out of the bundle configuration module.
A bundle whose constructor fails is not parsed, but the periodic sync still stored it as active. Health checks and other readers of the active bundle rows then counted a bundle that no Dag processor was processing, unlike startup, which never records such a bundle.
Restricting new bundle rows to constructed bundles could not cover a re-added bundle, because stored rows must stay reactivatable for Dag processors to repair each other's active state. It also stopped filtered processors from storing hot-added bundles as they do at startup. Health in reload mode reads active rows as the declared bundles, so a configured bundle stays active while it is retried.
Health in reload mode now counts only the bundles the deployment declares, as with a static list. A failed command reports its exit status so operators can find the cause, while its command, output and errors stay hidden.
Thanks for detailed review. I have addressed this comment, and now bundle type lifecycle is managed properly through base class, and assosiated impls |
Summary
Devlist discuss thread: https://lists.apache.org/thread.html/860cv5t71v5mnq59b50fk5891lv5nh26
Lazy consensus thread: https://lists.apache.org/thread.html/jm76cmcr6gofw8xq4rlp8k5q10sqz2h6
Dag processors currently read the bundle list only at startup. A deployment must restart them to add or remove a bundle. In a large deployment, these restarts are difficult when bundles are added frequently.
This PR adds the capability of hot reload using the existing
dag_bundle_config_list. The Dag processor checks for changes at the existingbundle_refresh_check_interval. The configuration source returns the complete list of bundles.A deployment can supply the list through Airflow's existing
_CMDor_SECRETconfiguration mechanism. For example, a command can read a file or call an internal API:Existing literal environment variables and
airflow.cfgvalues keep their startup behavior. Users do not need to rename their environment variables unless they want to enable reload. The ordinary environment variable takes precedence over_CMDand_SECRET.Behavior
For example, a deployment can publish these lists without restarting the Dag processor:
[]removes all bundles. Blank output is treated as a failed read, so a command must report a failure rather than return[].[]starts with no bundles.--bundle-namestop parsing removed bundles locally, but never deactivate missing bundles globally. An unfiltered processor is needed for global deactivation.Note: For v1, hot reload is supported only for database backed Dag processors. HTTP-backed Dag processors (recently added feature) can continue using a literal dag_bundle_config_list. If _CMD or _SECRET is configured with an HTTP-backed processor, it will fail at startup with a clear error. HTTP-mode reload is outside the scope of this PR
Multiple Dag processors
The approach allows eventual convergence. Processors may see a change at different times. For example:
[finance].[]and marksfinanceinactive.financeactive again, then stops permanently.Each unfiltered processor reconciles bundle active state with the database on every check, even when its local list has not changed. Processor B can therefore repair that stale write. The state converges when surviving processors see the same list and continue processing; the change is not immediate across all hosts.
Finish existing Dag runs before removing a bundle if those runs need to complete. Tasks and callbacks can still need its definition.
This PR is based on
mainand can be reviewed independently of #73209 and #73217. It adds no public source class, new configuration option, database migration.This PR adds an optional bundle_config field to DagFileParseRequest and the internal StartLangSDKRuntime message. This is required to carry the accepted importer settings and team ownership, so parsingprocess do not read the bundle configuration source again.
The configuration key is marked sensitive to support
_CMDand_SECRET, so configuration views that hide sensitive values will also hide this value.Test Plan
Along with the OSS unit tests, also performed integration testing in local
Case: Bundle discovery and removal
Case: source failure keeps the accepted list
API server:

Case: Construction and database synchronization retry
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-6) following the guidelines