Skip to content

Commit 403df86

Browse files
GitHKAndrei Neagu
andauthored
Fix director service discovery (#1538)
* stop service will no longer fial the tg task on erro * downgraded errors to warnings they are being handled * services correctly filtered between environments swarm_stack_name label is used Co-authored-by: Andrei Neagu <[email protected]>
1 parent 83b3a2b commit 403df86

File tree

1 file changed

+9
-3
lines changed
  • services/director/src/simcore_service_director

1 file changed

+9
-3
lines changed

services/director/src/simcore_service_director/producer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def _check_node_uuid_available(
4444
log.debug("Checked if UUID %s is already in use", node_uuid)
4545
# check if service with same uuid already exists
4646
try:
47+
# not filtering by "swarm_stack_name" label because it's safer
4748
list_of_running_services_w_uuid = await client.services.list(
4849
filters={"label": "uuid=" + node_uuid}
4950
)
@@ -812,7 +813,7 @@ async def get_services_details(
812813
) -> List[Dict]:
813814
async with docker_utils.docker_client() as client: # pylint: disable=not-async-context-manager
814815
try:
815-
filters = ["type=main"]
816+
filters = ["type=main", f"swarm_stack_name={config.SWARM_STACK_NAME}"]
816817
if user_id:
817818
filters.append("user_id=" + user_id)
818819
if study_id:
@@ -844,7 +845,7 @@ async def get_service_details(app: web.Application, node_uuid: str) -> Dict:
844845
"label": [
845846
f"uuid={node_uuid}",
846847
"type=main",
847-
f"swarm_stack_name={config.SWARM_STACK_NAME}"
848+
f"swarm_stack_name={config.SWARM_STACK_NAME}",
848849
]
849850
}
850851
)
@@ -875,7 +876,12 @@ async def stop_service(app: web.Application, node_uuid: str) -> None:
875876
async with docker_utils.docker_client() as client: # pylint: disable=not-async-context-manager
876877
try:
877878
list_running_services_with_uuid = await client.services.list(
878-
filters={"label": "uuid=" + node_uuid}
879+
filters={
880+
"label": [
881+
f"uuid={node_uuid}",
882+
f"swarm_stack_name={config.SWARM_STACK_NAME}",
883+
]
884+
}
879885
)
880886
except aiodocker.exceptions.DockerError as err:
881887
log.exception("Error while stopping container with uuid: %s", node_uuid)

0 commit comments

Comments
 (0)