include docker error reason in sandbox start failure response
This commit is contained in:
parent
d4434a0afe
commit
32793de992
3 changed files with 6 additions and 4 deletions
|
|
@ -94,11 +94,11 @@ class DockerSandboxRuntime(SandboxRuntime):
|
||||||
endpoint = self._endpoint_from_container(container)
|
endpoint = self._endpoint_from_container(container)
|
||||||
except (DockerException, OSError, ValueError) as exc:
|
except (DockerException, OSError, ValueError) as exc:
|
||||||
self._remove_created_container(container, str(chat_id), exc)
|
self._remove_created_container(container, str(chat_id), exc)
|
||||||
raise SandboxStartError(str(chat_id)) from exc
|
raise SandboxStartError(str(chat_id), str(exc)) from exc
|
||||||
except SandboxStartError:
|
except SandboxStartError:
|
||||||
raise
|
raise
|
||||||
except (DockerException, OSError, ValueError) as exc:
|
except (DockerException, OSError, ValueError) as exc:
|
||||||
raise SandboxStartError(str(chat_id)) from exc
|
raise SandboxStartError(str(chat_id), str(exc)) from exc
|
||||||
|
|
||||||
result = 'created'
|
result = 'created'
|
||||||
span.set_attribute('container.id', container_id)
|
span.set_attribute('container.id', container_id)
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,10 @@ def create_sandbox(
|
||||||
detail=str(exc),
|
detail=str(exc),
|
||||||
) from exc
|
) from exc
|
||||||
except SandboxStartError as exc:
|
except SandboxStartError as exc:
|
||||||
|
detail = f'{exc}: {exc.reason}' if exc.reason else str(exc)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||||
detail=str(exc),
|
detail=detail,
|
||||||
) from exc
|
) from exc
|
||||||
except SandboxError as exc:
|
except SandboxError as exc:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ class SandboxError(DomainError):
|
||||||
|
|
||||||
|
|
||||||
class SandboxStartError(SandboxError):
|
class SandboxStartError(SandboxError):
|
||||||
def __init__(self, chat_id: str) -> None:
|
def __init__(self, chat_id: str, reason: str = '') -> None:
|
||||||
super().__init__('sandbox_start_failed')
|
super().__init__('sandbox_start_failed')
|
||||||
self.chat_id = chat_id
|
self.chat_id = chat_id
|
||||||
|
self.reason = reason
|
||||||
|
|
||||||
|
|
||||||
class SandboxAlreadyRunningError(SandboxError):
|
class SandboxAlreadyRunningError(SandboxError):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue