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

Healthchecks provided for all context storages #279

Merged
merged 9 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ To execute all tests, including integration with DBs and APIs tests, run
```bash
make test_all
```
for successful execution of this command `Docker` and `docker-compose` are required.
for successful execution of this command `Docker` and `docker compose` are required.

To make sure that the code satisfies only the style requirements, run
```bash
Expand All @@ -127,22 +127,22 @@ DFF uses docker images for two purposes:
The first group can be launched via

```bash
docker-compose --profile context_storage up
docker compose --profile context_storage up
```

This will download and run all the databases (`mysql`, `postgres`, `redis`, `mongo`, `ydb`).

The second group can be launched via

```bash
docker-compose --profile stats up
docker compose --profile stats up
```

This will download and launch Superset Dashboard, Clickhouse, OpenTelemetry Collector.

To launch both groups run
```bash
docker-compose --profile context_storage --profile stats up
docker compose --profile context_storage --profile stats up
```
or
```bash
Expand Down
52 changes: 47 additions & 5 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.9"
services:

mysql:
env_file: [.env_file]
image: mysql:latest
Expand All @@ -10,6 +11,13 @@ services:
- 3307:3306
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: mysql -u $${MYSQL_USERNAME} -p$${MYSQL_PASSWORD} -e "select 1;"
interval: 5s
timeout: 10s
retries: 5
start_period: 30s
Comment on lines +16 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain how these numbers were chosen?
If we used the default ones we wouldn't have to specify anything and have


    healthcheck:
      test: mysql -u $${MYSQL_USERNAME} -p$${MYSQL_PASSWORD} -e "select 1;"

  psql:

instead.

Copy link
Collaborator Author

@pseusys pseusys Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These numbers were chosen after local testing; some DB images already have healthchecks included, other do not.
I wanted all of them to be in equal conditions.


psql:
env_file: [.env_file]
image: postgres:latest
Expand All @@ -20,6 +28,13 @@ services:
- 5432:5432
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: psql pg_isready -U $${POSTGRES_USERNAME} -d $${POSTGRES_DB}
interval: 5s
timeout: 10s
retries: 5
start_period: 30s

redis:
env_file: [.env_file]
image: redis:latest
Expand All @@ -31,6 +46,13 @@ services:
- 6379:6379
volumes:
- redis-data:/data
healthcheck:
test: redis-cli --raw incr ping
interval: 5s
timeout: 10s
retries: 5
start_period: 30s

mongo:
env_file: [.env_file]
image: mongo:latest
Expand All @@ -41,6 +63,13 @@ services:
- 27017:27017
volumes:
- mongo-data:/data/db
healthcheck:
test: mongosh --norc --quiet --eval 'db.runCommand("ping").ok' localhost:27017/test
interval: 5s
timeout: 10s
retries: 5
start_period: 30s

ydb:
env_file: [.env_file]
image: cr.yandex/yc/yandex-docker-local-ydb:latest
Expand All @@ -55,6 +84,13 @@ services:
volumes:
- ydb-data:/ydb_data
- ydb-certs:/ydb_certs
healthcheck:
test: sh ./health_check
interval: 5s
timeout: 10s
retries: 5
start_period: 30s

dashboard:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need health checks for dashboard and otelcol?
AFAIK dashboard performs its own health checks that are unrelated to docker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but I am not very familiar with what properties should we test in that cases. If you have a suggestion - I'll research how to add some.

env_file: [.env_file]
build:
Expand All @@ -70,6 +106,7 @@ services:
- stats
ports:
- "8088:8088"

dashboard-metadata:
env_file: [.env_file]
image: postgres:latest
Expand All @@ -83,11 +120,13 @@ services:
command: -p 5433
healthcheck:
test: pg_isready -p 5433 --username=$${POSTGRES_USERNAME}
interval: 4s
timeout: 3s
retries: 3
interval: 5s
timeout: 10s
retries: 5
start_period: 30s
volumes:
- dashboard-data:/var/lib/postgresql/data

clickhouse:
env_file: [.env_file]
image: clickhouse/clickhouse-server:latest
Expand All @@ -101,10 +140,12 @@ services:
volumes:
- ch-data:/var/lib/clickhouse/
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping || exit 1
test: wget --no-verbose --tries=1 --spider http://localhost:8123/ping
interval: 5s
timeout: 4s
timeout: 10s
retries: 5
start_period: 30s

otelcol:
image: otel/opentelemetry-collector-contrib:latest
profiles:
Expand All @@ -121,6 +162,7 @@ services:
ports:
- "4317:4317" # OTLP over gRPC receiver
- "4318:4318" # OTLP over HTTP receiver

volumes:
ch-data:
dashboard-data:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/user_guides/context_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ and the connection parameters, for example, *mongodb://admin:pass@localhost:2701
The GitHub-based distribution of DFF includes Docker images for each of the supported database types.
Therefore, the easiest way to deploy your service together with a database is to clone the GitHub
distribution and to take advantage of the packaged
`docker-compose file <https://github.com/deeppavlov/dialog_flow_framework/blob/master/docker-compose.yml>`_.
`docker compose file <https://github.com/deeppavlov/dialog_flow_framework/blob/master/compose.yml>`_.

.. code-block:: shell
:linenos:

git clone https://github.com/deeppavlov/dialog_flow_framework.git
cd dialog_flow_framework
# assuming we need to deploy mongodb
docker-compose up mongo
docker compose up mongo

The images can be configured using the docker-compose file or the
The images can be configured using the docker compose file or the
`environment file <https://github.com/deeppavlov/dialog_flow_framework/blob/master/.env_file>`_,
also available in the distribution. Consult these files for more options.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/user_guides/superset_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Collection procedure
.. code-block:: shell
:linenos:

# clone the original repository to access the docker-compose file
# clone the original repository to access the docker compose file
git clone https://github.com/deeppavlov/dialog_flow_framework.git
# install with the stats extra
cd dialog_flow_framework
Expand All @@ -32,11 +32,11 @@ Collection procedure
.. code-block:: shell
:linenos:

# clone the original repository to access the docker-compose file
# clone the original repository to access the docker compose file
git clone https://github.com/deeppavlov/dialog_flow_framework.git
# launch the required services
cd dialog_flow_framework
docker-compose --profile stats up
docker compose --profile stats up

**Collecting data**

Expand Down
9 changes: 2 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,14 @@ lint: venv
.PHONY: lint

docker_up:
docker-compose --profile context_storage --profile stats up -d --build
docker compose --profile context_storage --profile stats up -d --build --wait
.PHONY: docker_up

wait_db: docker_up
while ! docker-compose exec psql pg_isready; do sleep 1; done > /dev/null
while ! docker-compose exec mysql bash -c 'mysql -u $$MYSQL_USERNAME -p$$MYSQL_PASSWORD -e "select 1;"'; do sleep 1; done &> /dev/null
.PHONY: wait_db

test: venv
source <(cat .env_file | sed 's/=/=/' | sed 's/^/export /') && pytest -m "not no_coverage" --cov-fail-under=$(TEST_COVERAGE_THRESHOLD) --cov-report html --cov-report term --cov=dff --allow-skip=$(TEST_ALLOW_SKIP) tests/
.PHONY: test

test_all: venv wait_db test lint
test_all: venv docker_up test lint
.PHONY: test_all

build_drawio:
Expand Down