diff --git a/server/src/uds/services/OpenShift/provider.py b/server/src/uds/services/OpenShift/provider.py index f2991c3cb..d9c42610b 100644 --- a/server/src/uds/services/OpenShift/provider.py +++ b/server/src/uds/services/OpenShift/provider.py @@ -125,18 +125,6 @@ def test( # Utility def sanitized_name(self, name: str) -> str: """ - Sanitizes the VM name to comply with RFC 1123: - - Converts to lowercase - - Replaces any character not in [a-z0-9.-] with '-' - - Collapses multiple '-' into one - - Removes leading/trailing non-alphanumeric characters - - Limits length to 63 characters + OpenShift only allows machine names with [a-zA-Z0-9_-] """ - name = name.lower() - # Replace any character not allowed with '-' - name = re.sub(r'[^a-z0-9.-]', '-', name) - # Collapse multiple '-' into one - name = re.sub(r'-{2,}', '-', name) - # Remove leading/trailing non-alphanumeric characters - name = re.sub(r'^[^a-z0-9]+|[^a-z0-9]+$', '', name) - return name[:63] \ No newline at end of file + return re.sub(r'[^a-zA-Z0-9-]', '-', name).lower()[:63] diff --git a/server/tests/services/openshift/test_provider.py b/server/tests/services/openshift/test_provider.py index 69abc0d9f..797f56477 100644 --- a/server/tests/services/openshift/test_provider.py +++ b/server/tests/services/openshift/test_provider.py @@ -134,9 +134,9 @@ def test_sanitized_name(self) -> None: test_cases = [ ('Test-VM-1', 'test-vm-1'), ('Test_VM@2', 'test-vm-2'), - ('My Test VM!!!', 'my-test-vm'), - ('Test !!! this is', 'test-this-is'), - ('UDS-Pub-Hello World!!--2025065122-v1', 'uds-pub-hello-world-2025065122-v1'), + ('My Test VM!!!', 'my-test-vm---'), + ('Test !!! this is', 'test-----this-is'), + ('UDS-Pub-Hello World!!--2025065122-v1', 'uds-pub-hello-world----2025065122-v1'), ('a' * 100, 'a' * 63), # Test truncation ] for input_name, expected in test_cases: