refactor(api): Phase B P1 可靠性強化 (2 項)
Some checks failed
E2E Health Check / e2e-health (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled

1. send_cicd_progress 重試機制 (指數退避 1,2,4 秒)
2. K8s Repository 封裝 (IK8sRepository + K8sRepository)

首席架構師審查 P1 改進 - 模組化合規

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-30 01:52:59 +08:00
parent 64e51bb4fd
commit 13bb1496b0
5 changed files with 395 additions and 116 deletions

View File

@@ -371,3 +371,67 @@ class IEmbeddingCacheRepository(Protocol):
async def remove(self, playbook_id: str) -> bool:
"""移除 Playbook 向量"""
...
@runtime_checkable
class IK8sRepository(Protocol):
"""
K8s Repository Protocol
職責: K8s API 操作 (Pods/Deployments/Events)
實作: K8sRepository (kubernetes_asyncio)
版本: v1.0
建立: 2026-03-30 (台北時區)
建立者: Claude Code (首席架構師 P1 改進)
設計原則:
- Service 層不直接呼叫 kubernetes_asyncio
- 透過 Repository 進行 K8s 操作
- 符合 leWOOOgo 積木化原則
"""
async def list_pods(
self,
namespace: str = "awoooi",
) -> list[dict]:
"""
列出 Namespace 下的 Pods
Returns:
list[{name, phase, ready, restarts, age}]
"""
...
async def list_deployments(
self,
namespace: str = "awoooi",
) -> list[dict]:
"""
列出 Namespace 下的 Deployments
Returns:
list[{name, ready_replicas, replicas, available}]
"""
...
async def get_pod_status_summary(
self,
namespace: str = "awoooi",
) -> dict:
"""
取得 Pod 狀態摘要
Returns:
{total, running, pending, failed, problem_pods: [...]}
"""
...
async def is_available(self) -> bool:
"""
檢查 K8s API 是否可用
Returns:
True 如果 K8s 連線正常
"""
...