Skip to content

Commit

Permalink
DRIVERS-2543 Pull mongohouse image from ADL ECR repo (#363)
Browse files Browse the repository at this point in the history
* DRIVERS-2543 Pull mongohouse image from ADL ECR repo

* bootstrap the secret

* cleanup

* support podman

* try again

* undo changes

* fix handling of token

* expose port

* fix usage of tty

* add sleep and debug print

* remove sleep

* try acquiring creds

* try again

* try again

* fix arg name

* fix arg handling

* Add local config file

* fix docker invocation

* fix docker invocation

* detach the docker container

* Use separate files for ECR image usage

* use updated config

* restore config.yml

* address review
  • Loading branch information
blink1073 authored Nov 6, 2023
1 parent 5dd829b commit 428a52e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 6 deletions.
23 changes: 22 additions & 1 deletion .evergreen/atlas_data_lake/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Atlas Data Lake Testing

The files in this directory are required to build and launch a local
## Git Checkout

Two scripts in this directory are required to build and launch a local
`mongohoused` for testing. In the Evergreen configuration file, execute
the following command in the foreground to build the server:

Expand All @@ -16,3 +18,22 @@ sh ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-local.sh

`$DRIVERS_TOOLS` is an environment variable set to the root directory
of the clone of the `drivers-evergreen-tools` repository.

## Docker Image

Two scripts in this directory are required to pull and run the
`mongohoused` docker image. In the Evergreen configuration file, execute
the following command in the foreground to build the server:

```
bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/pull-mongohouse-image.sh
```

and the following command in the foreground to run the server:

```
bash ${DRIVERS_TOOLS}/.evergreen/atlas_data_lake/run-mongohouse-image.sh
```

`$DRIVERS_TOOLS` is an environment variable set to the root directory
of the clone of the `drivers-evergreen-tools` repository.
Empty file modified .evergreen/atlas_data_lake/build-mongohouse-local.sh
100755 → 100644
Empty file.
15 changes: 15 additions & 0 deletions .evergreen/atlas_data_lake/pull-mongohouse-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# This script sets up the local docker image for mongohoused.
#
set -eux

DRIVERS_TOOLS=${DRIVERS_TOOLS:-$(readlink -f ../..)}
REPO="904697982180.dkr.ecr.us-east-1.amazonaws.com/atlas-query-engine-test"
pushd $DRIVERS_TOOLS/.evergreen/auth_aws
bash setup_secrets.sh drivers/adl
source secrets-export.sh
unset AWS_SESSION_TOKEN
popd
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $REPO
docker pull $REPO
13 changes: 13 additions & 0 deletions .evergreen/atlas_data_lake/run-mongohouse-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
#
# This script launches a docker-based mongohoused for testing.
#
# There is no corresponding 'shutdown' script; this project relies
# on Evergreen to terminate processes and clean up when tasks end.
set -eux

DRIVERS_TOOLS=${DRIVERS_TOOLS:-$(readlink -f ../..)}
IMAGE=904697982180.dkr.ecr.us-east-1.amazonaws.com/atlas-query-engine-test
USE_TTY=""
test -t 1 && USE_TTY="-t"
docker run -d -p 27017:27017 -v "$DRIVERS_TOOLS/.evergreen/atlas_data_lake:/src" -i $USE_TTY $IMAGE --config ./testdata/config/external/drivers/config.yaml
Empty file modified .evergreen/atlas_data_lake/run-mongohouse-local.sh
100755 → 100644
Empty file.
12 changes: 7 additions & 5 deletions .evergreen/auth_aws/setup_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

AWS_ROLE_ARN = "arn:aws:iam::857654397073:role/drivers-test-secrets-role"


def get_secrets(vaults, region, profile):
"""Get the driver secret values."""
# Handle local credentials.
profile = profile or os.environ.get("AWS_PROFILE")
session = boto3.Session(profile_name=profile)
creds = None
kwargs = dict(region_name=region)
if "AWS_ACCESS_KEY_ID" not in os.environ and not profile:
session = boto3.Session(profile_name=profile)
client = session.client(service_name='sts', **kwargs)
try:
# This will only fail locally.
Expand All @@ -29,11 +31,11 @@ def get_secrets(vaults, region, profile):
raise ValueError("Please provide a profile (typically using AWS_PROFILE)")

creds = resp['Credentials']

if creds:
kwargs.update(aws_access_key_id=creds['AccessKeyId'],
aws_secret_access_key=creds['SecretAccessKey'],
aws_session_token=creds['SessionToken'])
else:
session = boto3.Session(profile_name=profile)
aws_secret_access_key=creds['SecretAccessKey'],
aws_session_token=creds['SessionToken'])
client = session.client(service_name='secretsmanager', **kwargs)

secrets = []
Expand Down

0 comments on commit 428a52e

Please sign in to comment.