Reconnecting a bot to the server fails with KeyError
Context
If you terminate a bot and subsequently connect a new bot with the same ID to the server, the server throws a KeyError
.
Steps to reproduce
First, start up a server and a worker:
$ bgd server start &
$ bgd bot dummy
Then, Control-C the bot and start it again:
$ bgd bot dummy
Expected result
The bot reconnects to the server and proceeds as normal.
Actual result
The server throws the following exception:
2018-08-03 14:49:31,428 - grpc._server - ERROR - Exception calling application: '82f802e2-214b-47b2-954e-11865a9c54a1'
Traceback (most recent call last):
File "[...]/lib/python3.6/site-packages/grpc/_server.py", line 389, in _call_behavior
return behavior(argument, context), True
File "[...]/buildgrid/buildgrid/server/worker/bots_service.py", line 41, in CreateBotSession
request.bot_session)
File "[...]/buildgrid/buildgrid/server/worker/bots_interface.py", line 53, in create_bot_session
self._check_bot_ids(bot_id)
File "[...]/buildgrid/buildgrid/server/worker/bots_interface.py", line 93, in _check_bot_ids
self._close_bot_session(_name)
File "[...]/buildgrid/buildgrid/server/worker/bots_interface.py", line 106, in _close_bot_session
self._scheduler.retry_job(name)
File "[...]/buildgrid/buildgrid/server/scheduler.py", line 56, in retry_job
job = self.jobs[name]
KeyError: '82f802e2-214b-47b2-954e-11865a9c54a1'