Skip to content

Commit

Permalink
Merge pull request #2166 from AlexsLemonade/dev
Browse files Browse the repository at this point in the history
[DEPLOY] Deploy final fixes to pg_bouncer config and fix intermittent test failures.
  • Loading branch information
kurtwheeler authored Feb 26, 2020
2 parents b47923f + 7c38f08 commit a8476ae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
8 changes: 8 additions & 0 deletions common/data_refinery_common/models/original_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ def needs_downloading(self, own_processor_id=None) -> bool:
if unstarted_downloader_jobs.count() > 0:
return False

# Do an extra check for blocking jobs for trancsriptome indices.
# This is necessary because needs_processing() won't check
# the blocking jobs for them because they're supposed to
# have multiple processor jobs. However if the file does need to
# be redownloaded, we only want one downloader job to be recreated.
if self.has_blocking_jobs(own_processor_id):
return False

# If this file has been processed, then it doesn't need to be downloaded again.
return self.needs_processing(own_processor_id)

Expand Down
7 changes: 5 additions & 2 deletions infrastructure/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ docker pull $DOCKERHUB_REPO/$FOREMAN_DOCKER_IMAGE
# Test that the pg_bouncer instance is up. 15 minutes should be more than enough.
start_time=$(date +%s)
diff=0
until pg_isready -d $DATABASE_NAME -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER &> /dev/null || [ "$diff" -gt "900" ]
until pg_isready -d $DATABASE_NAME -h $DATABASE_PUBLIC_HOST -p $DATABASE_PORT -U $DATABASE_USER &> /dev/null || [ "$diff" -gt "900" ]
do
echo "Waiting for the pg_bouncer instance to come online ..."
sleep 10
let "diff = $(date +%s) - $start_time"
done

if ! pg_isready -d $DATABASE_NAME -h $DATABASE_HOST -p $DATABASE_PORT -U $DATABASE_USER &> /dev/null; then
if ! pg_isready -d $DATABASE_NAME -h $DATABASE_PUBLIC_HOST -p $DATABASE_PORT -U $DATABASE_USER &> /dev/null; then
echo "pg_bouncer instance failed to come up after 15 minutes."
exit 1
fi
Expand All @@ -273,18 +273,21 @@ fi
docker run \
--env-file prod_env \
--env RUNNING_IN_CLOUD=False \
--env DATABASE_HOST=$DATABASE_PUBLIC_HOST \
$DOCKERHUB_REPO/$FOREMAN_DOCKER_IMAGE python3 manage.py migrate auth

# Apply general migrations.
docker run \
--env-file prod_env \
--env RUNNING_IN_CLOUD=False \
--env DATABASE_HOST=$DATABASE_PUBLIC_HOST \
$DOCKERHUB_REPO/$FOREMAN_DOCKER_IMAGE python3 manage.py migrate

# Create the cache table if it does not already exist.
docker run \
--env-file prod_env \
--env RUNNING_IN_CLOUD=False \
--env DATABASE_HOST=$DATABASE_PUBLIC_HOST \
$DOCKERHUB_REPO/$FOREMAN_DOCKER_IMAGE python3 manage.py createcachetable

# Make sure to clear out any old nomad job specifications since we
Expand Down
Binary file modified infrastructure/environments/staging.tfvars
Binary file not shown.
4 changes: 4 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ output "environment_variables" {
{name = "DATABASE_NAME"
value = "${aws_db_instance.postgres_db.name}"},
{name = "DATABASE_HOST"
value = "${aws_instance.pg_bouncer.private_ip}"},
# We want to use the private IP from everywhere except wherever
# deployment is happening, so we also need to expose this IP.
{name = "DATABASE_PUBLIC_HOST"
value = "${aws_instance.pg_bouncer.public_ip}"},
{name = "RDS_HOST"
value = "${aws_db_instance.postgres_db.address}"},
Expand Down
6 changes: 1 addition & 5 deletions workers/data_refinery_workers/processors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
ProcessorJobOriginalFileAssociation,
Sample,
)
from data_refinery_common.utils import (
get_env_variable,
get_env_variable_gracefully,
get_instance_id,
)
from data_refinery_common.utils import get_env_variable, get_instance_id

logger = get_and_configure_logger(__name__)
# Let this fail if SYSTEM_VERSION is unset.
Expand Down

0 comments on commit a8476ae

Please sign in to comment.