From c19b99f82877830931dafa4bf3fdf9cbf6aafc05 Mon Sep 17 00:00:00 2001 From: ali-zipstack Date: Mon, 27 Jan 2025 17:16:16 +0530 Subject: [PATCH] fix for duplicate container while retrying executions --- unstract/core/src/unstract/core/utilities.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/unstract/core/src/unstract/core/utilities.py b/unstract/core/src/unstract/core/utilities.py index 89213e49f..34d5c1729 100644 --- a/unstract/core/src/unstract/core/utilities.py +++ b/unstract/core/src/unstract/core/utilities.py @@ -1,5 +1,6 @@ import logging import os +import uuid from typing import Optional logger = logging.getLogger() @@ -31,7 +32,10 @@ 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: - container_name = f"{tool_image.split('/')[-1]}-{tool_version}-{run_id}" + tool_name = tool_image.split("/")[-1] + # TODO: Add execution attempt to better track instead of uuid + short_uuid = uuid.uuid4().hex[:6] # To avoid duplicate name collision + container_name = f"{tool_name}-{tool_version}-{short_uuid}-{run_id}" # To support limits of container clients like K8s if len(container_name) > 63: