You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vyncint (via GitHub)" <gi...@apache.org> on 2026/07/21 23:49:39 UTC

[PR] Apply Dag processor labels to its Deployment [airflow]

vyncint opened a new pull request, #70205:
URL: https://github.com/apache/airflow/pull/70205

   `dagProcessor.labels` is documented as applying to Dag processor objects and pods, but the Deployment metadata currently receives only global labels. Apply component-specific labels there too, preserving the existing component-over-global precedence.
   
   The regression test covers a global-only label, a component-only label, and a colliding label key.
   
   closes: #53190
   
   Tests:
   
   - `breeze testing helm-tests --use-xdist` (2061 passed)
   - `prek run --from-ref main --stage pre-commit`
   - `prek run --from-ref main --stage manual`
   - `breeze ci selective-check --commit-ref HEAD`
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Codex (GPT-5)
   
   Generated-by: Codex (GPT-5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "Miretpl (via GitHub) via commits" <co...@airflow.apache.org>.
Miretpl commented on code in PR #70205:
URL: https://github.com/apache/airflow/pull/70205#discussion_r3684860500


##########
chart/templates/api-server/api-server-deployment.yaml:
##########
@@ -30,6 +30,12 @@
 {{- $containerSecurityContext := include "containerSecurityContext" (list .Values.apiServer .Values) }}
 {{- $containerSecurityContextWaitForMigrations := include "containerSecurityContext" (list .Values.apiServer.waitForMigrations .Values) }}
 {{- $containerLifecycleHooks := or .Values.apiServer.containerLifecycleHooks .Values.containerLifecycleHooks }}
+{{- $deploymentLabels := .Values.labels }}
+{{- $podLabels := .Values.apiServer.labels }}
+{{- if ne .Values.apiServer.podLabels nil }}
+  {{- $deploymentLabels = mustMerge (deepCopy .Values.apiServer.labels) .Values.labels }}
+  {{- $podLabels = .Values.apiServer.podLabels }}
+{{- end }}

Review Comment:
   Could you export the logic to the helper function?



##########
chart/templates/api-server/api-server-deployment.yaml:
##########
@@ -80,8 +86,8 @@ spec:
         tier: airflow
         component: api-server
         release: {{ .Release.Name }}
-        {{- if or .Values.labels .Values.apiServer.labels }}
-          {{- mustMerge .Values.apiServer.labels .Values.labels | toYaml | nindent 8 }}
+        {{- if or .Values.labels $podLabels }}
+          {{- mustMerge (deepCopy $podLabels) .Values.labels | toYaml | nindent 8 }}

Review Comment:
   Is there a need for `deepCopy` here?



##########
chart/tests/helm_tests/airflow_aux/test_pod_labels.py:
##########
@@ -0,0 +1,165 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import pytest
+from chart_utils.helm_template_generator import render_chart
+
+# Components whose workload object carries only the global labels until
+# ``podLabels`` is set. ``dagProcessor`` has its own dedicated module in
+# ``helm_tests/dagprocessor/test_labels_deployment.py``.
+COMPONENTS = [
+    ("apiServer", "templates/api-server/api-server-deployment.yaml", {}),
+    ("scheduler", "templates/scheduler/scheduler-deployment.yaml", {}),
+    (
+        "workers.celery",
+        "templates/workers/worker-deployment.yaml",
+        {"executor": "CeleryExecutor"},
+    ),
+    ("triggerer", "templates/triggerer/triggerer-deployment.yaml", {}),
+    (
+        "flower",
+        "templates/flower/flower-deployment.yaml",
+        {"executor": "CeleryExecutor", "flower": {"enabled": True}},
+    ),
+    ("statsd", "templates/statsd/statsd-deployment.yaml", {}),
+    (
+        "pgbouncer",
+        "templates/pgbouncer/pgbouncer-deployment.yaml",
+        {"pgbouncer": {"enabled": True}},
+    ),
+    ("redis", "templates/redis/redis-statefulset.yaml", {"executor": "CeleryExecutor"}),
+]
+
+GLOBAL_LABELS = {"test_global_label": "test_global_label_value", "common_label": "global_value"}
+COMPONENT_LABELS = {
+    "test_component_label": "test_component_label_value",
+    "common_label": "component_value",
+}
+POD_LABELS = {"test_pod_label": "test_pod_label_value", "common_label": "pod_value"}
+OTEL_ENABLED = {"otelCollector": {"tracesEnabled": True}}
+
+
+def _deep_merge(base: dict, overlay: dict) -> dict:
+    merged = dict(base)
+    for key, value in overlay.items():
+        if isinstance(value, dict) and isinstance(merged.get(key), dict):
+            merged[key] = _deep_merge(merged[key], value)
+        else:
+            merged[key] = value
+    return merged
+
+
+def _nest(values_key: str, payload: dict) -> dict:
+    """Expand a dotted values key, so ``workers.celery`` reaches the right table."""
+    for part in reversed(values_key.split(".")):
+        payload = {part: payload}
+    return payload
+
+
+def _render(values_key: str, show_only: str, extra_values: dict, component: dict) -> tuple[dict, dict]:
+    values = _deep_merge({"labels": GLOBAL_LABELS}, extra_values)
+    values = _deep_merge(values, _nest(values_key, component))
+    docs = render_chart(values=values, show_only=[show_only])
+    return docs[0]["metadata"]["labels"], docs[0]["spec"]["template"]["metadata"]["labels"]

Review Comment:
   What is the reasoning for adding these helper functions?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate Dag processor object and pod labels [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5074359276

   Implemented the `podLabels` split requested in the review and earlier discussion:
   
   - Leaving `dagProcessor.podLabels` unset preserves the existing behavior: `dagProcessor.labels` applies to pods, while the Deployment receives global labels only.
   - Setting `dagProcessor.podLabels` (including `{}`) opts into separation: `dagProcessor.labels` applies to the Deployment and `dagProcessor.podLabels` applies to pods.
   - Component labels keep precedence over global labels, and `deepCopy` prevents `mustMerge` from mutating the source values.
   
   I also added values/schema documentation, a news fragment, and regression coverage for the fallback, separated-label, collision, and explicit-empty-map cases. The branch is rebased on current `main`.
   
   Validation completed:
   
   - `breeze testing helm-tests --use-xdist` — 2095 passed
   - `prek run --from-ref upstream/main --stage pre-commit`
   - `prek run --from-ref upstream/main --stage manual`
   - `breeze ci selective-check --commit-ref HEAD`
   
   ---
   Drafted-by: Codex (GPT-5) (no human review 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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate Dag processor object and pod labels [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5074593144

   Verified on the rebased branch:
   
   - `podLabels` unset — unchanged behavior (Deployment: global only, pods: component + global)
   - `podLabels` set — Deployment: component + global, pods: podLabels + global
   - `podLabels: {}` — pods get global only
   - collisions — component wins on the Deployment, podLabels wins on pods
   
   Backward compatibility: rendering the whole chart with the same values against current `main` and against this branch gives byte-identical output.
   
   Tests: 7 passed in `test_labels_deployment.py`, 125 passed across the dagprocessor, redis, statsd and otel_collector helm suites.
   
   Ready for review @Miretpl.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "Miretpl (via GitHub)" <gi...@apache.org>.
Miretpl commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5072293361

   > I'll implement it on dag-processor here first as the reference pattern (values.yaml + template + tests), and once you're happy with it extend the same pattern to the other components, using apiServer rather than webserver. Prefer everything in one PR, or dag-processor first then follow-ups?
   
   In general small PRs are better, but whole thing will rather not be big, so I will adjust. Do as it will be more comfortable for you.
   
   > using apiServer rather than webserver
   
   The Webserver will also be needed, but for the 1.2x line (on main we have 2.0) only.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "Miretpl (via GitHub)" <gi...@apache.org>.
Miretpl commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5072131238

   My idea https://github.com/apache/airflow/pull/59290#issuecomment-3667433158 after becoming a Committer is still the same. Separation, like in annotations, gives more flexibility, and I see cases when it would be nice to separate labels between the pod and the deployment itself. And if there will be a user who will want to have the same labels, there will be always a possibility to set the same value on both levels.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5124605051

   Hi @Miretpl,
   
   Following up on this. The podLabels split you asked for is in, and I extended it to the remaining components in 177dc55: apiServer, scheduler, workers.celery, triggerer, flower, statsd, pgbouncer, redis and otelCollector.
   
   Could you take another look when you have a moment? The changes-requested review is still blocking merge.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "Miretpl (via GitHub)" <gi...@apache.org>.
Miretpl commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5134109139

   @vyncint Most of the people here are doing work voluntarily, so getting feedback may take some time, especially in the AI era where it is easy to generate a PR, but still people have to take a look at it if it is aligned with the project. Sooner or later, I or some other maintainer will take another look at the PR and give another round of feedback. Please do not mention people in particular comments and/or get feedback when the PR is stale for a day or two. If it is stale for around 2 weeks, I think it is a good time period to try to ping any maintainer for the review.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #70205: Allow separate object and pod labels for chart components
URL: https://github.com/apache/airflow/pull/70205


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5040234455

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our [Contributors' Guide](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5083935856

   @Miretpl extended the pattern to the remaining components in 177dc55: apiServer, scheduler, workers.celery, triggerer, flower, statsd, pgbouncer, redis and otelCollector. Title and description updated to match the wider scope.
   
   otelCollector turned out to be the one exception. Its Deployment already merged component labels onto the object, so there is no backward-compatibility branch to preserve there — only its pod side gains the knob, and its object labels are unchanged. Every other component follows the dagProcessor shape exactly.
   
   Verification:
   
   - helm template with every component's labels set and podLabels unset is byte-identical to main across 3638 lines, with the random secrets pinned so the render is deterministic. That is the backward-compatibility proof.
   - New parametrized module helm_tests/airflow_aux/test_pod_labels.py covers all three states (unset, set, {}) for every component: 38 passed together with the existing dagProcessor module. I put the new cases in one parametrized module rather than nine near-identical files, following test_annotations.py; happy to split them per component if you prefer that layout.
   - Component suites for statsd, otel_collector, redis, api_server, scheduler, triggerer, worker, flower and pgbouncer: 779 passed, 1 failed.
   - Chart quality, basic chart and annotations modules: 114 passed, 9 failed.
   
   The 10 failures are pre-existing and unrelated. They assert on Helm's JSON-schema error wording, and local Helm 3.14.4 phrases it differently from what the tests expect; they cover dags.persistence.accessMode, pullPolicy and apiServer.securityContext. Running the same modules on a clean checkout of the base gives exactly the same counts, so nothing here is new. CI runs a pinned Helm, so I expect them green there.
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "Miretpl (via GitHub)" <gi...@apache.org>.
Miretpl commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5051320676

   Could you please check discussions from previous proposed PRs for the relevant change https://github.com/apache/airflow/pull/59290?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5069972877

   Thanks @Miretpl — I read through #59290 and understand the hold now. That PR made the same change for the webserver and stalled on a design question that was never settled, so rather than re-land it for dag-processor I'd like a direction first.
   
   Today per-component labels (e.g. dagProcessor.labels) only land on the pod template (spec.template.metadata.labels); the Deployment's own metadata.labels gets global labels only. Two ways to close that gap:
   
   A) Merge component labels onto the Deployment metadata directly (what this PR does now). Simple, but it changes where existing users' labels land, so it's a backward-compatibility concern.
   
   B) Add a per-component podLabels section (like the existing annotations / podAnnotations split): labels go to the Deployment, podLabels to the pod, and when podLabels is unset, labels fall back to the pod level to preserve today's behavior. This is the approach Miretpl proposed in #59290.
   
   On scope, #59290 also concluded this should be applied across all components rather than one at a time, and target apiServer rather than webserver (webserver is going away with Airflow 2.x). Happy to broaden this PR accordingly.
   
   Could a committer confirm (1) approach A or B, and (2) whether you want the full multi-component change in one PR? I'll rework and rebase onto main once there's a direction. cc @jscheffl @potiuk @jedcunningham @romsharon98
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Apply Dag processor labels to its Deployment [airflow]

Posted by "vyncint (via GitHub)" <gi...@apache.org>.
vyncint commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5072188306

   Thanks @Miretpl — agreed, the separation is the cleaner model. I'll go with podLabels:
   
   - labels -> Deployment metadata.labels
   - podLabels -> pod spec.template.metadata.labels
   - backward compatible: when podLabels is unset, labels stay on the pod level (today's behavior) and the Deployment keeps only global labels.
   
   I'll implement it on dag-processor here first as the reference pattern (values.yaml + template + tests), and once you're happy with it extend the same pattern to the other components, using apiServer rather than webserver. Prefer everything in one PR, or dag-processor first then follow-ups?
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Allow separate object and pod labels for chart components [airflow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #70205:
URL: https://github.com/apache/airflow/pull/70205#issuecomment-5657396203

   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org