You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "diegoalvarez-clarity (via GitHub)" <gi...@apache.org> on 2025/11/17 12:44:44 UTC
[PR] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
diegoalvarez-clarity opened a new pull request, #58391:
URL: https://github.com/apache/airflow/pull/58391
## Problem
Kubernetes automatically creates a label `batch.kubernetes.io/job-name` with the job name as its value. This label value must not exceed 63 characters, which effectively means the job name itself must be ≤ 63 characters.
Previously, the KubernetesJobOperator added the "job-" prefix after truncating the name to 63 characters, which could result in job names exceeding the limit (e.g., 67 characters). This caused Kubernetes API validation errors indicating that the label value exceeded 63 characters.
## Solution
This PR fixes the issue by:
1. Accounting for the prefix before truncation: Calculate the available length for the base name (POD_NAME_MAX_LENGTH - len(JOB_NAME_PREFIX) = 59) and pass this reduced max_length to create_unique_id and add_unique_suffix functions.
2. Adding the prefix after name generation: The "job-" prefix is added after the name has been properly truncated, ensuring the final name never exceeds 63 characters.
3. Using a constant for maintainability: Introduced JOB_NAME_PREFIX = "job-" as a module-level constant to avoid magic strings.
## Testing
- Updated test_task_id_as_name_with_suffix_very_long to expect 50 'a's instead of 71, reflecting the correct behavior where the prefix is accounted for before truncation.
- All existing tests continue to pass, confirming backward compatibility for names that don't require truncation.
## Contributors
- @diego15ag (co-author)
- @jprieto92 (co-author)
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "diegoalvarez-clarity (via GitHub)" <gi...@apache.org>.
diegoalvarez-clarity commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3569405942
I'm a little lost here @potiuk. I've updated the branch with the latest changes in master and I don't see the failing tests anymore. Is there anything else I need to do?
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3541658819
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #58391:
URL: https://github.com/apache/airflow/pull/58391
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "diegoalvarez-clarity (via GitHub)" <gi...@apache.org>.
diegoalvarez-clarity commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3570158910
> > I'm a little lost here @potiuk. I've updated the branch with the latest changes in master and I don't see the failing tests anymore. Is there anything else I need to do?
>
> Since you are first-time contributor, your workflows need to be approved to be run by a maintainer (this is spam/bitcoing mining protection).
>
> I just did - see what it results with.
It looks like every check passed 🙌
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3569922405
> I'm a little lost here @potiuk. I've updated the branch with the latest changes in master and I don't see the failing tests anymore. Is there anything else I need to do?
Since you are first-time committer, your workflows need to be approved to be run by a maintainer (this is spam/bitcoing mining protection).
I just did - see what it results with.
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3568349815
Tests need to be fixed.
--
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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3570202915
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional 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] fix(kubernetes): Account for job- prefix when truncating job names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #58391:
URL: https://github.com/apache/airflow/pull/58391#issuecomment-3570203356
Merged :)
--
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