Skip to content

Commit

Permalink
fix: check milvus connection at the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
billshitg committed Jul 4, 2024
1 parent 8095de0 commit 673f090
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
11 changes: 9 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

from fastapi.security import HTTPBasic
from pymilvus.exceptions import MilvusException

from app.embeddings.embedding_services import (
AWS_Bedrock_Embedding,
Expand Down Expand Up @@ -141,9 +142,12 @@ def get_llm_service(llm_config):
alias=milvus_config.get("alias", "default"),
)
service_status["embedding_store"] = {"status": "ok", "error": None}
except MilvusException as e:
embedding_store = None
service_status["embedding_store"] = {"status": "milvus error", "error": str(e)}
except Exception as e:
embedding_store = None
service_status["embedding_store"] = {"status": "error", "error": str(e)}
service_status["embedding_store"] = {"status": "embedding error", "error": str(e)}

support_collection_name = milvus_config.get("collection_name", "tg_support_documents")
LogWriter.info(
Expand All @@ -165,9 +169,12 @@ def get_llm_service(llm_config):
alias=milvus_config.get("alias", "default"),
)
service_status["support_ai_embedding_store"] = {"status": "ok", "error": None}
except MilvusException as e:
support_ai_embedding_store = None
service_status["support_ai_embedding_store"] = {"status": "milvus error", "error": str(e)}
except Exception as e:
support_ai_embedding_store = None
service_status["support_ai_embedding_store"] = {"status": "error", "error": str(e)}
service_status["support_ai_embedding_store"] = {"status": "embedding error", "error": str(e)}


if DOC_PROCESSING_CONFIG is None or (
Expand Down
14 changes: 0 additions & 14 deletions app/routers/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ def read_root():

@router.get("/health")
async def health():
try:
# Check if Milvus is up and running and if the required collections exist
connections.connect(host="milvus-standalone", port="19530")
# Check if the required collections exist
inquiry_collection_exists = utility.has_collection("tg_inquiry_documents")
support_collection_exists = utility.has_collection("tg_support_documents")

if inquiry_collection_exists or support_collection_exists:
service_status["milvus"] = {"status": "ok", "error": None}
else:
service_status["milvus"] = {"status": "error", "error": "Milvus is up and running, but no collection exists"}
except Exception as e:
service_status["milvus"] = {"status": "error", "error": str(e)}

status = {
"status": "unhealthy" if any(v["error"] is not None for v in service_status.values()) else "healthy",
"details": service_status
Expand Down

0 comments on commit 673f090

Please sign in to comment.