jedcunningham commented on a change in pull request #15443:
URL: https://github.com/apache/airflow/pull/15443#discussion_r616234903
##########
File path: tests/kubernetes/test_pod_generator.py
##########
@@ -656,6 +657,24 @@ def test_pod_name_confirm_to_max_length(self, _, pod_id):
assert len(parts[0]) <= 63
assert len(parts[1]) <= 63
+ @parameterized.expand(
+ (
+ ("pod-name-with-hyphen-", "pod-name-with-hyphen"),
+ ("pod-name-with-double-hyphen--", "pod-name-with-double-hyphen"),
+ ("pod0-name", "pod0-name"),
+ ("simple", "simple"),
Review comment:
```suggestion
("simple", "simple"),
("pod-name-with-dot.", "pod-name-with-dot"),
("pod-name-with-double-dot..", "pod-name-with-double-dot"),
("pod-name-with-hyphen-dot-.", "pod-name-with-hyphen-dot"),
```
##########
File path: airflow/kubernetes/pod_generator.py
##########
@@ -469,7 +469,10 @@ def make_unique_pod_id(pod_id: str) -> str:
safe_uuid = uuid.uuid4().hex # safe uuid will always be less than 63
chars
trimmed_pod_id = pod_id[:MAX_LABEL_LEN]
- safe_pod_id = f"{trimmed_pod_id}.{safe_uuid}"
+
+ # Since we use '.' as separator we need to remove all the occurences
of '-' if any
+ # in the trimmed_pod_id as the regex does not allow '-' followed by
'.'.
+ safe_pod_id = f"{trimmed_pod_id.rstrip('-')}.{safe_uuid}"
Review comment:
```suggestion
trimmed_pod_id = pod_id[:MAX_LABEL_LEN].rstrip('-') # Strip
trailing '-' as it cant be followed by '.'
safe_pod_id = f"{trimmed_pod_id}.{safe_uuid}"
```
Maybe? Either way, your comment is wrong as it only removes trailing
dashes, and occurrences has a typo.
What about the '..' case (and more, maybe trimming until the last char is
a-z0-9)?
--
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]