fix(ollama): treat legacy primary as ollama
Some checks failed
CD Pipeline / tests (push) Failing after 1m48s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Code Review / ai-code-review (push) Successful in 28s

This commit is contained in:
Your Name
2026-05-05 13:25:27 +08:00
parent 33d4326cce
commit 869646459c
2 changed files with 18 additions and 8 deletions

View File

@@ -150,8 +150,8 @@ class OllamaAutoRecoveryService:
current_primary=self._current_primary,
)
# 若 primary 不是 ollama立刻評估一次不等 30s interval
if self._current_primary != "ollama":
# 若 primary 不是 Ollama立刻評估一次不等 30s interval
if not self._is_ollama_primary(self._current_primary):
try:
await self._check_and_recover()
except Exception:
@@ -217,9 +217,9 @@ class OllamaAutoRecoveryService:
# Redis 持久化(跨重啟恢復)
await self._persist_primary(provider)
# 2026-05-04 ogt: B5/B6 修復 — 判斷改用 startswith("ollama_")
# 2026-05-04 ogt: B5/B6 修復 — 判斷改用 _is_ollama_primary()
# 原設計provider != "ollama",但 callback 傳 "ollama_gcp_a" → 永遠觸發 tracking
if not provider.startswith("ollama_"):
if not self._is_ollama_primary(provider):
# 切換到非 Ollamagemini/nemotron/claude→ 重置 counter開始監控恢復
self._consecutive_healthy = 0
logger.info(
@@ -302,6 +302,11 @@ class OllamaAutoRecoveryService:
def is_running(self) -> bool:
return self._task is not None and not self._task.done()
@staticmethod
def _is_ollama_primary(provider: str) -> bool:
"""Return true for both legacy "ollama" and ADR-110 provider names."""
return provider == "ollama" or provider.startswith("ollama_")
# -------------------------------------------------------------------------
# 背景監控迴圈
# -------------------------------------------------------------------------
@@ -359,7 +364,7 @@ class OllamaAutoRecoveryService:
if (
self._consecutive_healthy >= self._stable_count_required
and not self._current_primary.startswith("ollama_")
and not self._is_ollama_primary(self._current_primary)
):
await self._switch_back_to_ollama()
else: