Skip to content

Commit 3d686b3

Browse files
author
pintaoz
committed
Add dots in the end to indicate the username is trimmed
1 parent cfd7dd8 commit 3d686b3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/hyperpod_cli/commands/job.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,4 +1144,7 @@ def get_user_name():
11441144
# label value does not allow slash
11451145
user_name = user_name.replace('/', '-')
11461146
# 63 is the max length for a Kubernetes label
1147-
return user_name[:63]
1147+
if len(user_name) > 63:
1148+
# Add dots in the end to indicate the username is trimmed
1149+
return user_name[:59] + '...'
1150+
return user_name

test/unit_tests/test_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2139,4 +2139,4 @@ def test_get_user_name_long_arn(self, mock_boto3_client):
21392139
long_user_name = "ReadOnly/AmazonSageMaker-a-long-long-long-long-long-long-long-arn-for-testing-get-user-name"
21402140
long_arn = "arn:aws:iam::0123456789012:assumed-role/" + long_user_name
21412141
mock_identity.get.return_value = long_arn
2142-
self.assertEqual(get_user_name(), "AssumedRole-" + long_user_name.replace("/", "-")[:51])
2142+
self.assertEqual(get_user_name(), "AssumedRole-" + long_user_name.replace("/", "-")[:48] + "...")

0 commit comments

Comments
 (0)