quentin-sommer opened a new issue, #60229:
URL: https://github.com/apache/airflow/issues/60229
### Apache Airflow Provider(s)
cncf-kubernetes
### Versions of Apache Airflow Providers
apache-airflow-providers-cncf-kubernetes==10.9.0
### Apache Airflow version
2.10.5
### Operating System
linux
### Deployment
Google Cloud Composer
### Deployment details
composer-2.16.1-airflow-2.10.5
### What happened
When using `GKEStartJobOperator` the job name that is generated doesn't
strip `_` characters, leading to a kubernetes server error response:
```
[2026-01-07, 11:54:30 EST] {kubernetes.py:568} ERROR - Exception when
attempting to create Namespaced Job:
{
"apiVersion": "batch/v1",
"kind": "Job",
"metadata": {
"annotations": {},
"labels": {},
"name": "job-cloud_composer_task_export_answers_stats-3gxv44tg",
"namespace": "data-science"
},
}
// actual error
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Job.batch
\"job-cloud_composer_task_export_answers_stats-3gxv44tg\" is invalid:
metadata.name: Invalid value:
\"job-cloud_composer_task_export_answers_stats-3gxv44tg\": a lowercase RFC 1123
subdomain must consist of lower case alphanumeric characters, '-' or '.', and
must start and end with an alphanumeric character (e.g. 'example.com', regex
used for validation is
'[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')",
"reason": "Invalid",
"details": {
"name": "job-cloud_composer_task_export_answers_stats-3gxv44tg",
"group": "batch",
"kind": "Job",
"causes": [
{
"reason": "FieldValueInvalid",
"message": "Invalid value:
\"job-cloud_composer_task_export_answers_stats-3gxv44tg\": a lowercase RFC 1123
subdomain must consist of lower case alphanumeric characters, '-' or '.', and
must start and end with an alphanumeric character (e.g. 'example.com', regex
used for validation is
'[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')",
"field": "metadata.name"
}
]
},
"code": 422
}
```
The regex provided in the stacktrace:
```
[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
```
Doesn't validate the job name:
```
job-cloud_composer_task_export_answers_stats-3gxv44tg
```
Our task names use underscores as it's the python convetion
### What you think should happen instead
the pod operator
https://github.com/apache/airflow/blob/2daadf4abfa7c93c128229ca8028a818c0ddfad5/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py#L671
calls `_set_name` which replaces invalid chars by `-`
but the job operator
https://github.com/apache/airflow/blob/2daadf4abfa7c93c128229ca8028a818c0ddfad5/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/job.py#L190
doesn't call set name, leading to invalid names being preserved.
The actual names come from this function:
https://github.com/apache/airflow/blob/2daadf4abfa7c93c128229ca8028a818c0ddfad5/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/kubernetes_helper_functions.py#L125
### How to reproduce
Use `GKEStartJobOperator` or KubernetesStartJobOperator with a task id
containing a `_`
### Anything else
I'm willing to submit a fix and I'm already prepping one
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]