Skip to content

Commit bd4f611

Browse files
authored
🚑️ Dask sidecar must have a unique name, also when re-deploying (ITISFoundation#2641)
1 parent c406846 commit bd4f611

File tree

7 files changed

+16
-9
lines changed

7 files changed

+16
-9
lines changed

packages/pytest-simcore/src/pytest_simcore/rabbit_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import asyncio
66
import json
77
import logging
8+
import os
89
import socket
910
from dataclasses import dataclass
1011
from typing import Any, AsyncIterator, Dict, Iterator, Optional
@@ -87,7 +88,7 @@ def _reconnect_callback():
8788
# NOTE: to show the connection name in the rabbitMQ UI see there
8889
# https://www.bountysource.com/issues/89342433-setting-custom-connection-name-via-client_properties-doesn-t-work-when-connecting-using-an-amqp-url
8990
connection = await aio_pika.connect_robust(
90-
rabbit_config.dsn + f"?name={__name__}_{id(socket.gethostname())}",
91+
rabbit_config.dsn + f"?name={__name__}_{socket.gethostname()}_{os.getpid()}",
9192
client_properties={"connection_name": "pytest read connection"},
9293
)
9394
assert connection

packages/simcore-sdk/src/simcore_sdk/node_ports_common/dbmanager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import os
34
import socket
45
from typing import Optional
56

@@ -66,7 +67,7 @@ def __init__(self, db_engine: Optional[aiopg.sa.Engine] = None):
6667
@staticmethod
6768
async def _create_db_engine() -> aiopg.sa.Engine:
6869
dsn = DataSourceName(
69-
application_name=f"{__name__}_{id(socket.gethostname())}",
70+
application_name=f"{__name__}_{socket.gethostname()}_{os.getpid()}",
7071
database=config.POSTGRES_DB,
7172
user=config.POSTGRES_USER,
7273
password=config.POSTGRES_PW,

services/dask-sidecar/docker/boot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ else
116116
--dashboard-address 8787 \
117117
--memory-limit "$ram" \
118118
--resources "$resources" \
119-
--name "$(hostname)"
119+
--name "dask-sidecar_$(hostname)_$$"
120120
else
121121
exec dask-worker "${DASK_SCHEDULER_ADDRESS}" \
122122
--local-directory /tmp/dask-sidecar \
@@ -128,6 +128,6 @@ else
128128
--dashboard-address 8787 \
129129
--memory-limit "$ram" \
130130
--resources "$resources" \
131-
--name "$(hostname)"
131+
--name "dask-sidecar_$(hostname)_$$"
132132
fi
133133
fi

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/rabbitmq.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import logging
5+
import os
56
import socket
67
from asyncio import CancelledError, Queue, Task
78
from typing import Any, Dict, List, Optional, Union
@@ -84,7 +85,7 @@ async def connect(self) -> None:
8485
# NOTE: to show the connection name in the rabbitMQ UI see there [https://www.bountysource.com/issues/89342433-setting-custom-connection-name-via-client_properties-doesn-t-work-when-connecting-using-an-amqp-url]
8586
hostname = socket.gethostname()
8687
self._connection = await aio_pika.connect(
87-
url + f"?name={__name__}_{id(hostname)}",
88+
url + f"?name={__name__}_{id(hostname)}_{os.getpid()}",
8889
client_properties={
8990
"connection_name": f"dynamic-sidecar_{self._node_id} {hostname}"
9091
},

services/sidecar/src/simcore_service_sidecar/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
"""
44
import logging
5+
import os
56
import socket
67
from typing import Optional
78

@@ -40,7 +41,7 @@ def __init__(self):
4041

4142
async def __aenter__(self):
4243
dsn = DataSourceName(
43-
application_name=f"{__name__}_{id(socket.gethostname())}",
44+
application_name=f"{__name__}_{socket.gethostname()}_{os.getpid()}",
4445
database=POSTGRES_DB,
4546
user=POSTGRES_USER,
4647
password=POSTGRES_PW,

services/sidecar/src/simcore_service_sidecar/rabbitmq.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import os
34
import socket
45
from asyncio import CancelledError
56
from typing import Any, Dict, List, Optional, Union
@@ -59,7 +60,7 @@ async def connect(self):
5960

6061
# NOTE: to show the connection name in the rabbitMQ UI see there [https://www.bountysource.com/issues/89342433-setting-custom-connection-name-via-client_properties-doesn-t-work-when-connecting-using-an-amqp-url]
6162
self._connection = await aio_pika.connect(
62-
url + f"?name={__name__}_{id(socket.gethostname())}",
63+
url + f"?name={__name__}_{socket.gethostname()}_{os.getpid()}",
6364
client_properties={"connection_name": "sidecar connection"},
6465
)
6566
self._connection.add_close_callback(_close_callback)

services/web/server/src/simcore_service_webserver/computation_subscribe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import contextlib
33
import logging
4+
import os
45
import socket
56
from typing import Any, AsyncIterator, Awaitable, Callable, Dict, List
67

@@ -107,7 +108,8 @@ async def setup_rabbitmq_consumer(app: web.Application) -> AsyncIterator[None]:
107108
# NOTE: to show the connection name in the rabbitMQ UI see there [https://www.bountysource.com/issues/89342433-setting-custom-connection-name-via-client_properties-doesn-t-work-when-connecting-using-an-amqp-url]
108109
async def get_connection() -> aio_pika.Connection:
109110
return await aio_pika.connect_robust(
110-
f"{rabbit_broker}" + f"?name={__name__}_{socket.gethostname()}_{id(app)}",
111+
f"{rabbit_broker}"
112+
+ f"?name={__name__}_{socket.gethostname()}_{os.getpid()}",
111113
client_properties={"connection_name": "webserver read connection"},
112114
)
113115

@@ -147,7 +149,7 @@ async def exchange_consumer(
147149
)
148150
# Declaring queue
149151
queue = await channel.declare_queue(
150-
f"webserver_{socket.gethostname()}_{id(app)}_{exchange_name}",
152+
f"webserver_{exchange_name}_{socket.gethostname()}_{os.getpid()}",
151153
exclusive=True,
152154
arguments={"x-message-ttl": 60000},
153155
)

0 commit comments

Comments
 (0)