romsharon98 commented on code in PR #42427:
URL: https://github.com/apache/airflow/pull/42427#discussion_r1778287226


##########
airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py:
##########
@@ -282,6 +286,8 @@ def custom_obj_api(self) -> CustomObjectsApi:
         return CustomObjectsApi()
 
     def execute(self, context: Context):
+        self.name = self.create_job_name()

Review Comment:
   got it 😄 



##########
airflow/providers/cncf/kubernetes/operators/spark_kubernetes.py:
##########
@@ -161,8 +160,13 @@ def manage_template_specs(self):
         return template_body
 
     def create_job_name(self):
-        initial_name = add_unique_suffix(name=self.task_id, 
max_len=MAX_LABEL_LEN)
-        return re.sub(r"[^a-z0-9-]+", "-", initial_name.lower())
+        name = (
+            self.name or self.template_body.get("spark", {}).get("metadata", 
{}).get("name") or self.task_id
+        )
+
+        updated_name = add_unique_suffix(name=name, max_len=MAX_LABEL_LEN)
+
+        return re.sub(r"[^a-z0-9-]+", "-", updated_name.lower())

Review Comment:
   maybe better use this function here?
   
https://github.com/apache/airflow/blob/main/airflow/providers/cncf/kubernetes/operators/pod.py#L1007



-- 
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]

Reply via email to