Martin Blanchard pushed to branch mablanch/23-new-logging at BuildGrid / buildgrid
Commits:
-
dd572340
by Martin Blanchard at 2018-11-08T16:54:57Z
7 changed files:
- buildgrid/server/actioncache/service.py
- buildgrid/server/bots/service.py
- buildgrid/server/cas/service.py
- buildgrid/server/execution/service.py
- buildgrid/server/operations/service.py
- buildgrid/server/referencestorage/service.py
- tests/cas/test_services.py
Changes:
... | ... | @@ -42,8 +42,9 @@ class ActionCacheService(remote_execution_pb2_grpc.ActionCacheServicer): |
42 | 42 |
self._instances[name] = instance
|
43 | 43 |
|
44 | 44 |
def GetActionResult(self, request, context):
|
45 |
+ self.__logger.debug("GetActionResult request from [%s]", context.peer())
|
|
46 |
+ |
|
45 | 47 |
try:
|
46 |
- self.__logger.debug("GetActionResult request from [%s]", context.peer())
|
|
47 | 48 |
instance = self._get_instance(request.instance_name)
|
48 | 49 |
return instance.get_action_result(request.action_digest)
|
49 | 50 |
|
... | ... | @@ -59,8 +60,9 @@ class ActionCacheService(remote_execution_pb2_grpc.ActionCacheServicer): |
59 | 60 |
return remote_execution_pb2.ActionResult()
|
60 | 61 |
|
61 | 62 |
def UpdateActionResult(self, request, context):
|
63 |
+ self.__logger.debug("UpdateActionResult request from [%s]", context.peer())
|
|
64 |
+ |
|
62 | 65 |
try:
|
63 |
- self.__logger.debug("UpdateActionResult request from [%s]", context.peer())
|
|
64 | 66 |
instance = self._get_instance(request.instance_name)
|
65 | 67 |
instance.update_action_result(request.action_digest, request.action_result)
|
66 | 68 |
return request.action_result
|
... | ... | @@ -43,8 +43,9 @@ class BotsService(bots_pb2_grpc.BotsServicer): |
43 | 43 |
self._instances[name] = instance
|
44 | 44 |
|
45 | 45 |
def CreateBotSession(self, request, context):
|
46 |
+ self.__logger.debug("CreateBotSession request from [%s]", context.peer())
|
|
47 |
+ |
|
46 | 48 |
try:
|
47 |
- self.__logger.debug("CreateBotSession request from [%s]", context.peer())
|
|
48 | 49 |
parent = request.parent
|
49 | 50 |
instance = self._get_instance(request.parent)
|
50 | 51 |
return instance.create_bot_session(parent,
|
... | ... | @@ -58,8 +59,9 @@ class BotsService(bots_pb2_grpc.BotsServicer): |
58 | 59 |
return bots_pb2.BotSession()
|
59 | 60 |
|
60 | 61 |
def UpdateBotSession(self, request, context):
|
62 |
+ self.__logger.debug("UpdateBotSession request from [%s]", context.peer())
|
|
63 |
+ |
|
61 | 64 |
try:
|
62 |
- self.__logger.debug("UpdateBotSession request from [%s]", context.peer())
|
|
63 | 65 |
names = request.name.split("/")
|
64 | 66 |
# Operation name should be in format:
|
65 | 67 |
# {instance/name}/{uuid}
|
... | ... | @@ -87,7 +89,8 @@ class BotsService(bots_pb2_grpc.BotsServicer): |
87 | 89 |
return bots_pb2.BotSession()
|
88 | 90 |
|
89 | 91 |
def PostBotEventTemp(self, request, context):
|
90 |
- self.__logger.debug("PostBotEventTemp request from [%s]", context.peer())
|
|
92 |
+ self.__logger.debug("PostBotEventTemp request from [%s]", context.peer())
|
|
93 |
+ |
|
91 | 94 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
92 | 95 |
return Empty()
|
93 | 96 |
|
... | ... | @@ -45,11 +45,12 @@ class ContentAddressableStorageService(remote_execution_pb2_grpc.ContentAddressa |
45 | 45 |
self._instances[name] = instance
|
46 | 46 |
|
47 | 47 |
def FindMissingBlobs(self, request, context):
|
48 |
+ self.__logger.debug("FindMissingBlobs request from [%s]", context.peer())
|
|
49 |
+ |
|
48 | 50 |
try:
|
49 |
- self.__logger.debug("FindMissingBlobs request: [%s]", request)
|
|
50 | 51 |
instance = self._get_instance(request.instance_name)
|
51 | 52 |
response = instance.find_missing_blobs(request.blob_digests)
|
52 |
- self.__logger.debug("FindMissingBlobs response: [%s]", response)
|
|
53 |
+ |
|
53 | 54 |
return response
|
54 | 55 |
|
55 | 56 |
except InvalidArgumentError as e:
|
... | ... | @@ -60,11 +61,12 @@ class ContentAddressableStorageService(remote_execution_pb2_grpc.ContentAddressa |
60 | 61 |
return remote_execution_pb2.FindMissingBlobsResponse()
|
61 | 62 |
|
62 | 63 |
def BatchUpdateBlobs(self, request, context):
|
64 |
+ self.__logger.debug("BatchUpdateBlobs request from [%s]", context.peer())
|
|
65 |
+ |
|
63 | 66 |
try:
|
64 |
- self.__logger.debug("BatchUpdateBlobs request: [%s]", request)
|
|
65 | 67 |
instance = self._get_instance(request.instance_name)
|
66 | 68 |
response = instance.batch_update_blobs(request.requests)
|
67 |
- self.__logger.debug("FindMissingBlobs response: [%s]", response)
|
|
69 |
+ |
|
68 | 70 |
return response
|
69 | 71 |
|
70 | 72 |
except InvalidArgumentError as e:
|
... | ... | @@ -75,12 +77,16 @@ class ContentAddressableStorageService(remote_execution_pb2_grpc.ContentAddressa |
75 | 77 |
return remote_execution_pb2.BatchReadBlobsResponse()
|
76 | 78 |
|
77 | 79 |
def BatchReadBlobs(self, request, context):
|
80 |
+ self.__logger.debug("BatchReadBlobs request from [%s]", context.peer())
|
|
81 |
+ |
|
78 | 82 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
79 | 83 |
context.set_details('Method not implemented!')
|
80 | 84 |
|
81 | 85 |
return remote_execution_pb2.BatchReadBlobsResponse()
|
82 | 86 |
|
83 | 87 |
def GetTree(self, request, context):
|
88 |
+ self.__logger.debug("GetTree request from [%s]", context.peer())
|
|
89 |
+ |
|
84 | 90 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
85 | 91 |
context.set_details('Method not implemented!')
|
86 | 92 |
|
... | ... | @@ -107,8 +113,9 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
107 | 113 |
self._instances[name] = instance
|
108 | 114 |
|
109 | 115 |
def Read(self, request, context):
|
116 |
+ self.__logger.debug("Read request from [%s]", context.peer())
|
|
117 |
+ |
|
110 | 118 |
try:
|
111 |
- self.__logger.debug("Read request: [%s]", request)
|
|
112 | 119 |
path = request.resource_name.split("/")
|
113 | 120 |
instance_name = path[0]
|
114 | 121 |
|
... | ... | @@ -148,13 +155,12 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
148 | 155 |
context.set_code(grpc.StatusCode.OUT_OF_RANGE)
|
149 | 156 |
yield bytestream_pb2.ReadResponse()
|
150 | 157 |
|
151 |
- self.__logger.debug("Read finished.")
|
|
152 |
- |
|
153 | 158 |
def Write(self, requests, context):
|
159 |
+ self.__logger.debug("Write request from [%s]", context.peer())
|
|
160 |
+ |
|
154 | 161 |
try:
|
155 | 162 |
requests, request_probe = tee(requests, 2)
|
156 | 163 |
first_request = next(request_probe)
|
157 |
- self.__logger.debug("First write request: [%s]", first_request)
|
|
158 | 164 |
|
159 | 165 |
path = first_request.resource_name.split("/")
|
160 | 166 |
|
... | ... | @@ -175,7 +181,7 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
175 | 181 |
|
176 | 182 |
instance = self._get_instance(instance_name)
|
177 | 183 |
response = instance.write(requests)
|
178 |
- self.__logger.debug("Write response: [%s]", response)
|
|
184 |
+ |
|
179 | 185 |
return response
|
180 | 186 |
|
181 | 187 |
except NotImplementedError as e:
|
... | ... | @@ -43,8 +43,9 @@ class ExecutionService(remote_execution_pb2_grpc.ExecutionServicer): |
43 | 43 |
self._instances[name] = instance
|
44 | 44 |
|
45 | 45 |
def Execute(self, request, context):
|
46 |
+ self.__logger.debug("Execute request from [%s]", context.peer())
|
|
47 |
+ |
|
46 | 48 |
try:
|
47 |
- self.__logger.debug("Execute request from [%s]", context.peer())
|
|
48 | 49 |
message_queue = queue.Queue()
|
49 | 50 |
instance = self._get_instance(request.instance_name)
|
50 | 51 |
operation = instance.execute(request.action_digest,
|
... | ... | @@ -79,8 +80,9 @@ class ExecutionService(remote_execution_pb2_grpc.ExecutionServicer): |
79 | 80 |
yield operations_pb2.Operation()
|
80 | 81 |
|
81 | 82 |
def WaitExecution(self, request, context):
|
83 |
+ self.__logger.debug("WaitExecution request from [%s]", context.peer())
|
|
84 |
+ |
|
82 | 85 |
try:
|
83 |
- self.__logger.debug("WaitExecution request from [%s]", context.peer())
|
|
84 | 86 |
names = request.name.split("/")
|
85 | 87 |
|
86 | 88 |
# Operation name should be in format:
|
... | ... | @@ -42,8 +42,9 @@ class OperationsService(operations_pb2_grpc.OperationsServicer): |
42 | 42 |
self._instances[name] = instance
|
43 | 43 |
|
44 | 44 |
def GetOperation(self, request, context):
|
45 |
+ self.__logger.debug("GetOperation request from [%s]", context.peer())
|
|
46 |
+ |
|
45 | 47 |
try:
|
46 |
- self.__logger.debug("GetOperation request from [%s]", context.peer())
|
|
47 | 48 |
name = request.name
|
48 | 49 |
|
49 | 50 |
instance_name = self._parse_instance_name(name)
|
... | ... | @@ -64,8 +65,9 @@ class OperationsService(operations_pb2_grpc.OperationsServicer): |
64 | 65 |
return operations_pb2.Operation()
|
65 | 66 |
|
66 | 67 |
def ListOperations(self, request, context):
|
68 |
+ self.__logger.debug("ListOperations request from [%s]", context.peer())
|
|
69 |
+ |
|
67 | 70 |
try:
|
68 |
- self.__logger.debug("ListOperations request from [%s]", context.peer())
|
|
69 | 71 |
# The request name should be the collection name
|
70 | 72 |
# In our case, this is just the instance_name
|
71 | 73 |
instance_name = request.name
|
... | ... | @@ -88,8 +90,9 @@ class OperationsService(operations_pb2_grpc.OperationsServicer): |
88 | 90 |
return operations_pb2.ListOperationsResponse()
|
89 | 91 |
|
90 | 92 |
def DeleteOperation(self, request, context):
|
93 |
+ self.__logger.debug("DeleteOperation request from [%s]", context.peer())
|
|
94 |
+ |
|
91 | 95 |
try:
|
92 |
- self.__logger.debug("DeleteOperation request from [%s]", context.peer())
|
|
93 | 96 |
name = request.name
|
94 | 97 |
|
95 | 98 |
instance_name = self._parse_instance_name(name)
|
... | ... | @@ -106,8 +109,9 @@ class OperationsService(operations_pb2_grpc.OperationsServicer): |
106 | 109 |
return Empty()
|
107 | 110 |
|
108 | 111 |
def CancelOperation(self, request, context):
|
112 |
+ self.__logger.debug("CancelOperation request from [%s]", context.peer())
|
|
113 |
+ |
|
109 | 114 |
try:
|
110 |
- self.__logger.debug("CancelOperation request from [%s]", context.peer())
|
|
111 | 115 |
name = request.name
|
112 | 116 |
|
113 | 117 |
instance_name = self._parse_instance_name(name)
|
... | ... | @@ -35,6 +35,8 @@ class ReferenceStorageService(buildstream_pb2_grpc.ReferenceStorageServicer): |
35 | 35 |
self._instances[name] = instance
|
36 | 36 |
|
37 | 37 |
def GetReference(self, request, context):
|
38 |
+ self.__logger.debug("GetReference request from [%s]", context.peer())
|
|
39 |
+ |
|
38 | 40 |
try:
|
39 | 41 |
instance = self._get_instance(request.instance_name)
|
40 | 42 |
digest = instance.get_digest_reference(request.key)
|
... | ... | @@ -54,6 +56,8 @@ class ReferenceStorageService(buildstream_pb2_grpc.ReferenceStorageServicer): |
54 | 56 |
return buildstream_pb2.GetReferenceResponse()
|
55 | 57 |
|
56 | 58 |
def UpdateReference(self, request, context):
|
59 |
+ self.__logger.debug("UpdateReference request from [%s]", context.peer())
|
|
60 |
+ |
|
57 | 61 |
try:
|
58 | 62 |
instance = self._get_instance(request.instance_name)
|
59 | 63 |
digest = request.digest
|
... | ... | @@ -72,6 +76,8 @@ class ReferenceStorageService(buildstream_pb2_grpc.ReferenceStorageServicer): |
72 | 76 |
return buildstream_pb2.UpdateReferenceResponse()
|
73 | 77 |
|
74 | 78 |
def Status(self, request, context):
|
79 |
+ self.__logger.debug("Status request from [%s]", context.peer())
|
|
80 |
+ |
|
75 | 81 |
try:
|
76 | 82 |
instance = self._get_instance(request.instance_name)
|
77 | 83 |
allow_updates = instance.allow_updates
|
... | ... | @@ -89,7 +89,7 @@ def test_bytestream_read(mocked, data_to_read, instance): |
89 | 89 |
request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
|
90 | 90 |
|
91 | 91 |
data = b""
|
92 |
- for response in servicer.Read(request, None):
|
|
92 |
+ for response in servicer.Read(request, context):
|
|
93 | 93 |
data += response.data
|
94 | 94 |
assert data == data_to_read
|
95 | 95 |
|
... | ... | @@ -111,7 +111,7 @@ def test_bytestream_read_many(mocked, instance): |
111 | 111 |
request.resource_name += "blobs/{}/{}".format(HASH(data_to_read).hexdigest(), len(data_to_read))
|
112 | 112 |
|
113 | 113 |
data = b""
|
114 |
- for response in servicer.Read(request, None):
|
|
114 |
+ for response in servicer.Read(request, context):
|
|
115 | 115 |
data += response.data
|
116 | 116 |
assert data == data_to_read
|
117 | 117 |
|
... | ... | @@ -137,7 +137,7 @@ def test_bytestream_write(mocked, instance, extra_data): |
137 | 137 |
bytestream_pb2.WriteRequest(data=b'def', write_offset=3, finish_write=True)
|
138 | 138 |
]
|
139 | 139 |
|
140 |
- response = servicer.Write(requests, None)
|
|
140 |
+ response = servicer.Write(requests, context)
|
|
141 | 141 |
assert response.committed_size == 6
|
142 | 142 |
assert len(storage.data) == 1
|
143 | 143 |
assert (hash_, 6) in storage.data
|
... | ... | @@ -178,7 +178,7 @@ def test_cas_find_missing_blobs(mocked, instance): |
178 | 178 |
re_pb2.Digest(hash=HASH(b'ghij').hexdigest(), size_bytes=4)
|
179 | 179 |
]
|
180 | 180 |
request = re_pb2.FindMissingBlobsRequest(instance_name=instance, blob_digests=digests)
|
181 |
- response = servicer.FindMissingBlobs(request, None)
|
|
181 |
+ response = servicer.FindMissingBlobs(request, context)
|
|
182 | 182 |
assert len(response.missing_blob_digests) == 1
|
183 | 183 |
assert response.missing_blob_digests[0] == digests[1]
|
184 | 184 |
|
... | ... | @@ -201,7 +201,7 @@ def test_cas_batch_update_blobs(mocked, instance): |
201 | 201 |
]
|
202 | 202 |
|
203 | 203 |
request = re_pb2.BatchUpdateBlobsRequest(instance_name=instance, requests=update_requests)
|
204 |
- response = servicer.BatchUpdateBlobs(request, None)
|
|
204 |
+ response = servicer.BatchUpdateBlobs(request, context)
|
|
205 | 205 |
assert len(response.responses) == 2
|
206 | 206 |
|
207 | 207 |
for blob_response in response.responses:
|