Repository navigation
Conversation
A single Dag processor parses every Dag bundle, so a heavy or failing bundle cannot be scaled, sized or scheduled apart from the others. Sets mirror workers.celery.sets, so each set can override any dagProcessor setting and parse only the bundles it selects, while bundles stay defined once in dagBundleConfigList. related: apache#61037 Co-authored-by: SeonghwanLee <[email protected]> Signed-off-by: Xch1 <[email protected]>
The default Dag processor parses every Dag bundle, so keeping it enabled next to sets that select bundles silently parses those bundles twice. Unlike worker queues, the default Dag processor does not take a separate share of the work, so deriving enableDefault from sets avoids a misconfiguration that gives no error. An explicit true or false is still honoured. related: apache#61037 Co-authored-by: SeonghwanLee <[email protected]> Signed-off-by: Xch1 <[email protected]>
Can't review if you haven't tested it e2e and show screenshot, gifs, videos of that |
|
@kaxil recording-b-isolation.mp4What I ran: the whole chart on kind (Kubernetes v1.31.12) with an image built from this checkout, not only the Setup: two dagProcessor:
sets:
- {name: set-a, bundleNames: [bundle_a]}
- {name: set-b, bundleNames: [bundle_b]}Deployment and UI
Chart behaviour
Isolation
Tests
Drafted-by: Claude Code (Sonnet 5.5) |
aaron-y-chen
left a comment
There was a problem hiding this comment.
Thanks for the contribution! Great job :)
|
@aaron-y-chen dagProcessor:
enableDefault: true
podDisruptionBudget: {enabled: true}
sets:
- name: set-a
command: [airflow]
args: [dag-processor, --bundle-name, bundle_a]
bundleNames: [bundle_a]
- name: set-b
bundleNames: [bundle_b]
serviceAccount: {create: true, name: team-b} 1. Default PDB also selected the sets' Pods
2. A set's
3.
Other cases I ran on the cluster with the fixed chart
Stability and tests
Generated-by: Claude Code (Sonnet 5.5) |
Signed-off-by: Chao-Hung Wan <[email protected]>
…into chart-dag-processor-sets
stegololz
left a comment
There was a problem hiding this comment.
Thanks for picking this up!
I proposed triggerer and dag processor sets on dev@ (https://lists.apache.org/thread/gbyh213vy957bn63nvhfh884j83tvzcv), and this PR covers the dag processor side well, so I'll only do triggerer.sets separately, following the conventions here (enableDefault, dag-processor-set label, PDB exclusion, SA handling) so both can later move onto one shared set helper.
We run per-team dag processors on a multi-team setup with one processor per bundle through a wrapper chart, and checked this branch against the cases we hit there. A few inline notes, all reproduced with helm template on ea54876e.
| {{- $dagProcessor := include "workersMergeValues" (list $.Values.dagProcessor $dagProcessorSet) | fromYaml -}} | ||
| {{- $_ := set $globals.Values "dagProcessor" $dagProcessor -}} | ||
| {{- with $globals -}} | ||
| {{- if .Values.dagProcessor.serviceAccount.create -}} |
There was a problem hiding this comment.
A set ServiceAccount is created here, but rbac/security-context-constraint-rolebinding.yaml (L113-116) still binds only dagProcessor.serviceAccountName of the parent values. With rbac.createSCCRoleBinding: true, enableDefault: false and a set using serviceAccount: {create: true, name: team-a}, the rolebinding lists t-airflow-dag-processor but never team-a, so that set's pods lose the SCC binding on OpenShift. Looping over the rendered SA names there would fix it.
(Worker sets on main have the same gap in that file and in pod-launcher-rolebinding.yaml. Fine to keep that out of scope here.)
There was a problem hiding this comment.
Good catch. I will loop over the Dag processor ServiceAccount names the chart actually renders in the SCC rolebinding, using the same name resolution as the ServiceAccount template, and add a test for it. Agreed to leave the worker sets out of this PR.
Drafted-by: Claude Code (Sonnet 5.5)
| {{- if $enableDefault -}} | ||
| {{- $dagProcessorSets = concat (list (dict "name" "default")) $dagProcessorSets -}} | ||
| {{- end -}} | ||
| {{- range $dagProcessorSet := $dagProcessorSets -}} |
There was a problem hiding this comment.
Set names aren't validated, and these all render without error:
- two sets named
xgive two Deploymentst-dag-processor-x; - a set named
defaultwithenableDefault: truegives twot-dag-processor; team_agivest-dag-processor-team_a, which the API server rejects (not DNS-1123).
A fail on duplicate names, on default, and on names that aren't DNS-1123 labels would catch these at render time.
There was a problem hiding this comment.
Agreed. I will add a render-time fail for duplicate set names, a set named default, and names that are not DNS-1123 labels, with a test for each.
Drafted-by: Claude Code (Sonnet 5.5)
| {{- end }} | ||
| {{- $renderedArgs := tpl (toYaml $args) $dagProcessorContext }} | ||
| {{- range . }} | ||
| {{- if not (has . $definedBundles) }} |
There was a problem hiding this comment.
Two things here:
- Same bundle in two sets:
bundleNames: [b1]in two sets renders both, sob1gets parsed by two processors. A check that each bundle is claimed by at most one set would help; we hit this in our own setup. - Substring match (nit): the
contains . $renderedArgscheck on L64 matches substrings, so a bundleb1passes when args only contain--bundle-name 'b10'.
There was a problem hiding this comment.
The substring match is a bug in my check. I will compare the full --bundle-name value and add a test.
For the same bundle in two sets, I would not make it a hard fail. The chart already allows one bundle on several Pods (replicas: 2), moving a bundle between sets needs a short overlap, and workers.celery.sets does not forbid two sets on one queue either.
Instead I suggest a warning in NOTES.txt. I checked it on a kind cluster with helm install --dry-run and helm upgrade --dry-run=server: with set-a and set-b both selecting bundle_a it prints Dag bundle "bundle_a" is selected by more than one Dag processor set (set-a, set-b), so it is parsed by each of them., and nothing without overlap or without sets. It is only shown on install/upgrade (not helm template) and chart tests cannot cover it, so fail stays for the cases that can never work (point 2).
I am fine with a hard fail if you prefer, as long as both set types follow the same rule.
Drafted-by: Claude Code (Sonnet 5.5)
…or SCC A set name ends up in the Deployment name and in a Pod label, so duplicate, `default` or non-DNS-1123 names rendered manifests that collided with each other or were rejected by the API server. They now fail at render time. The OpenShift SCC role binding only listed the parent Dag processor ServiceAccount, so a set that uses its own ServiceAccount lost the SCC binding. It now lists the ServiceAccount of every Dag processor Deployment. The check that custom `args` select each bundle compared substrings, so bundle `b1` was accepted when the args only selected `b10`. It now matches the whole `--bundle-name` value. A bundle selected by more than one set is only reported with a warning on `helm install` and `helm upgrade`, not rejected, because parsing a bundle in several processors is already possible with `replicas` and is needed while moving a bundle between sets.
Helm reports a missing required property as "missing property 'name'" or "name is required" depending on its version, so the test matched only one of them.
The default Dag processor is not created next to sets unless enableDefault is true, so the cases that expected its ServiceAccount did not set it.
|
@stegololz Thanks for the review. Summary of what this update changes and how it was tested. What changed
What was tested
Help needed: OpenShift SCC Generated-by: Claude Code (Sonnet 5.5); |
potiuk
left a comment
There was a problem hiding this comment.
Thanks for taking this over and for the end-to-end recording. The design follows workers.celery.sets closely, and the tests cover the earlier review rounds well. Two things need work before this can go in: a sets-only deployment never deactivates a removed bundle (inline), and the set-expansion logic is copied into four templates and needs to move into one shared helper (below). The rest are smaller edge cases. stegololz's three threads look handled by 24fa057. Please resolve them or reply once stegololz confirms, especially the NOTES.txt warning versus a hard failure for a bundle shared by two sets.
Quality signals to check (chart/templates/dag-processor/dag-processor-deployment.yaml:42)
Document the removed-bundle limitation of sets-only deployments, or address it in core.
Flagged by both the primary and adversarial reviewers.
Code quality (chart/templates/dag-processor/)
Please de-duplicate: move the set expansion, the enableDefault derivation and the set validation into one _helpers.yaml helper, and use it from the Deployment, PDB, ServiceAccount, SCC RoleBinding and NOTES.txt. Today the block is copied four times (plus a fifth variant in NOTES.txt), and several findings in this review come from those copies already disagreeing. One helper keeps them consistent and gives triggerer.sets a base to reuse instead of a sixth copy.
Smaller observations
- See inline comments on
chart/templates/dag-processor/dag-processor-poddisruptionbudget.yaml:69,chart/templates/dag-processor/dag-processor-deployment.yaml:110,chart/templates/dag-processor/dag-processor-deployment.yaml:42,chart/templates/dag-processor/dag-processor-deployment.yaml:112,chart/templates/NOTES.txt:156,chart/templates/dag-processor/dag-processor-deployment.yaml:78,chart/values.yaml:2196,chart/values.yaml:2153.
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.
| {{- end -}} | ||
| {{- $enableDefault := .Values.dagProcessor.enableDefault -}} | ||
| {{- if kindIs "invalid" $enableDefault -}} | ||
| {{- $enableDefault = not .Values.dagProcessor.sets -}} |
There was a problem hiding this comment.
When sets is non-empty, enableDefault now defaults to false, so a typical "one set per bundle" setup has no Dag processor running without --bundle-name. In core, DagFileProcessorManager.sync_bundles calls sync_bundles_to_db(deactivate_missing=not self.bundle_names_to_parse) (airflow-core/src/airflow/dag_processing/manager.py:334), so every set-scoped processor skips deactivating bundles that were removed from dagBundleConfigList. If a bundle and its set are later removed, the bundle is never marked inactive, deactivate_stale_dags never takes its "bundle no longer active" branch, and nothing parses those files any more, so their Dags stay active in the UI. Please document this in manage-dag-files.rst (and say how to clean up, e.g. a one-off run or temporarily enabling the default processor), or cover it on the core side.
There was a problem hiding this comment.
Documented in a new "Removing a Dag bundle" section of manage-dag-files.rst. After removing a
bundle and its set, run airflow dags reserialize --bundle-name <bundle> once in the
dag-processor container of a remaining set. It calls sync_bundles_to_db() with the full
config, so bundles that are no longer configured are marked inactive. The alternative is to set
enableDefault: true until the Dags are gone. The scheduler then marks the Dags stale
(cleanup_processor_metadata, every scheduler.parsing_cleanup_interval).
Checked on kind (sets-only, set-a → bundle_a, set-b → bundle_b,
parsing_cleanup_interval: 30):
| Step | dag_bundle.active (a / b) |
is_stale (a / b) |
|---|---|---|
| Before | t / t | f / f |
90s after removing bundle_b and set-b |
t / t | f / f |
After reserialize --bundle-name bundle_a (exit 0) |
t / f | f / f |
| 90s later | t / f | f / t |
The scheduler logged Deactivating Dag because its bundle is no longer active bundle_name=bundle_b.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| dag-processor-set: {{ .Values.dagProcessor.name }} | ||
| {{- end }} | ||
| {{- if and (eq .Values.dagProcessor.name "default") $setsWithPdb }} | ||
| matchExpressions: |
There was a problem hiding this comment.
NotIn only excludes sets that have their own PDB. A set with podDisruptionBudget.enabled: false is still selected by the default PDB, so its Pods count toward the default Deployment's maxUnavailable / minAvailable. An unhealthy opt-out Pod can then block node drains of healthy default Pods, which is the opposite of what the set asked for and differs from the docs ("A PodDisruptionBudget selects the Pods of a single Deployment"). When sets is non-empty, key: dag-processor-set, operator: DoesNotExist would keep the default PDB to its own Pods, and the selector stays unchanged when there are no sets.
There was a problem hiding this comment.
Done: when sets is not empty, the default PDB uses dag-processor-set DoesNotExist. The
selector is unchanged without sets. On kind with enableDefault: true and set-b opting out, the
default, set-a and set-b Pods all ran. The default PDB and set-a's PDB each reported
expectedPods: 1, and set-b had no PDB, so no PDB counts the set-b Pod.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| component: dag-processor | ||
| release: {{ .Release.Name }} | ||
| {{- if ne .Values.dagProcessor.name "default" }} | ||
| dag-processor-set: {{ .Values.dagProcessor.name }} |
There was a problem hiding this comment.
The set name is written unquoted into the label. A name such as 123 passes the DNS-1123 check but renders dag-processor-set: 123, a YAML integer, and the API server rejects it because label values must be strings (checked with helm template). The same applies at L122 and in the PDB selector. {{ .Values.dagProcessor.name | quote }} fixes all three.
There was a problem hiding this comment.
Quoted in the Deployment selector, the Pod labels and the PDB selector. A set named 123 renders
dag-processor-set: "123", and the Deployment was accepted and ran on kind.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| {{- end -}} | ||
| {{- $enableDefault := .Values.dagProcessor.enableDefault -}} | ||
| {{- if kindIs "invalid" $enableDefault -}} | ||
| {{- $enableDefault = not .Values.dagProcessor.sets -}} |
There was a problem hiding this comment.
With enableDefault: false and sets: [], nothing is rendered and there is no error, while dagProcessor.enabled: true still makes the scheduler skip its Dag mounts. A render-time fail for this case would catch the misconfiguration.
There was a problem hiding this comment.
This now fails at render time: "dagProcessor.enableDefault is false and dagProcessor.sets is
empty, so no Dag processor would run; …".
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| {{- if ne .Values.dagProcessor.name "default" }} | ||
| dag-processor-set: {{ .Values.dagProcessor.name }} | ||
| {{- end }} | ||
| {{- if .Values.dagProcessor.strategy }} |
There was a problem hiding this comment.
strategy is not in the workersMergeValues full-overwrite list, so it is deep-merged. A set with strategy: {type: Recreate} renders type: Recreate together with the inherited rollingUpdate block (checked with helm template), which the API server rejects. Either document that a set must also set rollingUpdate: null, or overwrite strategy as a whole for sets.
There was a problem hiding this comment.
A set's strategy now replaces the parent's as a whole, which is documented. On kind, a set with
strategy: {type: Recreate} renders {"type":"Recreate"} and is accepted.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
|
|
||
| {{- $bundleClaims := dict }} | ||
| {{- if .Values.dagProcessor.enabled }} | ||
| {{- range .Values.dagProcessor.sets | default list }} |
There was a problem hiding this comment.
The overlap warning only compares raw sets[*].bundleNames. It says nothing for the default processor running next to sets with no bundleNames (the double-parse case the PR description calls out), for sets inheriting the parent bundleNames, or for a set with no bundleNames (which parses everything). It also reports a single set that repeats a bundle as (a, a). Building it from the merged values would cover these cases.
There was a problem hiding this comment.
The warning is now built from the merged values of every Dag processor (dagProcessor.bundleOverlaps).
It covers the default processor next to sets, sets that inherit the parent bundleNames, and sets
without bundleNames (which parse every bundle), and it de-duplicates a bundle repeated in one set.
Since helm template does not render NOTES.txt, the helper is tested through a copy of the chart.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| {{- if not (has . $definedBundles) }} | ||
| {{- fail (printf "Bundle %q is not defined in `dagProcessor.dagBundleConfigList`" .) }} | ||
| {{- end }} | ||
| {{- if not (regexMatch (printf "--bundle-name(=|\\s+(-\\s+)?)['\"]*%s['\"]*(\\s|$)" (regexQuoteMeta .)) $renderedArgs) }} |
There was a problem hiding this comment.
The args check only accepts --bundle-name. The CLI also accepts -B (airflow-core/src/airflow/cli/cli_config.py:162), and the check doesn't look at a custom command used with args: ~. Such valid setups fail to render.
There was a problem hiding this comment.
-B is accepted now (-B x, -Bx, -B=x), and the check looks at command together with
args, so command: [bash, -c, "exec airflow dag-processor -B x"] with args: ~ renders.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| args: | ||
| - "bash" | ||
| - "-c" | ||
| - "exec airflow dag-processor{{ range .Values.dagProcessor.bundleNames }} --bundle-name {{ . | squote }}{{ end }}" |
There was a problem hiding this comment.
squote doesn't escape an embedded ', so a bundle name with an apostrophe breaks the bash -c command. Bundle names are not restricted in core. Either check bundle names against a safe character set in the chart, or pass the flags as separate argv items.
There was a problem hiding this comment.
The default args now take the flags from a helper that quotes each name for a POSIX shell
(' → '\''). On kind, a bundle named it's_c started and was parsed with
--bundle-name 'it'\''s_c'. Outside the chart: core rejects such a name for some metric names
(InvalidStatsNameException in the Dag processor log), but parsing and serialization still work.
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
| # unless `bundleNames` is set, so bundles selected by a set would then be parsed twice. | ||
| enableDefault: ~ | ||
|
|
||
| # Names of the bundles from `dagBundleConfigList` this dag processor parses |
There was a problem hiding this comment.
"If empty, the dag processor parses all the bundles" isn't true for a set when the parent sets bundleNames: workersMergeValues ignores an empty-list override, so bundleNames: [] on a set inherits the parent's list. Worth saying so here and in the docs. Also, new text in values.yaml and values.schema.json says "dag processor"; the project writes it as "Dag processor".
There was a problem hiding this comment.
Documented in values.yaml, the schema and the docs: a set inherits the parent bundleNames when
it does not set them or sets an empty list. The new text now says "Dag processor".
Drafted-by: Claude Code (Opus 5.5); reviewed by xchwan before posting
The set expansion, enableDefault derivation and validation were copied into five templates, and the copies had already started to disagree. Review also found setups that rendered but could not run as intended: a set without its own PodDisruptionBudget still counted toward the default one, numeric set names produced non-string labels, a set's Recreate strategy inherited rollingUpdate, bundle names with quotes broke the shell command, valid -B or command-only selections were rejected, and no Dag processor at all was accepted silently. The overlap warning missed the default processor and inherited bundleNames, and sets-only deployments never deactivate removed bundles, which users need to know how to clean up. Generated-by: Claude Code
The scheduler, not the Dag processors, marks the Dags of an inactive bundle as stale, and sets replace lists and several settings as a whole rather than merging every key, so the docs sent users to the wrong place and described overrides that do not happen. Generated-by: Claude Code
The docs build rejects the word used to describe what the reserialize command does to the remaining bundle. Generated-by: Claude Code
|
Thanks for the review. Everything is addressed in a2aa205, f875273 and 7fd63d8. The branch also
One core issue showed up on a fresh database. When several set processors start at the same time, Drafted-by: Claude Code (Opus 5.5); reviewed by |

A single Dag processor parses every Dag bundle, so a heavy or failing bundle cannot be scaled, sized or scheduled apart from the others. Sets mirror workers.celery.sets, so each set can override any dagProcessor setting and parse only the bundles it selects, while bundles stay defined once in dagBundleConfigList.
closes: #61037
related: #74849
Why
The chart runs a single Dag processor Deployment that parses every Dag bundle. A heavy or failing
bundle cannot be scaled, sized, scheduled or isolated apart from the others, and every replica shares
one configuration. The core already supports parsing a subset of bundles
(
airflow dag-processor --bundle-name ..., repeatable), so only the chart is missing.This takes over the work started in #61039 (closed after going stale while waiting for a chart design
direction) and applies the direction agreed in that discussion: follow
workers.celery.setsrather thanintroducing a parallel configuration tree. The original author is credited as co-author on the commit.
What changed compared to #61039
Review feedback on #61039 and how it is handled here:
deployPerBundle.bundleOverrides) can drift apartdagProcessor.dagBundleConfigList; a set selects them withbundleNamesand the chart fails when a name is not definedargsparameterargsknob;--bundle-nameflags are appended to the last item of the existingdagProcessor.argsdeploymentOverridelevel and model it onworkers.celery.setsdagProcessor.sets/enableDefaultmirror the worker sets values (except theenableDefaultdefault, see below) and reuse the same merge helper (workersMergeValues) and naming schememain, after theworkersdeprecation removal and sets simplification (#66671)enableDefaultkeeps the existing Deployment whensetsis empty, and can be set totrueto run it next to the sets (see below)enableDefaultlogic (differs fromworkers.celery.enableDefault)enableDefaultis not a plaintruedefault. When it is not set, the default Dag processor is created onlyif
setsis empty; an explicittrueorfalseis always respected.Worker sets split work by queue, but the default Dag processor parses all bundles unless
bundleNamesis set. Keeping it enabled next to sets that select bundles would silently make those bundles be parsed
twice, with no error to point at the cause. With
sets: []nothing changes for existing users.Documentation only and failing the render were considered, but the first relies on users noticing the
warning and the second blocks valid setups. If maintainers prefer exact parity with
workers.celery.enableDefault, restoringenableDefault: trueis a small change.The #61039 implementation (helper templates
dag-processor.deployment/dag-processor.poddisruptionbudget,deployPerBundle,bundleOverrides) is not reused; this PR is a fresh implementation on the sets pattern.What it does
dagProcessor.enableDefault,dagProcessor.bundleNamesanddagProcessor.setsvalues (with schema).setsrequires anameand can override anydagProcessorvalue. It renders its ownDeployment
<release>-dag-processor-<name>and, when enabled, its own PodDisruptionBudget<release>-dag-processor-pdb-<name>, selected by adag-processor-setlabel.bundleNamesis validated againstdagBundleConfigListand turned into--bundle-nameflags.dagBundleConfigList(the Airflow config is shared by all Dag processors, sothe override would be silently ignored); the chart fails with an explanation instead.
sets: []) the rendered Deployment and PodDisruptionBudget are identical tomain.chart/docs/manage-dag-files.rst.Not included: a per-set
image(requested in #74849). It is a separate change on top of this structure.Note: the default Dag processor parses all bundles unless
bundleNamesis set on it, so whenenableDefaultis set totruenext to sets, a bundle selected by a set is parsed twice. This is documentedin
values.yaml, the schema and the docs.Testing
Executed:
chart/tests/helm_tests/airflow_core/test_dag_processor_sets.py(19 tests): default output,enableDefaultderived from
sets(5 combinations), naming with/without default, set labels and selectors, value overrides,--bundle-nameargs (single, multiple,on the default processor), args untouched without
bundleNames, all bundles still present in the sharedconfig, failures (unknown bundle, missing
name,dagBundleConfigListin a set), per-set PDB, disabledDag processor.
test_dag_processor.pyandtest_worker_sets.py: 241 tests passed.prek run --stage pre-commiton the changed files: all hooks passed.helm templateoutput of the Dag processor Deployment and PodDisruptionBudget with default values,compared against
main: no differences.helm template, clean chart directory): about 0.75s onmain, 0.9s with this change anddefault values, 0.95s with 10 sets and 1.2s with 30 sets (about 10ms per set).
LocalDagBundles, one set per bundle): theDeployments, PodDisruptionBudgets and
--bundle-nameargs were as expected, and the logs of each Dagprocessor show it only refreshing and scanning its own bundle.
Not verified:
8 CPUs (12 GB memory after raising it), and a single-node kind cluster running the migration job, API
server, scheduler and several Dag processors at once saturated the CPU. The startup/liveness probes
(each of which starts a full
airflowprocess) timed out and kept restarting the API server andscheduler, even after relaxing the probe timeouts and dropping the log-groomer sidecars. The Dag
processors themselves stayed up, so only they were checked (Deployments, PodDisruptionBudgets, args and
logs). A run on a machine with more CPU would be welcome.
No newsfragment: the feature is opt-in and the chart only takes newsfragments for major or breaking changes.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5.5) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.