daemon.excepts module

exception daemon.excepts.DockerNotFoundException[source]

Bases: Exception

Exception if docker client cannot communicate with dockerd

exception daemon.excepts.DockerImageException[source]

Bases: Exception

Exception while handling a docker image in the workspace

exception daemon.excepts.DockerNetworkException[source]

Bases: Exception

Exception while handling docker networks in the workspace

exception daemon.excepts.DockerContainerException[source]

Bases: Exception

Exception while handling a docker container in the workspace

exception daemon.excepts.Runtime400Exception[source]

Bases: Exception

Exception for all errors in Daemon

  • Should only be used in api/endpoints/*.py.

  • Should always be chained.

  • Handled by daemon_runtime_exception_handler

exception daemon.excepts.PartialDaemon400Exception(message=None, \args*)[source]

Bases: Exception

Exception for all errors in Partial Daemon

This can be raised from 2 places: 1. Inside partial daemon:

  • Should always be chained and raised in a[i/partial/endpoints/*.py.

  • This way it has a __cause__ and stacktrace can be retrieved in partial_daemon_exception_handler

  1. Inside main store: - Should be raised whenever main-daemon receives a 400 from partial-daemon. - Don’t chain it. Raise it like - PartialDaemon400Exception(‘original traceback’) - Gets handled via daemon_runtime_exception_handler when chained with Runtime400Exception

exception daemon.excepts.PartialDaemonConnectionException(message=None, \args*)[source]

Bases: daemon.excepts.PartialDaemon400Exception

Exception if JinaD cannot connect to Partial Daemon

daemon.excepts.json_response(status_code, detail, body)[source]

json response from status, detail & body

  • Parameters

    • status_code (HTTPStatus) – http status code

    • detail (str) – exception name in detail

    • body (str) – error stacktrace

    Return type

    JSONResponse

    Returns

    JSONResponse object

async daemon.excepts.partial_daemon_exception_handler(request, ex)[source]

Exception handler for all PartialDaemon400Exceptions

Since PartialDaemon400Exception is always chained, we access the __cause__ and send that as body.

This handler makes sure, in case of exceptions (Pod/Deployment/Flow start/update/delete failures), the response from Partial Daemon whould always look like - ```{

“detail”: “PartialDaemon400Exception”, “body”: [

“stack trace line1” “stack trace line2:

]

}```

  • Parameters

    Returns

    json response representing the error

async daemon.excepts.daemon_runtime_exception_handler(request, ex)[source]

Exception handler for all Runtime400Exceptions

Runtime400Exception is always chained.

  • When __cause__ is PartialDaemon400Exception, we know, it is due to an error inside the Partial Daemon container and ex.message carries the actual stack trace.

  • All other errors are inside the main Daemon itself, so we get the stack trace using traceback.

  • Parameters

    • request (Request) – starlette request

    • ex (Runtime400Exception) – actual Runtime400Exception

    Returns

    json response representing the error

async daemon.excepts.validation_exception_handler(request, ex)[source]

Exception handler for all RequestValidationError raised by pydantic

  • Parameters

    • request (Request) – starlette request

    • ex (RequestValidationError) – actual Validation exception

    Returns

    json response representing the error