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

Extend init_containers defined in pod_override #17537

Merged
merged 6 commits into from
Aug 19, 2021

Conversation

repocho
Copy link
Contributor

@repocho repocho commented Aug 10, 2021

If you add an init_container in pod_override the specified init_containers in the pod-template-file for kubernetes are ovewritten instead of extended as it is the case of the volumes for example.
So, for example, if you have a git sync ini_container but you define another init container, the task won't be executed because airflow won't find the dags as the init_container is replaced.

This change is just extending the init_container defined in the pod_override with the existing ones defined in the pod template file for kubernetes. In that sense you can define new extra init_containers.

@boring-cyborg boring-cyborg bot added the provider:cncf-kubernetes Kubernetes provider related issues label Aug 10, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 10, 2021

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 Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, 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.
    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

@kaxil kaxil added this to the Airflow 2.2 milestone Aug 10, 2021
@uranusjr uranusjr closed this Aug 11, 2021
@uranusjr uranusjr reopened this Aug 11, 2021
@jedcunningham
Copy link
Member

Thanks @repocho! Can you add a test for this in tests/kubernetes/test_pod_generator.py?

@repocho
Copy link
Contributor Author

repocho commented Aug 11, 2021

Thanks for the time reviewing this PR @jedcunningham !

I have added a test for this. Let me know if you need anything more.
Thanks again.

tests/kubernetes/test_pod_generator.py Outdated Show resolved Hide resolved
tests/kubernetes/test_pod_generator.py Outdated Show resolved Hide resolved
@repocho
Copy link
Contributor Author

repocho commented Aug 12, 2021

Thanks @jedcunningham, I have merged your suggestions and launched the tests again with success.

tests/kubernetes/test_pod_generator.py::TestPodGenerator::test_reconcile_specs_init_containers PASSED 

@jedcunningham
Copy link
Member

Oh, looks like we have a static check failure in that test file. Can you reformat that when you get the chance?

@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Aug 13, 2021
repocho and others added 4 commits August 15, 2021 11:33
…sync and similar init_containers will stay)

With that change if you define a pod_override and specifies the "init_containers" attribute it will extend the base init_containers with the new ones instead of overwriting them. That is to keep the dag git sync init_containers or other pre-defined init_containers based on the template or the configuration.
Improves readability and removes unused attributes from the spec.

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
@repocho
Copy link
Contributor Author

repocho commented Aug 15, 2021

I have rebased the branch with the last changes in branch main, to be able to launch all the tests

@repocho repocho requested a review from kaxil as a code owner August 15, 2021 10:23
@jedcunningham jedcunningham merged commit e107891 into apache:main Aug 19, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Aug 19, 2021

Awesome work, congrats on your first merged pull request!

@jedcunningham
Copy link
Member

Thanks for the bugfix @repocho and congrats on your first commit 🎉!

@repocho
Copy link
Contributor Author

repocho commented Aug 21, 2021

Thank you for all your help !! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge provider:cncf-kubernetes Kubernetes provider related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants