Skip to content
Snippets Groups Projects
Commit 8169a487 authored by finn's avatar finn
Browse files

Returning empty messages after exception is raised

parent c565b786
Branches
Tags
No related merge requests found
Pipeline #28358687 failed
......@@ -24,6 +24,7 @@ import logging
import grpc
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2_grpc
from .._exceptions import NotFoundError
......@@ -39,13 +40,19 @@ class ActionCacheService(remote_execution_pb2_grpc.ActionCacheServicer):
try:
return self._action_cache.get_action_result(request.action_digest)
except NotFoundError:
except NotFoundError as e:
self.logger.error(e)
context.set_code(grpc.StatusCode.NOT_FOUND)
return remote_execution_pb2.ActionResult()
def UpdateActionResult(self, request, context):
try:
self._action_cache.update_action_result(request.action_digest, request.action_result)
return request.action_result
except NotImplementedError:
except NotImplementedError as e:
self.logger.error(e)
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
return remote_execution_pb2.ActionResult()
......@@ -28,6 +28,8 @@ import grpc
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2_grpc
from buildgrid._protos.google.longrunning import operations_pb2
from .._exceptions import InvalidArgumentError
......@@ -55,11 +57,13 @@ class ExecutionService(remote_execution_pb2_grpc.ExecutionServicer):
self.logger.error(e)
context.set_details(str(e))
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
return operations_pb2.Operation()
except NotImplementedError as e:
self.logger.error(e)
context.set_details(str(e))
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
return operations_pb2.Operation()
def WaitExecution(self, request, context):
try:
......@@ -77,6 +81,7 @@ class ExecutionService(remote_execution_pb2_grpc.ExecutionServicer):
self.logger.error(e)
context.set_details(str(e))
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
return operations_pb2.Operation()
def _remove_client(self, operation_name, message_queue):
self._instance.unregister_message_client(operation_name, message_queue)
......
......@@ -37,6 +37,7 @@ class OperationsService(operations_pb2_grpc.OperationsServicer):
def GetOperation(self, request, context):
try:
return self._instance.get_operation(request.name)
except InvalidArgumentError as e:
self.logger.error(e)
context.set_details(str(e))
......@@ -52,15 +53,19 @@ class OperationsService(operations_pb2_grpc.OperationsServicer):
def DeleteOperation(self, request, context):
try:
return self._instance.delete_operation(request.name)
except InvalidArgumentError as e:
self.logger.error(e)
context.set_details(str(e))
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
return operations_pb2.Operation()
def CancelOperation(self, request, context):
try:
return self._instance.cancel_operation(request.name)
except NotImplementedError as e:
self.logger.error(e)
context.set_details(str(e))
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
return operations_pb2.Operation()
......@@ -23,6 +23,7 @@ import logging
import grpc
from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2
from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2_grpc
from .._exceptions import InvalidArgumentError, OutofSyncError
......@@ -43,6 +44,8 @@ class BotsService(bots_pb2_grpc.BotsServicer):
context.set_details(str(e))
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
return bots_pb2.BotSession()
def UpdateBotSession(self, request, context):
try:
return self._instance.update_bot_session(request.name,
......@@ -62,5 +65,8 @@ class BotsService(bots_pb2_grpc.BotsServicer):
context.set_details(str(e))
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
return bots_pb2.BotSession()
def PostBotEventTemp(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
return google.protobuf.Empty()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment