Skip to content

Improve gRPC service logging for unexpected exceptions and return INTERNAL error

Currently any exceptions that weren't explicitly caught will end up printing the default python exception stacktrace in the logs, which does not include any request details, making it hard to troubleshoot since the request data is not shown.

This MR changes that to include the request in the logs to facilitate troubleshooting. In addition to that, it also sets the error code INTERNAL in the response; gRPC clients may choose to retry the request.

An example of how one such exception would show up in the logs:

2020-07-02 14:36:55,841:[       buildgrid.server.bots.service][ERROR][gRPC_Executor_0]: Unexpected error in CreateBotSession; bot_id=[07ef16641947-1]: request=[bot_session {
  bot_id: "07ef16641947-1"
  worker {
    devices {
      handle: "07ef16641947-1"
    }
  }
}
]
Traceback (most recent call last):
  File "/Users/mhadjimichael/gitlab/BuildGrid/buildgrid/env/lib/python3.7/site-packages/BuildGrid-0.0.2-py3.7.egg/buildgrid/server/bots/service.py", line 95, in CreateBotSession
    request.bot_session)
  File "/Users/mhadjimichael/gitlab/BuildGrid/buildgrid/env/lib/python3.7/site-packages/BuildGrid-0.0.2-py3.7.egg/buildgrid/server/bots/instance.py", line 133, in create_bot_session
    raise DivisonByZeroError('asdf')
NameError: name 'DivisonByZeroError' is not defined
Edited by Marios Hadjimichael

Merge request reports