{"record":{"id":"46673e109362d597","repo":"agentscope-ai/agentscope","slug":"pod-self-pod-name-r-entered-phase-state","errorCode":null,"errorMessage":"Pod {self._pod_name!r} entered {phase} state","messagePattern":"Pod (.+?) entered (.+?) state","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"src/agentscope/workspace/_k8s/_k8s_workspace.py","lineNumber":533,"sourceCode":"                \"CrashLoopBackOff\",\n            },\n        )\n        _UNSCHEDULABLE_TYPES = frozenset(\n            {\"PodScheduled\"},\n        )\n\n        deadline = asyncio.get_event_loop().time() + timeout\n        delay = 0.5\n        while asyncio.get_event_loop().time() < deadline:\n            pod = await self._v1.read_namespaced_pod(\n                self._pod_name,\n                self._namespace,\n            )\n            phase = pod.status.phase if pod.status else None\n            if phase == \"Running\":\n                return\n            if phase in (\"Failed\", \"Unknown\"):\n                raise RuntimeError(\n                    f\"Pod {self._pod_name!r} entered {phase} state\",\n                )\n\n            if phase == \"Pending\" and pod.status:\n                for cs in pod.status.container_statuses or []:\n                    if cs.state and cs.state.waiting:\n                        reason = cs.state.waiting.reason or \"\"\n                        if reason in _TERMINAL_WAITING_REASONS:\n                            msg = cs.state.waiting.message or reason\n                            raise RuntimeError(\n                                f\"Pod {self._pod_name!r} container \"\n                                f\"is stuck: {msg}\",\n                            )\n                for cond in pod.status.conditions or []:\n                    if (\n                        cond.type in _UNSCHEDULABLE_TYPES\n                        and cond.status == \"False\"\n                        and cond.reason == \"Unschedulable\"","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_k8s/_k8s_workspace.py#L515-L551","documentation":"Raised while waiting for the workspace Pod to become Running: the Pod's phase transitioned to Failed or Unknown, meaning the container crashed or the kubelet lost track of it. The library surfaces this instead of waiting until the timeout so the failure reason can be inspected quickly.","triggerScenarios":"Workspace Pod container exiting immediately (bad image entrypoint, OOMKilled surfaced as Failed); node loss making the phase Unknown; image pull backoff escalating to failure on some cluster configurations.","commonSituations":"Wrong or missing image tag/ImagePullSecret; entrypoint error in a custom workspace image; memory limits too low causing repeated OOM kills; node notReady events.","solutions":["kubectl describe pod <pod> and read the container statuses / events for the real cause","If OOMKilled, raise the Pod's memory limits in the workspace Pod spec","Verify the image reference and imagePullSecrets are correct and reachable","If phase Unknown, check node health (kubectl get nodes) and reschedule"],"exampleFix":"# before\nbackend = await ws._provision_backend()  # RuntimeError: Pod entered Failed state\n\n# after\n# inspect first: kubectl describe pod <pod-name>; fix limits/image, then\nws = K8sWorkspace(..., resources={\"memory\": \"1Gi\"})\nbackend = await ws._provision_backend()","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    await ws.start()\nexcept RuntimeError as e:\n    if \"entered\" in str(e) and \"state\" in str(e):\n        # run kubectl describe pod; classify OOM vs crash\n        raise","preventionTips":["Set adequate memory/CPU limits on workspace Pods","Test custom workspace images locally first","Verify image references and pull secrets before deploy"],"tags":["kubernetes","pod-crash","oom","image-pull"],"backgroundTag":"kubernetes-pod-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}