Skip to content

Commit

Permalink
Implemented Retry for OpenSearch Container (opensearch-project#304)
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>

Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Feb 27, 2023
1 parent e4fc3e3 commit 88388db
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .ci/opensearch/Dockerfile.opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ ARG opensearch_path=/usr/share/opensearch
ARG opensearch_yml=$opensearch_path/config/opensearch.yml

ARG SECURE_INTEGRATION

HEALTHCHECK --start-period=20s --interval=5s --retries=2 --timeout=1s \
CMD if [ "$SECURE_INTEGRATION" != "true" ]; \
then curl --fail localhost:9200/_cat/health; \
else curl --fail -k https:/localhost:9200/_cat/health -u admin:admin; fi

RUN if [ "$SECURE_INTEGRATION" != "true" ] ; then $opensearch_path/bin/opensearch-plugin remove opensearch-security; fi
12 changes: 12 additions & 0 deletions .ci/opensearch/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3'

services:
opensearch:
restart: always
build:
context: .
dockerfile: Dockerfile.opensearch
Expand All @@ -11,6 +12,17 @@ services:
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
ports:
- '9200:9200'
user: opensearch
autoheal:
restart: always
image: willfarrell/autoheal
environment:
- AUTOHEAL_CONTAINER_LABEL=all
- AUTOHEAL_START_PERIOD=30
- AUTOHEAL_INTERVAL=5
- AUTOHEAL_DEFAULT_STOP_TIMEOUT=30
volumes:
- /var/run/docker.sock:/var/run/docker.sock
2 changes: 2 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
sudo sysctl -w vm.max_map_count=262144
- name: Runs OpenSearch cluster
id: start_opensearch_cluster
run: |
export OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }}
export SECURE_INTEGRATION=${{ matrix.secured }}
Expand All @@ -59,5 +60,6 @@ jobs:
npm run test:integration:helpers-secure
- name: Stop the OpenSearch cluster
if: ${{ steps.start_opensearch_cluster.outcome == 'success'}}
run: |
make cluster.opensearch.stop
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cluster.opensearch.build:

cluster.opensearch.start:
docker-compose --project-directory .ci/opensearch up -d ;
sleep 20;
sleep 60;

cluster.opensearch.stop:
docker-compose --project-directory .ci/opensearch down ;
Expand Down

0 comments on commit 88388db

Please sign in to comment.