-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we are now able to ping and set a specific password in the started ga…
…teway
- Loading branch information
Showing
6 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
services/clusters-keeper/src/simcore_service_clusters_keeper/modules/dask.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
import contextlib | ||
import asyncio | ||
import logging | ||
|
||
import dask_gateway | ||
from aiohttp.client_exceptions import ClientError | ||
from pydantic import SecretStr | ||
|
||
from ..models import EC2InstanceData | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
async def ping_gateway(ec2_instance: EC2InstanceData) -> bool: | ||
basic_auth = dask_gateway.BasicAuth(username="bing", password="asdf") | ||
with contextlib.suppress(ClientError): | ||
async def ping_gateway( | ||
ec2_instance: EC2InstanceData, gateway_password: SecretStr | ||
) -> bool: | ||
basic_auth = dask_gateway.BasicAuth( | ||
username="clusters-keeper", password="my_secure_P1ssword" | ||
) | ||
try: | ||
async with dask_gateway.Gateway( | ||
address=f"http://{ec2_instance.aws_public_ip}:8000", | ||
auth=basic_auth, | ||
asynchronous=True, | ||
) as gateway: | ||
cluster_reports = await gateway.list_clusters() | ||
cluster_reports = await asyncio.wait_for(gateway.list_clusters(), timeout=5) | ||
_logger.info("found %s clusters", len(cluster_reports)) | ||
return True | ||
except (ClientError, asyncio.TimeoutError): | ||
_logger.info("dask-gateway is unavailable", exc_info=True) | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 8 additions & 3 deletions
11
services/clusters-keeper/src/simcore_service_clusters_keeper/utils/clusters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
def create_startup_script() -> str: | ||
from ..core.settings import ApplicationSettings | ||
|
||
|
||
def create_startup_script(app_settings: ApplicationSettings) -> str: | ||
return "\n".join( | ||
[ | ||
"git clone https://github.com/ITISFoundation/osparc-simcore.git", | ||
"git clone --depth=1 https://github.com/ITISFoundation/osparc-simcore.git", | ||
"cd osparc-simcore/services/osparc-gateway-server", | ||
"make up-latest", | ||
"make config", | ||
f"echo 'c.Authenticator.password = \"{app_settings.CLUSTERS_KEEPER_COMPUTATIONAL_BACKEND_GATEWAY_PASSWORD.get_secret_value()}\"' >> .osparc-dask-gateway-config.py", | ||
f"DOCKER_IMAGE_TAG={app_settings.CLUSTERS_KEEPER_COMPUTATIONAL_BACKEND_DOCKER_IMAGE_TAG} make up", | ||
] | ||
) |