potiuk commented on code in PR #75945:
URL: https://github.com/apache/airflow/pull/75945#discussion_r4676201847
##########
chart/templates/dag-processor/dag-processor-poddisruptionbudget.yaml:
##########
@@ -40,5 +62,17 @@ spec:
tier: airflow
component: dag-processor
release: {{ .Release.Name }}
+ {{- if ne .Values.dagProcessor.name "default" }}
+ dag-processor-set: {{ .Values.dagProcessor.name }}
+ {{- end }}
+ {{- if and (eq .Values.dagProcessor.name "default") $setsWithPdb }}
+ matchExpressions:
Review 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.
##########
chart/templates/dag-processor/dag-processor-deployment.yaml:
##########
@@ -21,6 +21,37 @@
## Airflow Dag Processor Deployment
#################################
{{- if .Values.dagProcessor.enabled }}
+{{- $globals := deepCopy . -}}
+{{- $dagProcessorSets := .Values.dagProcessor.sets | default list -}}
+{{- $seenSetNames := dict -}}
+{{- range $dagProcessorSets -}}
+ {{- $setName := .name | default "" | toString -}}
+ {{- if eq $setName "default" -}}
+ {{- fail "`dagProcessor.sets` items cannot be named `default`; that name
is used by the default Dag processor" -}}
+ {{- end -}}
+ {{- if not (and (regexMatch "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" $setName) (le
(len $setName) 63)) -}}
+ {{- fail (printf "`dagProcessor.sets` item name %q is not a valid DNS-1123
label (lowercase alphanumerics and '-', starting and ending with an
alphanumeric, at most 63 characters)" $setName) -}}
+ {{- end -}}
+ {{- if hasKey $seenSetNames $setName -}}
+ {{- fail (printf "`dagProcessor.sets` contains the name %q more than once"
$setName) -}}
+ {{- end -}}
+ {{- $_ := set $seenSetNames $setName true -}}
+{{- end -}}
+{{- $enableDefault := .Values.dagProcessor.enableDefault -}}
+{{- if kindIs "invalid" $enableDefault -}}
+ {{- $enableDefault = not .Values.dagProcessor.sets -}}
Review 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.
##########
chart/templates/dag-processor/dag-processor-deployment.yaml:
##########
@@ -58,6 +106,9 @@ spec:
tier: airflow
component: dag-processor
release: {{ .Release.Name }}
+ {{- if ne .Values.dagProcessor.name "default" }}
+ dag-processor-set: {{ .Values.dagProcessor.name }}
+ {{- end }}
{{- if .Values.dagProcessor.strategy }}
Review 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.
##########
chart/templates/dag-processor/dag-processor-deployment.yaml:
##########
@@ -32,10 +63,27 @@
{{- $containerSecurityContextWaitForMigrations := include
"containerSecurityContext" (list .Values.dagProcessor.waitForMigrations
.Values) }}
{{- $containerLifecycleHooks := or
.Values.dagProcessor.containerLifecycleHooks .Values.containerLifecycleHooks }}
{{- $containerLifecycleHooksLogGroomerSidecar := or
.Values.dagProcessor.logGroomerSidecar.containerLifecycleHooks
.Values.containerLifecycleHooks }}
+{{- $args := .Values.dagProcessor.args }}
+{{- $dagProcessorContext := . }}
+{{- with .Values.dagProcessor.bundleNames }}
+ {{- $definedBundles := list }}
+ {{- range $.Values.dagProcessor.dagBundleConfigList }}
+ {{- $definedBundles = append $definedBundles .name }}
+ {{- end }}
+ {{- $renderedArgs := tpl (toYaml $args) $dagProcessorContext }}
+ {{- range . }}
+ {{- 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) }}
Review 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.
##########
chart/values.yaml:
##########
@@ -2153,7 +2189,11 @@ dagProcessor:
command: ~
# Args to use when running Airflow dag processor (templated).
- args: ["bash", "-c", "exec airflow dag-processor"]
+ # The default adds a `--bundle-name` flag for each item of `bundleNames`.
+ args:
+ - "bash"
+ - "-c"
+ - "exec airflow dag-processor{{ range .Values.dagProcessor.bundleNames }}
--bundle-name {{ . | squote }}{{ end }}"
Review 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.
##########
chart/templates/NOTES.txt:
##########
@@ -150,3 +150,21 @@
https://airflow.apache.org/docs/helm-chart/stable/production-guide.html#api-secr
{{- if ne .Values.executor (tpl .Values.config.core.executor $) }}
{{ fail "Please configure the executor with `executor`, not
`config.core.executor`." }}
{{- end }}
+
+{{- $bundleClaims := dict }}
+{{- if .Values.dagProcessor.enabled }}
+{{- range .Values.dagProcessor.sets | default list }}
Review 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.
##########
chart/templates/dag-processor/dag-processor-deployment.yaml:
##########
@@ -58,6 +106,9 @@ spec:
tier: airflow
component: dag-processor
release: {{ .Release.Name }}
+ {{- if ne .Values.dagProcessor.name "default" }}
+ dag-processor-set: {{ .Values.dagProcessor.name }}
Review 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.
##########
chart/templates/dag-processor/dag-processor-deployment.yaml:
##########
@@ -21,6 +21,37 @@
## Airflow Dag Processor Deployment
#################################
{{- if .Values.dagProcessor.enabled }}
+{{- $globals := deepCopy . -}}
+{{- $dagProcessorSets := .Values.dagProcessor.sets | default list -}}
+{{- $seenSetNames := dict -}}
+{{- range $dagProcessorSets -}}
+ {{- $setName := .name | default "" | toString -}}
+ {{- if eq $setName "default" -}}
+ {{- fail "`dagProcessor.sets` items cannot be named `default`; that name
is used by the default Dag processor" -}}
+ {{- end -}}
+ {{- if not (and (regexMatch "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" $setName) (le
(len $setName) 63)) -}}
+ {{- fail (printf "`dagProcessor.sets` item name %q is not a valid DNS-1123
label (lowercase alphanumerics and '-', starting and ending with an
alphanumeric, at most 63 characters)" $setName) -}}
+ {{- end -}}
+ {{- if hasKey $seenSetNames $setName -}}
+ {{- fail (printf "`dagProcessor.sets` contains the name %q more than once"
$setName) -}}
+ {{- end -}}
+ {{- $_ := set $seenSetNames $setName true -}}
+{{- end -}}
+{{- $enableDefault := .Values.dagProcessor.enableDefault -}}
+{{- if kindIs "invalid" $enableDefault -}}
+ {{- $enableDefault = not .Values.dagProcessor.sets -}}
Review 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.
##########
chart/values.yaml:
##########
@@ -2143,6 +2143,42 @@ dagProcessor:
# classpath: "airflow.dag_processing.bundles.local.LocalDagBundle"
# kwargs: {}
+ # Enable the default dag processor defined by the root `dagProcessor`
configuration to be created.
+ # If false, only the dedicated dag processors defined in 'sets' will be
created.
+ # When not set, the default dag processor is created only if 'sets' is empty.
+ # Set it to true explicitly to run the default dag processor next to the
sets. It parses ALL bundles
+ # 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
Review 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".
--
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]