fix: changed opensearch startup to turn opensearch into main process#1326
Merged
lucaseduoli merged 4 commits intomainfrom Apr 2, 2026
Merged
fix: changed opensearch startup to turn opensearch into main process#1326lucaseduoli merged 4 commits intomainfrom
lucaseduoli merged 4 commits intomainfrom
Conversation
Issue - #1170 Summary - Improved OpenSearch graceful shutdown reliability by flushing pending writes, adding a force-kill fallback in the entrypoint wrapper, and preventing double-close of the client connection. - Hardened the Docker Compose healthcheck to verify authenticated cluster health status rather than bare connectivity. OpenSearch Shutdown Improvements - Replaced `cluster.health()` call with `indices.flush(index="_all", wait_if_ongoing=True)` in `graceful_opensearch_shutdown` to ensure pending write operations are persisted before the client closes. - Set `clients.opensearch = None` after graceful shutdown in `src/main.py` to prevent a redundant double-close during `clients.cleanup()`. - Added a 90-second wait loop with `kill -0` polling in `opensearch-entrypoint-wrapper.sh` before issuing a force `SIGKILL`, ensuring the process has time to stop cleanly before being forcibly terminated. - Removed stale "Made with Bob" comment from `opensearch-entrypoint-wrapper.sh`. Docker Compose Healthcheck - Updated the OpenSearch healthcheck command to authenticate with `admin:$OPENSEARCH_PASSWORD` and query `/_cluster/health`, asserting the cluster status is `green` or `yellow` rather than only checking for a successful TCP connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the OpenSearch container's startup and shutdown processes, enhances reliability, and simplifies configuration. The main changes introduce a custom entrypoint script to handle graceful shutdown and background security setup, update the Dockerfile and docker-compose setup to use this script, and add a healthcheck for better container monitoring.
Entrypoint and Graceful Shutdown Improvements:
opensearch-entrypoint-wrapper.shthat starts OpenSearch in the background, runs the security setup after a delay, and handles graceful shutdown on termination signals.Dockerfileto copy and use the new entrypoint wrapper, ensuring it has the correct permissions and ownership. The container now uses this script as its entrypoint instead of the default. [1] [2]Docker Compose Configuration Enhancements:
docker-compose.ymlto remove the custom command logic for startup and security setup (now handled by the entrypoint wrapper), switched to using a named volume for persistent data (opensearch-data), and added astop_grace_periodfor graceful shutdown. [1] [2]docker-compose.ymlto monitor cluster health, improving reliability and observability.Related Pull Requests