Secure, Fast, and Extensible Sandbox runtime for AI agents.
fix(server): expire-check Allocated pod path in BatchSandbox get_status
刘祺祥f04d5aecc83f
diff --git a/server/opensandbox_server/services/k8s/batchsandbox_provider.py b/server/opensandbox_server/services/k8s/batchsandbox_provider.pyindex 02007cd51..40f030d11 100644--- a/server/opensandbox_server/services/k8s/batchsandbox_provider.py+++ b/server/opensandbox_server/services/k8s/batchsandbox_provider.py@@ -1004,10 +1004,12 @@ class BatchSandboxProvider(WorkloadProvider):allocated = status.get("allocated", 0)pod_ip = self._parse_pod_ip(workload)- if ready == 1 and pod_ip:+ if pod_ip:expired = self._expired_status(workload)if expired is not None:return expired++ if ready == 1 and pod_ip:state = "Running"reason = "POD_READY_WITH_IP"message = f"Pod is ready with IP ({ready}/{replicas} ready)"diff --git a/server/tests/k8s/test_batchsandbox_provider_task_failure.py b/server/tests/k8s/test_batchsandbox_provider_task_failure.pyindex 809429e62..89269dc70 100644--- a/server/tests/k8s/test_batchsandbox_provider_task_failure.py+++ b/server/tests/k8s/test_batchsandbox_provider_task_failure.py@@ -91,6 +91,22 @@ def test_get_status_reports_terminated_when_expire_time_has_passed():assert result["last_transition_at"] == "2020-01-01T00:00:00Z"+def test_get_status_reports_terminated_when_allocated_pod_is_past_expire_time():+ # Pod has IP but is not Ready yet (Allocated). Create wait treats Allocated as success,+ # so expiry must be checked before the ready/IP split.+ provider = BatchSandboxProvider(MagicMock())+ workload = {+ "spec": {"expireTime": "2020-01-01T00:00:00Z"},+ "status": {"replicas": 1, "ready": 0, "allocated": 1},+ "metadata": _ENDPOINTS,+ }++ result = provider.get_status(workload)++ assert result["state"] == "Terminated"+ assert result["reason"] == "SANDBOX_EXPIRED"++def test_get_status_reports_terminated_when_ready_pod_is_past_expire_time():provider = BatchSandboxProvider(MagicMock())workload = {