diff --git a/services/agent/src/simcore_service_agent/main.py b/services/agent/src/simcore_service_agent/main.py index 5d51293c64b..93b30dbbb45 100644 --- a/services/agent/src/simcore_service_agent/main.py +++ b/services/agent/src/simcore_service_agent/main.py @@ -5,11 +5,10 @@ from fastapi import FastAPI from servicelib.fastapi.logging_lifespan import create_logging_shutdown_event from servicelib.tracing import TracingConfig +from simcore_service_agent._meta import APP_NAME from simcore_service_agent.core.application import create_app from simcore_service_agent.core.settings import ApplicationSettings -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/services/api-server/src/simcore_service_api_server/main.py b/services/api-server/src/simcore_service_api_server/main.py index ace337b472e..0dfca9daa02 100644 --- a/services/api-server/src/simcore_service_api_server/main.py +++ b/services/api-server/src/simcore_service_api_server/main.py @@ -7,11 +7,10 @@ from fastapi import FastAPI from servicelib.fastapi.logging_lifespan import create_logging_shutdown_event from servicelib.tracing import TracingConfig +from simcore_service_api_server._meta import APP_NAME from simcore_service_api_server.core.application import create_app from simcore_service_api_server.core.settings import ApplicationSettings -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/services/autoscaling/src/simcore_service_autoscaling/main.py b/services/autoscaling/src/simcore_service_autoscaling/main.py index 48b5fe82b45..ea7449c68cf 100644 --- a/services/autoscaling/src/simcore_service_autoscaling/main.py +++ b/services/autoscaling/src/simcore_service_autoscaling/main.py @@ -7,11 +7,10 @@ from fastapi import FastAPI from servicelib import tracing from servicelib.fastapi.logging_lifespan import create_logging_shutdown_event +from simcore_service_autoscaling._meta import APP_NAME from simcore_service_autoscaling.core.application import create_app from simcore_service_autoscaling.core.settings import ApplicationSettings -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/services/docker-compose.devel.yml b/services/docker-compose.devel.yml index 28e5a8bfa95..b951454b22f 100644 --- a/services/docker-compose.devel.yml +++ b/services/docker-compose.devel.yml @@ -3,7 +3,7 @@ # NOTES: # - port 3000 used for ptsv # -x-common-environment: &common-environment +x-common_environment: &common_environment # Enforces *_DEBUG option in all services. ONLY allowed in devel-mode! DEBUG : "true" # Enforces app to boot debug mode (see docker/boot.sh). ONLY allowed in devel-mode! @@ -13,7 +13,7 @@ x-common-environment: &common-environment services: api-server: environment: - <<: *common-environment + <<: *common_environment API_SERVER_PROFILING : ${API_SERVER_PROFILING} API_SERVER_LOGLEVEL: DEBUG volumes: @@ -23,7 +23,7 @@ services: api-worker: environment: - <<: *common-environment + <<: *common_environment API_SERVER_PROFILING : ${API_SERVER_PROFILING} API_SERVER_LOGLEVEL: DEBUG volumes: @@ -33,7 +33,7 @@ services: autoscaling: environment: - <<: *common-environment + <<: *common_environment AUTOSCALING_LOGLEVEL: DEBUG volumes: @@ -43,7 +43,7 @@ services: invitations: environment: - <<: *common-environment + <<: *common_environment INVITATIONS_LOGLEVEL: DEBUG volumes: - ./invitations:/devel/services/invitations @@ -52,7 +52,7 @@ services: payments: environment: - <<: *common-environment + <<: *common_environment PAYMENTS_LOGLEVEL: DEBUG volumes: - ./payments:/devel/services/payments @@ -61,7 +61,7 @@ services: dynamic-schdlr: environment: - <<: *common-environment + <<: *common_environment DYNAMIC_SCHEDULER_PROFILING : ${DYNAMIC_SCHEDULER_PROFILING} DYNAMIC_SCHEDULER_LOGLEVEL: DEBUG volumes: @@ -73,7 +73,7 @@ services: catalog: environment: - <<: *common-environment + <<: *common_environment CATALOG_PROFILING : ${CATALOG_PROFILING} DYNAMIC_SIDECAR_MOUNT_PATH_DEV : ${PWD}/services/dynamic-sidecar CATALOG_LOGLEVEL: DEBUG @@ -84,7 +84,7 @@ services: notifications: environment: - <<: *common-environment + <<: *common_environment NOTIFICATIONS_PROFILING : ${NOTIFICATIONS_PROFILING} NOTIFICATIONS_LOGLEVEL: DEBUG volumes: @@ -94,7 +94,7 @@ services: clusters-keeper: environment: - <<: *common-environment + <<: *common_environment CLUSTERS_KEEPER_LOGLEVEL: DEBUG volumes: - ./clusters-keeper:/devel/services/clusters-keeper @@ -103,7 +103,7 @@ services: datcore-adapter: environment: - <<: *common-environment + <<: *common_environment DATCORE_ADAPTER_LOGLEVEL: DEBUG volumes: - ./datcore-adapter:/devel/services/datcore-adapter @@ -121,7 +121,7 @@ services: director-v2: environment: - <<: *common-environment + <<: *common_environment DIRECTOR_V2_PROFILING : ${DIRECTOR_V2_PROFILING} DYNAMIC_SIDECAR_MOUNT_PATH_DEV : ${PWD}/services/dynamic-sidecar DIRECTOR_V2_LOGLEVEL: DEBUG @@ -133,7 +133,7 @@ services: efs-guardian: environment: - <<: *common-environment + <<: *common_environment EFS_GUARDIAN_LOGLEVEL: DEBUG volumes: - ./efs-guardian:/devel/services/efs-guardian @@ -155,7 +155,7 @@ services: - ../packages:/devel/packages - ${HOST_UV_CACHE_DIR}:/home/scu/.cache/uv environment: &webserver_environment_devel - <<: *common-environment + <<: *common_environment DEBUG: 1 # NOTE: gunicorn expects an int not a boolean WEBSERVER_LOGLEVEL: DEBUG WEBSERVER_PROFILING: ${WEBSERVER_PROFILING} @@ -192,7 +192,7 @@ services: - ${ETC_HOSTNAME:-/etc/hostname}:/home/scu/hostname:ro environment: - <<: *common-environment + <<: *common_environment SIDECAR_LOGLEVEL: DEBUG ports: - "3000" @@ -202,7 +202,7 @@ services: dask-scheduler: volumes: *dask-sidecar_volumes_devel environment: - <<: *common-environment + <<: *common_environment SIDECAR_LOGLEVEL: DEBUG ports: - "3000" @@ -212,7 +212,7 @@ services: resource-usage-tracker: environment: - <<: *common-environment + <<: *common_environment RESOURCE_USAGE_TRACKER_LOGLEVEL: DEBUG volumes: - ./resource-usage-tracker:/devel/services/resource-usage-tracker @@ -225,7 +225,7 @@ services: - ../packages:/devel/packages - ${HOST_UV_CACHE_DIR}:/home/scu/.cache/uv environment: - <<: *common-environment + <<: *common_environment STORAGE_PROFILING : ${STORAGE_PROFILING} STORAGE_LOGLEVEL: DEBUG @@ -235,7 +235,7 @@ services: - ../packages:/devel/packages - ${HOST_UV_CACHE_DIR}:/home/scu/.cache/uv environment: - <<: *common-environment + <<: *common_environment STORAGE_PROFILING : ${STORAGE_PROFILING} STORAGE_LOGLEVEL: DEBUG @@ -245,13 +245,13 @@ services: - ../packages:/devel/packages - ${HOST_UV_CACHE_DIR}:/home/scu/.cache/uv environment: - <<: *common-environment + <<: *common_environment STORAGE_PROFILING : ${STORAGE_PROFILING} STORAGE_LOGLEVEL: DEBUG agent: environment: - <<: *common-environment + <<: *common_environment AGENT_LOGLEVEL: DEBUG volumes: - ./agent:/devel/services/agent diff --git a/services/docker-compose.local.yml b/services/docker-compose.local.yml index f1b1514ba55..18eab31dfe2 100644 --- a/services/docker-compose.local.yml +++ b/services/docker-compose.local.yml @@ -12,6 +12,8 @@ # x-common-environment: &common_environment SWARM_STACK_NAME : ${SWARM_STACK_NAME:-simcore_local} + + services: api-server: environment: @@ -297,8 +299,3 @@ services: - traefik.http.routers.${SWARM_STACK_NAME}_whoami.rule=PathPrefix(`/whoami`) - traefik.http.routers.${SWARM_STACK_NAME}_whoami.entrypoints=traefik_monitor - traefik.http.routers.${SWARM_STACK_NAME}_whoami.middlewares=${SWARM_STACK_NAME}_gzip@swarm - -networks: - docker-api-network: - driver_opts: - {} # override 'encrypted' locally, some WSL versions have issues with encrypted networks SEE https://github.com/microsoft/WSL/issues/10029 diff --git a/services/docker-compose.yml b/services/docker-compose.yml index 223277d9b1a..afafa768b27 100644 --- a/services/docker-compose.yml +++ b/services/docker-compose.yml @@ -561,7 +561,7 @@ services: hostname: "{{.Node.Hostname}}-{{.Task.Slot}}" networks: - default - - docker-api-network + - docker_api_subnet environment: <<: - *common_logging_environments @@ -603,7 +603,7 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock networks: - - docker-api-network + - docker_api_subnet static-webserver: image: ${DOCKER_REGISTRY:-itisfoundation}/static-webserver:${DOCKER_IMAGE_TAG:-latest} @@ -1557,8 +1557,8 @@ networks: internal: false labels: com.simcore.description: "computational services network" - docker-api-network: - name: ${SWARM_STACK_NAME}_docker-api-network + docker_api_subnet: + name: ${SWARM_STACK_NAME}_docker_api_subnet driver: overlay attachable: true internal: true diff --git a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/main.py b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/main.py index a08411cc2c5..786de55895e 100644 --- a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/main.py +++ b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/main.py @@ -9,11 +9,10 @@ create_logging_lifespan, ) from servicelib.tracing import TracingConfig +from simcore_service_dynamic_scheduler._meta import APP_NAME from simcore_service_dynamic_scheduler.core.application import create_app from simcore_service_dynamic_scheduler.core.settings import ApplicationSettings -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/services/notifications/src/simcore_service_notifications/main.py b/services/notifications/src/simcore_service_notifications/main.py index 84d32dc2705..a5791a984ff 100644 --- a/services/notifications/src/simcore_service_notifications/main.py +++ b/services/notifications/src/simcore_service_notifications/main.py @@ -5,13 +5,12 @@ from fastapi import FastAPI from servicelib.fastapi.logging_lifespan import create_logging_lifespan from servicelib.tracing import TracingConfig +from simcore_service_notifications._meta import APP_NAME from simcore_service_notifications.core.application import create_app from simcore_service_notifications.core.settings import ( ApplicationSettings, ) -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/services/storage/src/simcore_service_storage/main.py b/services/storage/src/simcore_service_storage/main.py index 4762791a5b8..0ed373e2ee7 100644 --- a/services/storage/src/simcore_service_storage/main.py +++ b/services/storage/src/simcore_service_storage/main.py @@ -7,11 +7,10 @@ from fastapi import FastAPI from servicelib.fastapi.logging_lifespan import create_logging_shutdown_event from servicelib.tracing import TracingConfig +from simcore_service_storage._meta import APP_NAME from simcore_service_storage.core.application import create_app from simcore_service_storage.core.settings import ApplicationSettings -from ._meta import APP_NAME - _logger = logging.getLogger(__name__) _NOISY_LOGGERS: Final[tuple[str, ...]] = ( diff --git a/tests/environment-setup/test_used_docker_compose.py b/tests/environment-setup/test_used_docker_compose.py index c083c79b206..4fc37d4d460 100644 --- a/tests/environment-setup/test_used_docker_compose.py +++ b/tests/environment-setup/test_used_docker_compose.py @@ -1,6 +1,7 @@ -# pylint: disable=unused-argument -# pylint: disable=bare-except # pylint: disable=redefined-outer-name +# pylint: disable=unused-argument +# pylint: disable=unused-variable +# pylint: disable=too-many-arguments import re import shutil @@ -110,7 +111,7 @@ def docker_compose_config_bash(osparc_simcore_scripts_dir: Path) -> Path: def test_validate_compose_file( compose_path: Path, env_devel_file: Path, - ensure_env_file, + ensure_env_file: Path, docker_compose_config_bash: Path, ): assert compose_path.exists() @@ -119,7 +120,7 @@ def test_validate_compose_file( # NOTE: with docker stack config, the .env file MUST be alongside the docker-compose file - subprocess.run( + subprocess.run( # noqa: S602 " ".join( [ f"{docker_compose_config_bash}", @@ -135,3 +136,30 @@ def test_validate_compose_file( # About versioning https://docs.docker.com/compose/compose-file/compose-file-v3/ assert "version" not in compose + + +@pytest.mark.parametrize( + "compose_path", compose_paths, ids=lambda p: str(p.relative_to(repo_dir)) +) +def test_network_names_contain_only_letters_and_underscores( + compose_path: Path, +): + """Ensure all network names only contain letters and underscores (no hyphens or other symbols). + + + NOTE: Our docker compose cannot resolve network names with hyphens + + e.g. `make .stack-simcore-development.yml` produces a compose file that do not include these networks which + results in an error when the stack starts that prints something like + + ERROR: failed to create service master-simcore_docker-api-proxy: Error response from daemon: network master-simcore_docker-api-network not found + """ + assert compose_path.exists() + compose = yaml.safe_load(compose_path.read_text()) + + networks = compose.get("networks", {}) + + for network_name in networks: + assert re.match( + r"^[a-zA-Z_]+$", network_name + ), f"Network name '{network_name}' in {compose_path.relative_to(repo_dir)} contains invalid characters. Only letters and underscores are allowed."