Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

Handle IBM auth for OpenSearch and health probe

Edwin Jose7e40770d1f22
diff --git a/src/config/settings.py b/src/config/settings.py
index b3d556288..9787e0582 100644
--- a/src/config/settings.py
+++ b/src/config/settings.py
@@ -331,7 +331,8 @@ class AppClients:
self.docling_http_client = None
async def initialize(self):
- # Initialize OpenSearch client
+ os_auth = None if IBM_AUTH_ENABLED else (OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD)
+
self.opensearch = AsyncOpenSearch(
hosts=[{"host": OPENSEARCH_HOST, "port": OPENSEARCH_PORT}],
connection_class=AIOHttpConnection,
@@ -339,7 +340,7 @@ class AppClients:
use_ssl=True,
verify_certs=False,
ssl_assert_fingerprint=None,
- http_auth=(OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD),
+ http_auth=os_auth,
http_compress=True,
)
@@ -393,7 +394,7 @@ class AppClients:
# Initialize Langflow client with generated/provided API key
if LANGFLOW_KEY and self.langflow_client is None:
try:
- if not OPENSEARCH_PASSWORD:
+ if not OPENSEARCH_PASSWORD and not IBM_AUTH_ENABLED:
raise ValueError("OPENSEARCH_PASSWORD is not set")
else:
await self.ensure_langflow_client()
diff --git a/src/main.py b/src/main.py
index 5adeea06c..b9647392d 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1033,8 +1033,15 @@ async def health_check(request: Request):
async def opensearch_health_ready(request):
"""Readiness probe: verifies OpenSearch dependency is reachable."""
+ from config.settings import IBM_AUTH_ENABLED
+
+ if IBM_AUTH_ENABLED:
+ return JSONResponse(
+ {"status": "ready", "note": "IBM auth mode - health checked per-request"},
+ status_code=200,
+ )
+
try:
- # Fast check that the cluster is reachable/auth works
await asyncio.wait_for(clients.opensearch.info(), timeout=5.0)
return JSONResponse(
{"status": "ready", "dependencies": {"opensearch": "up"}},