Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment documentation #427

Merged
merged 32 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9b0cae6
Use environment variable to set celery concurrency.
Sep 11, 2019
50dbc48
Split the celery option `-Ofair` to inlcude a space.
Sep 11, 2019
49bfc21
In most of the templates, add some requirements on values.
Sep 11, 2019
555654e
Change the deployment configmap.
Sep 11, 2019
7000f3d
Re-order and add commented out values.
Sep 11, 2019
89fcf7e
Was convenient to have, but may be confusing.
Sep 11, 2019
bd071e1
Update chart value.
Sep 11, 2019
cb85002
Comment in code to ask for dev to mention what env variables are modi…
Sep 11, 2019
f8bb8a9
A tiny help read me for the deployment.
Sep 11, 2019
38b9a22
Comment the helm values.yaml file.
Sep 11, 2019
b8b77a5
Update docker-compose file to include limitation on number of datbase…
Sep 11, 2019
ba3eadb
Not sure what we want in this documentation...
Sep 11, 2019
4e09872
Docstring to comments.
Sep 12, 2019
778a863
This template is not working and may not be usable.
Sep 16, 2019
60ad3e6
Update the default value.yaml file.
Sep 16, 2019
7472f23
Some update in a readme which needs to move.
Sep 16, 2019
a76b937
git should ignore the charts.
Sep 16, 2019
f41a14c
Remove minimal value.
Sep 16, 2019
27f6ae8
Delete a README not updated.
Sep 16, 2019
236f2f7
Update the production-deployment docs.
Sep 16, 2019
4157f34
Remove this documentation which is now redundant as added to the prod…
Sep 16, 2019
7136571
Azure pipeline: remove using `values.yaml` file as it is always used.
Sep 16, 2019
e415cd5
Remove using the minimalvalues.yaml file as the default deployment is…
Sep 16, 2019
ae6e5a9
Remove all mention of value files in azure pipeline.
Sep 16, 2019
617a5c3
Merge branch 'develop' into deployment-documentation
gusmith Sep 17, 2019
7e2eee9
disable celery monitring by default
Sep 17, 2019
a45d98a
Split DATABASE_MIN_CONNECTIONS and max into their celery and flask co…
Sep 17, 2019
b9abf3e
Update the methods initializaing the database connection pool.
Sep 17, 2019
91d67bb
Update config map to use the new environment variables.
Sep 17, 2019
f24e966
Remove an unnecessary env var from the api-deployment template.
Sep 17, 2019
8253102
Update the docker-compose file with the new env variables.
Sep 18, 2019
d8c1bf6
Forgot to update the changelog.
Sep 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ stages:
cd deployment/entity-service

helm lint --debug --namespace $(NAMESPACE) $(DEPLOYMENT) . \
-f values.yaml -f minimal-values.yaml \
--set api.app.debug=true \
--set global.postgresql.postgresqlPassword=notaproductionpassword \
--set api.ingress.enabled=false \
Expand All @@ -194,7 +193,6 @@ stages:

echo "Dry run"
helm upgrade --install --dry-run --wait --namespace $(NAMESPACE) $(DEPLOYMENT) . \
-f values.yaml -f minimal-values.yaml \
--set api.app.debug=true \
--set global.postgresql.postgresqlPassword=notaproductionpassword \
--set api.ingress.enabled=false \
Expand All @@ -211,7 +209,6 @@ stages:
echo "Start all the entity service pods"
cd deployment/entity-service
helm upgrade --install --wait --namespace $(NAMESPACE) $(DEPLOYMENT) . \
-f values.yaml -f minimal-values.yaml \
--set api.app.debug=true \
--set global.postgresql.postgresqlPassword=notaproductionpassword \
--set api.ingress.enabled=false \
Expand Down
4 changes: 3 additions & 1 deletion backend/entityservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def initdb_command():

@app.before_first_request
def before_first_request():
db.init_db_pool()
db_min_connections = config.FLASK_DB_MIN_CONNECTIONS
db_max_connections = config.FLASK_DB_MAX_CONNECTIONS
db.init_db_pool(db_min_connections, db_max_connections)


@app.before_request
Expand Down
7 changes: 6 additions & 1 deletion backend/entityservice/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
celery.conf.result_backend_transport_options = Config.CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS
celery.conf.worker_prefetch_multiplier = Config.CELERYD_PREFETCH_MULTIPLIER
celery.conf.worker_max_tasks_per_child = Config.CELERYD_MAX_TASKS_PER_CHILD
if Config.CELERYD_CONCURRENCY > 0:
# If set to 0, let celery choose the default, which is the number of available CPUs on the machine.
celery.conf.worker_concurrency = Config.CELERYD_CONCURRENCY


