Skip to content

Commit

Permalink
feat: Tool container name validation for length < 63 (#697)
Browse files Browse the repository at this point in the history
Tool container name validation for length < 63
  • Loading branch information
chandrasekharan-zipstack authored Sep 17, 2024
1 parent 70bdcf4 commit 30060ab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion unstract/core/src/unstract/core/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import logging
import os
from typing import Optional

logger = logging.getLogger()


class UnstractUtils:
@staticmethod
Expand Down Expand Up @@ -28,4 +31,12 @@ def get_env(env_key: str, default: Optional[str] = None, raise_err=False) -> str
def build_tool_container_name(
tool_image: str, tool_version: str, run_id: str
) -> str:
return f"{tool_image.split('/')[-1]}-{tool_version}-{run_id}"
container_name = f"{tool_image.split('/')[-1]}-{tool_version}-{run_id}"

# To support limits of container clients like K8s
if len(container_name) > 63:
logger.warning(
f"Container name exceeds 63 char limit for '{container_name}', "
"truncating to 63 chars. There might be collisions in container names"
)
return container_name[:63]

0 comments on commit 30060ab

Please sign in to comment.