Skip to content

Commit

Permalink
Is1877/allow constraints on director services (#1878)
Browse files Browse the repository at this point in the history
* added DIRECTOR_SERVICES_CUSTOM_CONSTRAINTS variable
  • Loading branch information
sanderegg authored Oct 14, 2020
1 parent 217aac9 commit a9cf515
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ jobs:
- name: set target variable
run: |
target=$(git name-rev --refs="refs/remotes/origin/*" --name-only ${GITHUB_SHA})
echo ::set-env name=TARGET::${target}
echo "TARGET=${target}" >> $GITHUB_ENV
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: set owner variable
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*}
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
- name: set git tag
run: echo ::set-env name=GIT_TAG::${GITHUB_REF##*/}
run: echo "GIT_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
- if: env.TARGET == 'remotes/origin/master'
env:
FROM_TAG_PREFIX: staging-github
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: set owner variable
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*}
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
- name: set git tag
run: echo ::set-env name=GIT_TAG::${GITHUB_REF##*/}
run: echo "GIT_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: deploy
run: ./ci/deploy/dockerhub-tag-version.bash
62 changes: 31 additions & 31 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -238,7 +238,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -353,7 +353,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -402,7 +402,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -451,7 +451,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -500,7 +500,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -549,7 +549,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -599,7 +599,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -649,7 +649,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -699,7 +699,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -749,7 +749,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -795,7 +795,7 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: show system environs
if: github.event_name == 'push'
run: ./ci/helpers/show_system_versions.bash
Expand All @@ -807,7 +807,7 @@ jobs:
run: ./ci/build/test-images.bash build_images
- name: set owner variable
if: github.event_name == 'push'
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*}
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
- name: push images
# only pushes have access to the docker credentials
if: github.event_name == 'push'
Expand All @@ -828,14 +828,14 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -893,14 +893,14 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -958,14 +958,14 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -1023,14 +1023,14 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -1072,14 +1072,14 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup docker
run: |
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: setup python environment
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -1152,7 +1152,7 @@ jobs:
if: github.event_name == 'pull_request'
run: |
export TMP_DOCKER_REGISTRY=${GITHUB_REPOSITORY%/*}
echo ::set-env name=DOCKER_REGISTRY::${TMP_DOCKER_REGISTRY,,}
echo "DOCKER_REGISTRY=${TMP_DOCKER_REGISTRY,,}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: setup python environment
uses: actions/setup-python@v2
Expand Down Expand Up @@ -1307,9 +1307,9 @@ jobs:
sudo ./ci/github/helpers/setup_docker_compose.bash
./ci/github/helpers/setup_docker_experimental.bash
./ci/github/helpers/setup_docker_buildx.bash
echo ::set-env name=DOCKER_BUILDX::1
echo "DOCKER_BUILDX=1" >> $GITHUB_ENV
- name: set owner variable
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*}
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
- name: deploy master
if: github.ref == 'refs/heads/master'
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_template_db(postgres_dsn: Dict, postgres_engine: sa.engine.Engine) ->
queries = [
# disconnect existing users
f"""
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = '{postgres_dsn["database"]}' AND pid <> pg_backend_pid();
""",
# drop template database
Expand Down Expand Up @@ -116,7 +116,7 @@ def database_from_template_before_each_function(
queries = [
# terminate existing connections to the database
f"""
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = '{postgres_dsn["database"]}';
""",
# drop database
Expand Down Expand Up @@ -209,7 +209,7 @@ def postgres_session(postgres_db: sa.engine.Engine) -> sa.orm.session.Session:

@tenacity.retry(
wait=tenacity.wait_fixed(5),
stop=tenacity.stop_after_attempt(20),
stop=tenacity.stop_after_attempt(60),
before_sleep=tenacity.before_sleep_log(log, logging.INFO),
reraise=True,
)
Expand Down
11 changes: 9 additions & 2 deletions packages/pytest-simcore/src/pytest_simcore/rabbit_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
# pylint:disable=unused-argument
# pylint:disable=redefined-outer-name

import logging
import os
import socket
from typing import Any, Dict, Optional, Tuple

import aio_pika
import pytest
import tenacity
from servicelib.rabbitmq_utils import RabbitMQRetryPolicyUponInitialization
from simcore_sdk.config.rabbit import Config

from .helpers.utils_docker import get_service_published_port

log = logging.getLogger(__name__)


@pytest.fixture(scope="module")
def rabbit_config(docker_stack: Dict, devel_environ: Dict) -> Config:
Expand Down Expand Up @@ -127,7 +129,12 @@ async def rabbit_queue(
# HELPERS --


@tenacity.retry(**RabbitMQRetryPolicyUponInitialization().kwargs)
@tenacity.retry(
wait=tenacity.wait_fixed(5),
stop=tenacity.stop_after_attempt(60),
before_sleep=tenacity.before_sleep_log(log, logging.INFO),
reraise=True,
)
async def wait_till_rabbit_responsive(url: str) -> None:
connection = await aio_pika.connect(url)
await connection.close()
1 change: 1 addition & 0 deletions services/catalog/docker-compose-extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
- REGISTRY_SSL=${REGISTRY_SSL}
- DIRECTOR_REGISTRY_CACHING=${DIRECTOR_REGISTRY_CACHING}
- DIRECTOR_REGISTRY_CACHING_TTL=${DIRECTOR_REGISTRY_CACHING_TTL}
- DIRECTOR_SERVICES_CUSTOM_CONSTRAINTS=${DIRECTOR_SERVICES_CUSTOM_CONSTRAINTS}
- DIRECTOR_SELF_SIGNED_SSL_SECRET_ID=${DIRECTOR_SELF_SIGNED_SSL_SECRET_ID}
- DIRECTOR_SELF_SIGNED_SSL_SECRET_NAME=${DIRECTOR_SELF_SIGNED_SSL_SECRET_NAME}
- DIRECTOR_SELF_SIGNED_SSL_FILENAME=${DIRECTOR_SELF_SIGNED_SSL_FILENAME}
Expand Down
7 changes: 6 additions & 1 deletion services/director/src/simcore_service_director/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
LOGLEVEL_STR = os.environ.get("LOGLEVEL", "WARNING").upper()
log_level = getattr(logging, LOGLEVEL_STR)
logging.basicConfig(
level=log_level, format="%(levelname)s:%(name)s-%(lineno)d: %(message)s",
level=log_level,
format="%(levelname)s:%(name)s-%(lineno)d: %(message)s",
)
logging.root.setLevel(log_level)

Expand All @@ -38,6 +39,10 @@
os.environ.get("DIRECTOR_REGISTRY_CACHING_TTL", 15 * 60)
)

DIRECTOR_SERVICES_CUSTOM_CONSTRAINTS: str = os.environ.get(
"DIRECTOR_SERVICES_CUSTOM_CONSTRAINTS", ""
)

# for passing self-signed certificate to spawned services
DIRECTOR_SELF_SIGNED_SSL_SECRET_ID: str = os.environ.get(
"DIRECTOR_SELF_SIGNED_SSL_SECRET_ID", ""
Expand Down
Loading

0 comments on commit a9cf515

Please sign in to comment.