# Set up our logging
Expand All @@ -31,7 +34,9 @@

@worker_process_init.connect()
def init_worker(**kwargs):
init_db_pool()
db_min_connections = Config.CELERY_DB_MIN_CONNECTIONS
db_max_connections = Config.CELERY_DB_MAX_CONNECTIONS
init_db_pool(db_min_connections, db_max_connections)


@worker_process_shutdown.connect()
Expand Down
6 changes: 2 additions & 4 deletions backend/entityservice/database/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,22 @@ def init_db(delay=0.5):

@param float delay: Number of seconds to wait before executing the SQL.
"""
init_db_pool()
init_db_pool(1, 3)
time.sleep(delay)
with DBConn() as db:
with current_app.open_resource('init-db-schema.sql', mode='r') as f:
logger.warning("Initialising database")
db.cursor().execute(f.read())


def init_db_pool():
def init_db_pool(db_min_connections, db_max_connections):
"""
Initializes the database connection pool required by the application to connect to the database.
"""
db = config.DATABASE
host = config.DATABASE_SERVER
user = config.DATABASE_USER
pw = config.DATABASE_PASSWORD
db_min_connections = config.DATABASE_MIN_CONNECTIONS
db_max_connections = config.DATABASE_MAX_CONNECTIONS

global connection_pool
if connection_pool is None:
Expand Down
15 changes: 10 additions & 5 deletions backend/entityservice/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Config shared between the application backend and the celery workers.
"""
import os
import math
import logging


class Config(object):
"""
Hard coded default configuration which can be overwritten with environment variables
Hard coded default configuration which can be overwritten with environment variables.
"""

# If adding or deleting any, please ensure that the changelog will mention them.

DEBUG = os.getenv("DEBUG", "false") == "true"

CONNEXION_STRICT_VALIDATION = os.getenv("CONNEXION_STRICT_VALIDATION", "true").lower() == "true"
Expand All @@ -33,14 +33,18 @@ class Config(object):
DATABASE = os.getenv('DATABASE', 'postgres')
DATABASE_USER = os.getenv('DATABASE_USER', 'postgres')
DATABASE_PASSWORD = os.getenv('DATABASE_PASSWORD', '')
DATABASE_MIN_CONNECTIONS = os.getenv('DATABASE_MIN_CONNECTIONS', '1')
DATABASE_MAX_CONNECTIONS = os.getenv('DATABASE_MAX_CONNECTIONS', '3')

FLASK_DB_MIN_CONNECTIONS = os.getenv('FLASK_DB_MIN_CONNECTIONS', '1')
FLASK_DB_MAX_CONNECTIONS = os.getenv('FLASK_DB_MAX_CONNECTIONS', '10')

CELERY_BROKER_URL = os.getenv(
'CELERY_BROKER_URL',
('sentinel://:{}@{}:26379/0' if REDIS_USE_SENTINEL else 'redis://:{}@{}:6379/0').format(REDIS_PASSWORD, REDIS_SERVER)
)

CELERY_DB_MIN_CONNECTIONS = os.getenv('CELERY_DB_MIN_CONNECTIONS', '1')
CELERY_DB_MAX_CONNECTIONS = os.getenv('CELERY_DB_MAX_CONNECTIONS', '3')

CELERY_BROKER_TRANSPORT_OPTIONS = {'master_name': "mymaster"} if REDIS_USE_SENTINEL else {}

CELERY_RESULT_BACKEND = CELERY_BROKER_URL
Expand All @@ -61,6 +65,7 @@ class Config(object):

CELERYD_PREFETCH_MULTIPLIER = int(os.getenv('CELERYD_PREFETCH_MULTIPLIER', '1'))
CELERYD_MAX_TASKS_PER_CHILD = int(os.getenv('CELERYD_MAX_TASKS_PER_CHILD', '4'))
CELERYD_CONCURRENCY = int(os.getenv("CELERYD_CONCURRENCY", '0'))
CELERY_ACKS_LATE = os.getenv('CELERY_ACKS_LATE', 'false') == 'true'

# Number of comparisons per chunk (on average).
Expand Down
145 changes: 0 additions & 145 deletions deployment/README.md

This file was deleted.

1 change: 1 addition & 0 deletions deployment/entity-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/*
2 changes: 1 addition & 1 deletion deployment/entity-service/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: entity-service
appVersion: 1.11.2
version: 1.11.2
version: 1.12.0
gusmith marked this conversation as resolved.
Show resolved Hide resolved
description: Privacy preserving record linkage service
sources:
- https://github.com/data61/anonlink-entity-service
Expand Down
77 changes: 0 additions & 77 deletions deployment/entity-service/minimal-values.yaml

This file was deleted.

Loading