Skip to content

Commit 033e497

Browse files
authored
Ensures client and worker IDs are always unique (fixes finos#419). (finos#420)
Signed-off-by: rafa-be <raphael@noisycamp.com>
1 parent 2295a1b commit 033e497

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/scaler/cluster/combo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
object_storage_address=self._object_storage_address,
9090
preload=None,
9191
worker_io_threads=worker_io_threads,
92-
worker_names=[f"{socket.gethostname().split('.')[0]}_{i}" for i in range(n_workers)],
92+
worker_names=[f"{socket.gethostname().split('.')[0]}" for _ in range(n_workers)],
9393
per_worker_capabilities=per_worker_capabilities or {},
9494
per_worker_task_queue_size=per_worker_task_queue_size,
9595
heartbeat_interval_seconds=heartbeat_interval_seconds,

src/scaler/utility/identifiers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ def __repr__(self) -> str:
1616

1717
@staticmethod
1818
def generate_client_id(name: Optional[str] = None) -> "ClientID":
19-
if name is None:
20-
name = uuid.uuid4().bytes.hex()
19+
unique_client_tag = uuid.uuid4().bytes.hex()
2120

22-
return ClientID(f"Client|{name}".encode())
21+
if name is None:
22+
return ClientID(f"Client|{unique_client_tag}".encode())
23+
else:
24+
return ClientID(f"Client|{name}|{unique_client_tag}".encode())
2325

2426

2527
class WorkerID(Identifier):
@@ -35,7 +37,8 @@ def invalid_worker_id() -> "WorkerID":
3537

3638
@staticmethod
3739
def generate_worker_id(name: str) -> "WorkerID":
38-
return WorkerID(f"Worker|{name}".encode())
40+
unique_worker_tag = uuid.uuid4().bytes.hex()
41+
return WorkerID(f"Worker|{name}|{unique_worker_tag}".encode())
3942

4043

4144
_INVALID_WORKER_ID = WorkerID(b"")

0 commit comments

Comments
 (0)