Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/helm chart: workers.command for KubernetesExecutor #39132

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

nyirit
Copy link
Contributor

@nyirit nyirit commented Apr 19, 2024

Helm-chart version used: 1.13.1 (latest)
Airflow version used: 2.8.4

The workers.command value override is ignored if KubernetesExecutor is used.

I wanted to add a custom command parameter to the base container in the pods that are created to execute the tasks, but I failed to do so with the following values.yaml override:

airflow:
  executor: KubernetesExecutor

  workers:
    command: ['my-test-command']

I have found that this value is only used in the worker-deployment.yaml, but not in the pod-template-file.kubernetes-helm-yaml which seems to be used for KubernetesExecutor.

Based on the workers.command documentation this does seem to be a bug.

Potential workaround

To make this work and prove that this is actually needed in my case, I have used the following override in the dag definition:

from datetime import datetime
from airflow import DAG
from kubernetes.client import models as k8s

default_args = {
    'executor_config': {
        'pod_override': k8s.V1Pod(
            spec=k8s.V1PodSpec(
                containers=[
                    k8s.V1Container(
                        name='base',
                        command=['my', 'command', 'to', 'run'],
                    )
                ],
            )
        ),
    }
}

with DAG(dag_id='test', default_args=default_args, start_date=datetime(2024, 1, 1), schedule=None) as dag:
    ....

This gets the job done, but it would be a lot nicer to be able to do this from the helm-chart, especially as this should be the default behaviour in my case for each dag.


I have checked open issues, but did not find one that mentions this problem. Also, this is my first PR here, so even against my best intentions, I might have missed something in the contributing guidelines, so all feedback and help is welcome :)

Branch is freshly rebased! :)


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Copy link

boring-cyborg bot commented Apr 19, 2024

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 pre-commits 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 Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment 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 for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • 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

Copy link
Collaborator

@romsharon98 romsharon98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.
I think we can also add args label in following PR because it's related to command.
but it's not that simple because the default value for command is belong to celery worker.

@nyirit nyirit force-pushed the fix-command-for-k8s-worker branch 3 times, most recently from 5935a4c to 7ebb4a0 Compare April 22, 2024 15:15
Copy link
Member

@jedcunningham jedcunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for pod_template to check the command isn't set by default?

@nyirit nyirit force-pushed the fix-command-for-k8s-worker branch from 7ebb4a0 to 237cec3 Compare April 22, 2024 17:20
@nyirit nyirit force-pushed the fix-command-for-k8s-worker branch from 237cec3 to 4a44443 Compare April 22, 2024 19:10
@jedcunningham jedcunningham merged commit 6e51198 into apache:main Apr 23, 2024
53 checks passed
Copy link

boring-cyborg bot commented Apr 23, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@jedcunningham
Copy link
Member

Thanks @nyirit! Congrats on your first commit 🎉 !

@nyirit nyirit deleted the fix-command-for-k8s-worker branch April 23, 2024 21:52
@nyirit
Copy link
Contributor Author

nyirit commented Apr 23, 2024

Awesome! Thank you @jedcunningham for the help with it! :)

RodrigoGanancia pushed a commit to RodrigoGanancia/airflow that referenced this pull request May 10, 2024
@utkarsharma2 utkarsharma2 added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:helm-chart Airflow Helm Chart changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants