PaulW commented on a change in pull request #4636: [AIRFLOW-3737] Kubernetes 
executor cannot handle long dag/task names
URL: https://github.com/apache/airflow/pull/4636#discussion_r264577106
 
 

 ##########
 File path: airflow/contrib/executors/kubernetes_executor.py
 ##########
 @@ -476,6 +480,27 @@ def _make_safe_pod_id(safe_dag_id, safe_task_id, 
safe_uuid):
 
         return safe_pod_id
 
+    @staticmethod
+    def _make_safe_label_value(string):
+        """
+        Valid label values must be 63 characters or less and must be empty or 
begin and
+        end with an alphanumeric character ([a-z0-9A-Z]) with dashes (-), 
underscores (_),
+        dots (.), and alphanumerics between.
+
+        If the label value is then greater than 63 chars once made safe, or 
differs in any
+        way from the original value sent to this function, then we need to 
truncate to
+        53chars, and append it with a unique hash.
+        """
+        MAX_LABEL_LEN = 63
+
+        safe_label = 
re.sub(r'^[^a-z0-9A-Z]*|[^a-zA-Z0-9_\-\.]|[^a-z0-9A-Z]*$', '', string)
 
 Review comment:
   Yes that is correct.  As the regex and formatting syntax on the kubernetes 
docs is quite precise, if we were to simply hash only if the modified labels 
were above 63 chars could lead to collisions if there are unsupported chars 
being the only difference between the dags (as you've mentioned above).  This 
also covers accentuated characters if they are used in dag names too.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to