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 KubernetesPodOperator pod name length validation #8829

Merged
merged 2 commits into from
May 15, 2020

Conversation

dsaiztc
Copy link
Contributor

@dsaiztc dsaiztc commented May 11, 2020

In #6523 a validation was added to KubernetesPodOperator that verifies the provided name conforms to the maximum number of characters for Kubernetes pods.

The provided character limit in such PR is not correct as it's using the maximum number of characters for a Kubernetes label, which is 63, instead of the maximum number of characters for Kubernetes name, which is 253 [1].

However, the char limit set in this module depends on the implementation of airflow.kubernetes.pod_generator.PodGenerator. Upon the commit this PR is based, whatever the length of the given name, such name will be shortened to conform to the norm (253 characters). In the referenced commit an additional 33 characters are added (- + 32 random), which in turns means that this should validate that the name is no longer that 220 characters (the value proposed).

Bear also in mind that current v.10.10 does not have the implementation of the commit mentioned but a different one where the name is not shortened but directly concatenated to another 9 characters (- + 8 random) and thus the name this limit could be set to 244 (instead of the 220 characters proposed).

[1] Identifiers and Names in Kubernetes


Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Unit tests coverage for changes (not needed for documentation changes)
  • Target Github ISSUE in description if exists
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

In case of fundamental code change, 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 UPDATING.md.
Read the Pull Request Guidelines for more information.

@boring-cyborg boring-cyborg bot added the k8s label May 11, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented May 11, 2020

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/master/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, pylint 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.
  • 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: [email protected]
    Slack: https://apache-airflow-slack.herokuapp.com/

@@ -322,5 +322,5 @@ def _set_resources(resources):
def _set_name(self, name):
if self.pod_template_file or self.full_pod_spec:
return None
validate_key(name, max_length=63)
validate_key(name, max_length=220)
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, we can keep it on 220 also for v1.10, as preparation for the longer suffix added in v2.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any further action needed from my side? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what else is needed for this fix to get on the v1.10 merge train 🚂

merging is blocked as long as there are unticked TODOs in the PR description btw.

maybe @kaxil: anything else?

Copy link
Member

Choose a reason for hiding this comment

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

Can we add tests too, please?

@dimberman Can you take a look please at this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM just would like to see some tests.

@kaxil kaxil added this to the Airflow 1.10.11 milestone May 14, 2020
@kaxil kaxil requested a review from dimberman May 14, 2020 22:02
@kaxil kaxil removed this from the Airflow 1.10.11 milestone May 14, 2020
@@ -322,5 +322,5 @@ def _set_resources(resources):
def _set_name(self, name):
if self.pod_template_file or self.full_pod_spec:
return None
validate_key(name, max_length=63)
validate_key(name, max_length=220)
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM just would like to see some tests.

@dimberman
Copy link
Contributor

thank you @ddelange! Once tests pass I'll merge.

@dsaiztc dsaiztc force-pushed the feature/k8s-operator-pod-name-length branch from 2dd9a6f to a83b9ef Compare May 15, 2020 14:09
@dsaiztc
Copy link
Contributor Author

dsaiztc commented May 15, 2020

All tests passed @dimberman =)

Any further feedback welcome.

@dsaiztc dsaiztc requested a review from dimberman May 15, 2020 15:41
@dimberman dimberman merged commit f82ad45 into apache:master May 15, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented May 15, 2020

Awesome work, congrats on your first merged pull request!

@dimberman dimberman added this to the Airflow 1.10.11 milestone May 15, 2020
@dimberman
Copy link
Contributor

Thank you @dsaiztc !

dimberman pushed a commit that referenced this pull request Jun 17, 2020
* Fix KubernetesPodOperator pod name length validation

* Add test, verify Exception is raised

(cherry picked from commit f82ad45)
potiuk pushed a commit that referenced this pull request Jun 29, 2020
* Fix KubernetesPodOperator pod name length validation

* Add test, verify Exception is raised

(cherry picked from commit f82ad45)
kaxil pushed a commit that referenced this pull request Jul 1, 2020
* Fix KubernetesPodOperator pod name length validation

* Add test, verify Exception is raised

(cherry picked from commit f82ad45)
cfei18 pushed a commit to cfei18/incubator-airflow that referenced this pull request Mar 5, 2021
* Fix KubernetesPodOperator pod name length validation

* Add test, verify Exception is raised

(cherry picked from commit f82ad45)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants