From fbcfe3f88ff4ea4d525721ddeb873df19de091f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Thu, 16 Apr 2026 12:57:11 +0300 Subject: [PATCH] test: use uuid4 for DockerizedServer container names to avoid collisions Container names were generated as {name}-{pid}-{counter}, where the counter is a per-process itertools.count. This scheme breaks across CI runs on the same host: if a prior job was killed abruptly (SIGKILL, cancellation) its containers are left running since --rm only removes containers on exit. A subsequent run whose worker inherits the same PID (common in containerized CI with small PID namespaces) and reaches the same counter value will collide with the orphaned container. Replace pid+counter with uuid.uuid4(), which generates a random UUID, making names unique across processes, hosts, and time without any shared state or leaking host identifiers. Fixes: SCYLLADB-1540 Closes scylladb/scylladb#29509 --- test/pylib/dockerized_service.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/pylib/dockerized_service.py b/test/pylib/dockerized_service.py index c9d80e5aea..9b207bb237 100644 --- a/test/pylib/dockerized_service.py +++ b/test/pylib/dockerized_service.py @@ -6,12 +6,11 @@ import logging import shutil -import itertools import asyncio import pathlib import re -import os import subprocess +import uuid from typing import Callable logger = logging.getLogger("DockerizedServer") @@ -20,8 +19,6 @@ class DockerizedServer: """class for running an external dockerized service image, typically mock server""" # pylint: disable=too-many-instance-attributes - newid = itertools.count(start=1).__next__ # Sequential unique id - def __init__(self, image, tmpdir, logfilenamebase, success_string : Callable[[str, int], bool] | str, failure_string : Callable[[str, int], bool] | str, @@ -48,7 +45,7 @@ class DockerizedServer: exe = pathlib.Path(next(exe for exe in [shutil.which(path) for path in ["podman", "docker"]] if exe is not None)).resolve() - sid = f"{os.getpid()}-{DockerizedServer.newid()}" + sid = str(uuid.uuid4()) name = f'{self.logfilenamebase}-{sid}' logfilename = (pathlib.Path(self.tmpdir) / name).with_suffix(".log") self.logfile = logfilename.open("wb")