Skip to content

Commit 15da1e0

Browse files
authored
feat(opensearch): Add OpenSearch in docker compose (#8611)
1 parent e9ff008 commit 15da1e0

File tree

6 files changed

+64
-23
lines changed

6 files changed

+64
-23
lines changed

.github/workflows/pr-external-dependency-unit-tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ env:
4545
# TODO: debug why this is failing and enable
4646
CODE_INTERPRETER_BASE_URL: http://localhost:8000
4747

48-
# OpenSearch
49-
OPENSEARCH_ADMIN_PASSWORD: "StrongPassword123!"
50-
5148
jobs:
5249
discover-test-dirs:
5350
# NOTE: Github-hosted runners have about 20s faster queue times and are preferred here.
@@ -118,9 +115,10 @@ jobs:
118115
- name: Create .env file for Docker Compose
119116
run: |
120117
cat <<EOF > deployment/docker_compose/.env
121-
COMPOSE_PROFILES=s3-filestore
118+
COMPOSE_PROFILES=s3-filestore,opensearch-enabled
122119
CODE_INTERPRETER_BETA_ENABLED=true
123120
DISABLE_TELEMETRY=true
121+
OPENSEARCH_FOR_ONYX_ENABLED=true
124122
EOF
125123
126124
- name: Set up Standard Dependencies
@@ -129,7 +127,6 @@ jobs:
129127
docker compose \
130128
-f docker-compose.yml \
131129
-f docker-compose.dev.yml \
132-
-f docker-compose.opensearch.yml \
133130
up -d \
134131
minio \
135132
relational_db \

backend/onyx/configs/app_configs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@
251251
os.environ.get("DEFAULT_OPENSEARCH_QUERY_TIMEOUT_S") or 50
252252
)
253253
OPENSEARCH_ADMIN_USERNAME = os.environ.get("OPENSEARCH_ADMIN_USERNAME", "admin")
254-
OPENSEARCH_ADMIN_PASSWORD = os.environ.get("OPENSEARCH_ADMIN_PASSWORD", "")
254+
OPENSEARCH_ADMIN_PASSWORD = os.environ.get(
255+
"OPENSEARCH_ADMIN_PASSWORD", "StrongPassword123!"
256+
)
255257
USING_AWS_MANAGED_OPENSEARCH = (
256258
os.environ.get("USING_AWS_MANAGED_OPENSEARCH", "").lower() == "true"
257259
)
@@ -282,6 +284,9 @@
282284
ENABLE_OPENSEARCH_INDEXING_FOR_ONYX = (
283285
os.environ.get("ENABLE_OPENSEARCH_INDEXING_FOR_ONYX", "").lower() == "true"
284286
)
287+
# NOTE: This effectively does nothing anymore, admins can now toggle whether
288+
# retrieval is through OpenSearch. This value is only used as a final fallback
289+
# in case that doesn't work for whatever reason.
285290
# Given that the "base" config above is true, this enables whether we want to
286291
# retrieve from OpenSearch or Vespa. We want to be able to quickly toggle this
287292
# in the event we see issues with OpenSearch retrieval in our dev environments.

deployment/docker_compose/docker-compose.dev.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ services:
3535
retries: 3
3636
start_period: 30s
3737

38+
opensearch:
39+
ports:
40+
- "9200:9200"
41+
3842
inference_model_server:
3943
ports:
4044
- "9000:9000"

deployment/docker_compose/docker-compose.opensearch.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

