Skip to content

Fix director service discovery #1538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions services/director/src/simcore_service_director/producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def _check_node_uuid_available(
log.debug("Checked if UUID %s is already in use", node_uuid)
# check if service with same uuid already exists
try:
# not filtering by "swarm_stack_name" label because it's safer
list_of_running_services_w_uuid = await client.services.list(
filters={"label": "uuid=" + node_uuid}
)
Expand Down Expand Up @@ -812,7 +813,7 @@ async def get_services_details(
) -> List[Dict]:
async with docker_utils.docker_client() as client: # pylint: disable=not-async-context-manager
try:
filters = ["type=main"]
filters = ["type=main", f"swarm_stack_name={config.SWARM_STACK_NAME}"]
if user_id:
filters.append("user_id=" + user_id)
if study_id:
Expand Down Expand Up @@ -844,7 +845,7 @@ async def get_service_details(app: web.Application, node_uuid: str) -> Dict:
"label": [
f"uuid={node_uuid}",
"type=main",
f"swarm_stack_name={config.SWARM_STACK_NAME}"
f"swarm_stack_name={config.SWARM_STACK_NAME}",
]
}
)
Expand Down Expand Up @@ -875,7 +876,12 @@ async def stop_service(app: web.Application, node_uuid: str) -> None:
async with docker_utils.docker_client() as client: # pylint: disable=not-async-context-manager
try:
list_running_services_with_uuid = await client.services.list(
filters={"label": "uuid=" + node_uuid}
filters={
"label": [
f"uuid={node_uuid}",
f"swarm_stack_name={config.SWARM_STACK_NAME}",
]
}
)
except aiodocker.exceptions.DockerError as err:
log.exception("Error while stopping container with uuid: %s", node_uuid)
Expand Down