Skip to content

Commit af4c54f

Browse files
ZaynJarvisclaude
andauthored
fix(server): add embedding connectivity probe to /ready endpoint (volcengine#1910)
The /ready endpoint checks AGFS, VectorDB, APIKeyManager, and Ollama but not the embedding provider. When the provider is down (500 or unreachable), ov find silently times out with a misleading "Network error" and neither ov health nor ov ready surfaces the real cause. Add an embedding probe (single-token embed with 10s timeout) so that ov ready reports a broken embedding backend before any search is attempted. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bc8fe8b commit af4c54f

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

openviking/server/routers/system.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: AGPL-3.0
33
"""System endpoints for OpenViking HTTP Server."""
44

5+
import asyncio
56
from typing import Optional
67

78
from fastapi import APIRouter, Depends, Request
@@ -21,6 +22,19 @@
2122
router = APIRouter()
2223

2324

25+
async def _embedding_probe(embedder) -> str:
26+
"""Quick embedding probe: embed a single token and check for errors."""
27+
from openviking.models.embedder.base import embed_compat
28+
29+
try:
30+
await embed_compat(embedder, "ok", is_query=True)
31+
return "ok"
32+
except Exception as e:
33+
provider = getattr(embedder, "provider", "unknown")
34+
model = getattr(embedder, "model_name", "unknown")
35+
return f"error: provider={provider} model={model}: {e}"
36+
37+
2438
@router.get("/health", tags=["system"])
2539
async def health_check(request: Request):
2640
"""Health check endpoint (no authentication required)."""
@@ -120,7 +134,25 @@ async def readiness_check(request: Request):
120134
except Exception as e:
121135
checks["api_key_manager"] = f"error: {e}"
122136

123-
# 4. Ollama: connectivity check if configured
137+
# 4. Embedding: quick probe to verify the provider is reachable
138+
try:
139+
from openviking_cli.utils.config.open_viking_config import OpenVikingConfigSingleton
140+
141+
ov_config = OpenVikingConfigSingleton.get_instance()
142+
embedder = ov_config.embedding.get_embedder()
143+
if embedder is not None:
144+
probe_result = await asyncio.wait_for(
145+
_embedding_probe(embedder), timeout=10.0
146+
)
147+
checks["embedding"] = probe_result
148+
else:
149+
checks["embedding"] = "not_configured"
150+
except asyncio.TimeoutError:
151+
checks["embedding"] = "error: probe timed out (provider unreachable)"
152+
except Exception as e:
153+
checks["embedding"] = f"error: {e}"
154+
155+
# 5. Ollama: connectivity check if configured
124156
try:
125157
from openviking_cli.utils.config.open_viking_config import OpenVikingConfigSingleton
126158
from openviking_cli.utils.ollama import check_ollama_running, detect_ollama_in_config

0 commit comments

Comments
 (0)