deployment/docker_compose/docker-compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ services:
7676
- FILE_STORE_BACKEND=${FILE_STORE_BACKEND:-s3}
7777
- POSTGRES_HOST=${POSTGRES_HOST:-relational_db}
7878
- VESPA_HOST=${VESPA_HOST:-index}
79+
- OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}
80+
- OPENSEARCH_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
81+
- ENABLE_OPENSEARCH_INDEXING_FOR_ONYX=${OPENSEARCH_FOR_ONYX_ENABLED:-false}
7982
- REDIS_HOST=${REDIS_HOST:-cache}
8083
- MODEL_SERVER_HOST=${MODEL_SERVER_HOST:-inference_model_server}
8184
- S3_ENDPOINT_URL=${S3_ENDPOINT_URL:-http://minio:9000}
@@ -147,6 +150,9 @@ services:
147150
- FILE_STORE_BACKEND=${FILE_STORE_BACKEND:-s3}
148151
- POSTGRES_HOST=${POSTGRES_HOST:-relational_db}
149152
- VESPA_HOST=${VESPA_HOST:-index}
153+
- OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}
154+
- OPENSEARCH_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
155+
- ENABLE_OPENSEARCH_INDEXING_FOR_ONYX=${OPENSEARCH_FOR_ONYX_ENABLED:-false}
150156
- REDIS_HOST=${REDIS_HOST:-cache}
151157
- MODEL_SERVER_HOST=${MODEL_SERVER_HOST:-inference_model_server}
152158
- INDEXING_MODEL_SERVER_HOST=${INDEXING_MODEL_SERVER_HOST:-indexing_model_server}
@@ -395,6 +401,45 @@ services:
395401
max-size: "50m"
396402
max-file: "6"
397403

404+
opensearch:
405+
image: opensearchproject/opensearch:3.4.0
406+
restart: unless-stopped
407+
# Controls whether this service runs. In order to enable it, add
408+
# opensearch-enabled to COMPOSE_PROFILES in the environment for this
409+
# docker-compose.
410+
profiles: ["opensearch-enabled"]
411+
environment:
412+
# We need discovery.type=single-node so that OpenSearch doesn't try
413+
# forming a cluster and waiting for other nodes to become live.
414+
- discovery.type=single-node
415+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD:-StrongPassword123!}
416+
# This and the JVM config below come from the example in https://docs.opensearch.org/latest/install-and-configure/install-opensearch/docker/
417+
# We do this to avoid unstable performance from page swaps.
418+
- bootstrap.memory_lock=true # Disable JVM heap memory swapping.
419+
# Java heap should be ~50% of memory limit. For now we assume a limit of
420+
# 2g although in practice the container can request more than this.
421+
# See https://opster.com/guides/opensearch/opensearch-basics/opensearch-heap-size-usage-and-jvm-garbage-collection/
422+
# Xms is the starting size, Xmx is the maximum size. These should be the
423+
# same.
424+
- "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
425+
volumes:
426+
- opensearch-data:/usr/share/opensearch/data
427+
# These come from the example in https://docs.opensearch.org/latest/install-and-configure/install-opensearch/docker/
428+
ulimits:
429+
# Similarly to bootstrap.memory_lock, we don't want to impose limits on
430+
# how much memory a process can lock from being swapped.
431+
memlock:
432+
soft: -1 # Set memlock to unlimited (no soft or hard limit).
433+
hard: -1
434+
nofile:
435+
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536.
436+
hard: 65536
437+
logging:
438+
driver: json-file
439+
options:
440+
max-size: "50m"
441+
max-file: "6"
442+
398443
nginx:
399444
image: nginx:1.25.5-alpine
400445
restart: unless-stopped
@@ -535,3 +580,5 @@ volumes:
535580
indexing_model_server_logs:
536581
# Shared volume for persistent document storage (Craft file-system mode)
537582
file-system:
583+
# Persistent data for OpenSearch.
584+
opensearch-data:

deployment/docker_compose/env.template

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ POSTGRES_PASSWORD=password
6464

6565
## File Store Backend: "s3" (default, uses MinIO) or "postgres" (no extra services needed)
6666
## COMPOSE_PROFILES activates the MinIO service. To use PostgreSQL file storage instead,
67-
## comment out COMPOSE_PROFILES and set FILE_STORE_BACKEND=postgres.
67+
## remove s3-filestore from COMPOSE_PROFILES and set FILE_STORE_BACKEND=postgres.
6868
COMPOSE_PROFILES=s3-filestore
6969
FILE_STORE_BACKEND=s3
70+
## Settings for enabling OpenSearch. Uncomment these and comment out
71+
## COMPOSE_PROFILES above.
72+
# COMPOSE_PROFILES=s3-filestore,opensearch-enabled
73+
# OPENSEARCH_FOR_ONYX_ENABLED=true
7074

7175
## MinIO/S3 Configuration (only needed when FILE_STORE_BACKEND=s3)
7276
S3_ENDPOINT_URL=http://minio:9000

0 commit comments

Comments
 (0)