-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Added dashes to pod naming #16636
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
Added dashes to pod naming #16636
Conversation
|
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)
|
uranusjr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some test cases will also be needed.
| :return: Pod name stripped of any unsafe characters | ||
| """ | ||
| return ''.join(ch.lower() for ch in list(string) if ch.isalnum()) | ||
| return ''.join(ch.lower() for ch in list(string) if ch.isalnum() or ch in ['-']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s probably easier to do a re.sub instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate more on why using an additional module would be more effective? I am fairly new to Python, so I am eager for knowledge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not many reasons TBH, just it’s probably easier to understand IMO.
return re.sub(r"[^-a-z0-9]+", string.lower())It may also be easier to implement additional logic, such as avoiding - in the beginning of the string (which the logic you implement right now does not do).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are to use regex, we should use a precompiled regex object. If we are not going to use regex here, then i think we should just do the comparison with ch == '-' without creating a new list in memory.
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
airflow/tests/kubernetes/test_pod_generator.py Lines 650 to 679 in 86d0a96
It seems like already provided test cases are enough (they are with dashes). Also, regex is valid for using dashes. |
Some more should be added since the logic now has more allowed characters. Name with leading dash/dot/underscore, for example. |
houqp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on what @kaxil said, i don't see specific code to guard against that regression?
| :return: Pod name stripped of any unsafe characters | ||
| """ | ||
| return ''.join(ch.lower() for ch in list(string) if ch.isalnum()) | ||
| return ''.join(ch.lower() for ch in list(string) if ch.isalnum() or ch in ['-']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are to use regex, we should use a precompiled regex object. If we are not going to use regex here, then i think we should just do the comparison with ch == '-' without creating a new list in memory.
|
@SimonOsipov i think you need to write code to check and remove trailing |
|
I think #17057 covers this. |
|
#17057 only covers the |
|
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. |
|
I terribly apologize, I a bit felt out of the issue I created. Is this issue still valid? |
|
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. |
Closes: #16600
In order to have a more readable naming of KubernetesExecutor Pod, decided to remove deleting "dashes" as per the documentation it is allowed.