finn pushed to branch finn/86-instance-error-msg at BuildGrid / buildgrid
Commits:
-
f7052140
by finnball at 2018-09-17T13:40:08Z
10 changed files:
- buildgrid/bot/bot_session.py
- buildgrid/server/actioncache/service.py
- buildgrid/server/bots/instance.py
- buildgrid/server/bots/service.py
- buildgrid/server/cas/service.py
- buildgrid/server/execution/instance.py
- buildgrid/server/execution/service.py
- buildgrid/server/operations/instance.py
- buildgrid/server/operations/service.py
- buildgrid/server/referencestorage/service.py
Changes:
... | ... | @@ -99,13 +99,13 @@ class BotSession: |
99 | 99 |
session = self._interface.create_bot_session(self._parent, self.get_pb2())
|
100 | 100 |
self._name = session.name
|
101 | 101 |
|
102 |
- self.logger.info("Created bot session with name: {}".format(self._name))
|
|
102 |
+ self.logger.info("Created bot session with name: [{}]".format(self._name))
|
|
103 | 103 |
|
104 | 104 |
for lease in session.leases:
|
105 | 105 |
self._update_lease_from_server(lease)
|
106 | 106 |
|
107 | 107 |
def update_bot_session(self):
|
108 |
- self.logger.debug("Updating bot session: {}".format(self._bot_id))
|
|
108 |
+ self.logger.debug("Updating bot session: [{}]".format(self._bot_id))
|
|
109 | 109 |
session = self._interface.update_bot_session(self.get_pb2())
|
110 | 110 |
for k, v in list(self._leases.items()):
|
111 | 111 |
if v.state == LeaseState.COMPLETED.value:
|
... | ... | @@ -141,12 +141,12 @@ class BotSession: |
141 | 141 |
asyncio.ensure_future(self.create_work(lease))
|
142 | 142 |
|
143 | 143 |
async def create_work(self, lease):
|
144 |
- self.logger.debug("Work created: {}".format(lease.id))
|
|
144 |
+ self.logger.debug("Work created: [{}]".format(lease.id))
|
|
145 | 145 |
|
146 | 146 |
loop = asyncio.get_event_loop()
|
147 | 147 |
lease = await loop.run_in_executor(None, self._work, self._context, lease)
|
148 | 148 |
|
149 |
- self.logger.debug("Work complete: {}".format(lease.id))
|
|
149 |
+ self.logger.debug("Work complete: [{}]".format(lease.id))
|
|
150 | 150 |
self.lease_completed(lease)
|
151 | 151 |
|
152 | 152 |
|
... | ... | @@ -161,14 +161,14 @@ class Worker: |
161 | 161 |
if k == 'pool':
|
162 | 162 |
self.properties[k] = v
|
163 | 163 |
else:
|
164 |
- raise KeyError('Key not supported: {}'.format(k))
|
|
164 |
+ raise KeyError('Key not supported: [{}]'.format(k))
|
|
165 | 165 |
|
166 | 166 |
if configs:
|
167 | 167 |
for k, v in configs.items():
|
168 | 168 |
if k == 'DockerImage':
|
169 | 169 |
self.configs[k] = v
|
170 | 170 |
else:
|
171 |
- raise KeyError('Key not supported: {}'.format(k))
|
|
171 |
+ raise KeyError('Key not supported: [{}]'.format(k))
|
|
172 | 172 |
|
173 | 173 |
@property
|
174 | 174 |
def configs(self):
|
... | ... | @@ -214,11 +214,11 @@ class Device: |
214 | 214 |
|
215 | 215 |
elif k == 'docker':
|
216 | 216 |
if v not in ('True', 'False'):
|
217 |
- raise ValueError('Value not supported: {}'.format(v))
|
|
217 |
+ raise ValueError('Value not supported: [{}]'.format(v))
|
|
218 | 218 |
self._properties[k] = v
|
219 | 219 |
|
220 | 220 |
else:
|
221 |
- raise KeyError('Key not supported: {}'.format(k))
|
|
221 |
+ raise KeyError('Key not supported: [{}]'.format(k))
|
|
222 | 222 |
|
223 | 223 |
@property
|
224 | 224 |
def name(self):
|
... | ... | @@ -77,4 +77,4 @@ class ActionCacheService(remote_execution_pb2_grpc.ActionCacheServicer): |
77 | 77 |
return self._instances[instance_name]
|
78 | 78 |
|
79 | 79 |
except KeyError:
|
80 |
- raise InvalidArgumentError("Invalid instance name: {}".format(instance_name))
|
|
80 |
+ raise InvalidArgumentError("Invalid instance name: [{}]".format(instance_name))
|
... | ... | @@ -60,7 +60,7 @@ class BotsInterface: |
60 | 60 |
|
61 | 61 |
self._bot_ids[name] = bot_id
|
62 | 62 |
self._bot_sessions[name] = bot_session
|
63 |
- self.logger.info("Created bot session name={} with bot_id={}".format(name, bot_id))
|
|
63 |
+ self.logger.info("Created bot session name=[{}] with bot_id=[{}]".format(name, bot_id))
|
|
64 | 64 |
|
65 | 65 |
for lease in self._scheduler.create_leases():
|
66 | 66 |
bot_session.leases.extend([lease])
|
... | ... | @@ -92,7 +92,7 @@ class BotsInterface: |
92 | 92 |
try:
|
93 | 93 |
server_lease = self._scheduler.get_job_lease(client_lease.id)
|
94 | 94 |
except KeyError:
|
95 |
- raise InvalidArgumentError("Lease not found on server: {}".format(client_lease))
|
|
95 |
+ raise InvalidArgumentError("Lease not found on server: [{}]".format(client_lease))
|
|
96 | 96 |
|
97 | 97 |
server_state = LeaseState(server_lease.state)
|
98 | 98 |
client_state = LeaseState(client_lease.state)
|
... | ... | @@ -105,7 +105,7 @@ class BotsInterface: |
105 | 105 |
# TODO: Lease was rejected
|
106 | 106 |
raise NotImplementedError("'Not Accepted' is unsupported")
|
107 | 107 |
else:
|
108 |
- raise OutofSyncError("Server lease: {}. Client lease: {}".format(server_lease, client_lease))
|
|
108 |
+ raise OutofSyncError("Server lease: [{}]. Client lease: [{}]".format(server_lease, client_lease))
|
|
109 | 109 |
|
110 | 110 |
elif server_state == LeaseState.ACTIVE:
|
111 | 111 |
|
... | ... | @@ -118,10 +118,10 @@ class BotsInterface: |
118 | 118 |
return None
|
119 | 119 |
|
120 | 120 |
else:
|
121 |
- raise OutofSyncError("Server lease: {}. Client lease: {}".format(server_lease, client_lease))
|
|
121 |
+ raise OutofSyncError("Server lease: [{}]. Client lease: [{}]".format(server_lease, client_lease))
|
|
122 | 122 |
|
123 | 123 |
elif server_state == LeaseState.COMPLETED:
|
124 |
- raise OutofSyncError("Server lease: {}. Client lease: {}".format(server_lease, client_lease))
|
|
124 |
+ raise OutofSyncError("Server lease: [{}]. Client lease: [{}]".format(server_lease, client_lease))
|
|
125 | 125 |
|
126 | 126 |
elif server_state == LeaseState.CANCELLED:
|
127 | 127 |
raise NotImplementedError("Cancelled states not supported yet")
|
... | ... | @@ -138,19 +138,19 @@ class BotsInterface: |
138 | 138 |
if name is not None:
|
139 | 139 |
_bot_id = self._bot_ids.get(name)
|
140 | 140 |
if _bot_id is None:
|
141 |
- raise InvalidArgumentError('Name not registered on server: {}'.format(name))
|
|
141 |
+ raise InvalidArgumentError('Name not registered on server: [{}]'.format(name))
|
|
142 | 142 |
elif _bot_id != bot_id:
|
143 | 143 |
self._close_bot_session(name)
|
144 | 144 |
raise InvalidArgumentError(
|
145 |
- 'Bot id invalid. ID sent: {} with name: {}.'
|
|
146 |
- 'ID registered: {} for that name'.format(bot_id, name, _bot_id))
|
|
145 |
+ 'Bot id invalid. ID sent: [{}] with name: [{}].'
|
|
146 |
+ 'ID registered: [{}] for that name'.format(bot_id, name, _bot_id))
|
|
147 | 147 |
else:
|
148 | 148 |
for _name, _bot_id in self._bot_ids.items():
|
149 | 149 |
if bot_id == _bot_id:
|
150 | 150 |
self._close_bot_session(_name)
|
151 | 151 |
raise InvalidArgumentError(
|
152 |
- 'Bot id already registered. ID sent: {}.'
|
|
153 |
- 'Id registered: {} with name: {}'.format(bot_id, _bot_id, _name))
|
|
152 |
+ 'Bot id already registered. ID sent: [{}].'
|
|
153 |
+ 'Id registered: [{}] with name: [{}]'.format(bot_id, _bot_id, _name))
|
|
154 | 154 |
|
155 | 155 |
def _close_bot_session(self, name):
|
156 | 156 |
""" Before removing the session, close any leases and
|
... | ... | @@ -159,14 +159,14 @@ class BotsInterface: |
159 | 159 |
bot_id = self._bot_ids.get(name)
|
160 | 160 |
|
161 | 161 |
if bot_id is None:
|
162 |
- raise InvalidArgumentError("Bot id does not exist: {}".format(name))
|
|
162 |
+ raise InvalidArgumentError("Bot id does not exist: [{}]".format(name))
|
|
163 | 163 |
|
164 |
- self.logger.debug("Attempting to close {} with name: {}".format(bot_id, name))
|
|
164 |
+ self.logger.debug("Attempting to close [{}] with name: [{}]".format(bot_id, name))
|
|
165 | 165 |
for lease in self._bot_sessions[name].leases:
|
166 | 166 |
if lease.state != LeaseState.COMPLETED.value:
|
167 | 167 |
# TODO: Be wary here, may need to handle rejected leases in future
|
168 | 168 |
self._scheduler.retry_job(lease.id)
|
169 | 169 |
|
170 |
- self.logger.debug("Closing bot session: {}".format(name))
|
|
170 |
+ self.logger.debug("Closing bot session: [{}]".format(name))
|
|
171 | 171 |
self._bot_ids.pop(name)
|
172 |
- self.logger.info("Closed bot {} with name: {}".format(bot_id, name))
|
|
172 |
+ self.logger.info("Closed bot [{}] with name: [{}]".format(bot_id, name))
|
... | ... | @@ -90,4 +90,4 @@ class BotsService(bots_pb2_grpc.BotsServicer): |
90 | 90 |
return self._instances[name]
|
91 | 91 |
|
92 | 92 |
except KeyError:
|
93 |
- raise InvalidArgumentError("Instance doesn't exist on server: {}".format(name))
|
|
93 |
+ raise InvalidArgumentError("Instance doesn't exist on server: [{}]".format(name))
|
... | ... | @@ -70,7 +70,7 @@ class ContentAddressableStorageService(remote_execution_pb2_grpc.ContentAddressa |
70 | 70 |
return self._instances[instance_name]
|
71 | 71 |
|
72 | 72 |
except KeyError:
|
73 |
- raise InvalidArgumentError("Invalid instance name: {}".format(instance_name))
|
|
73 |
+ raise InvalidArgumentError("Invalid instance name: [{}]".format(instance_name))
|
|
74 | 74 |
|
75 | 75 |
|
76 | 76 |
class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer):
|
... | ... | @@ -89,15 +89,15 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
89 | 89 |
# TODO: Decide on default instance name
|
90 | 90 |
if path[0] == "blobs":
|
91 | 91 |
if len(path) < 3 or not path[2].isdigit():
|
92 |
- raise InvalidArgumentError("Invalid resource name: {}".format(request.resource_name))
|
|
92 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(request.resource_name))
|
|
93 | 93 |
instance_name = ""
|
94 | 94 |
|
95 | 95 |
elif path[1] == "blobs":
|
96 | 96 |
if len(path) < 4 or not path[3].isdigit():
|
97 |
- raise InvalidArgumentError("Invalid resource name: {}".format(request.resource_name))
|
|
97 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(request.resource_name))
|
|
98 | 98 |
|
99 | 99 |
else:
|
100 |
- raise InvalidArgumentError("Invalid resource name: {}".format(request.resource_name))
|
|
100 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(request.resource_name))
|
|
101 | 101 |
|
102 | 102 |
instance = self._get_instance(instance_name)
|
103 | 103 |
yield from instance.read(path,
|
... | ... | @@ -134,15 +134,15 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
134 | 134 |
# TODO: Sort out no instance name
|
135 | 135 |
if path[0] == "uploads":
|
136 | 136 |
if len(path) < 5 or path[2] != "blobs" or not path[4].isdigit():
|
137 |
- raise InvalidArgumentError("Invalid resource name: {}".format(first_request.resource_name))
|
|
137 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(first_request.resource_name))
|
|
138 | 138 |
instance_name = ""
|
139 | 139 |
|
140 | 140 |
elif path[1] == "uploads":
|
141 | 141 |
if len(path) < 6 or path[3] != "blobs" or not path[5].isdigit():
|
142 |
- raise InvalidArgumentError("Invalid resource name: {}".format(first_request.resource_name))
|
|
142 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(first_request.resource_name))
|
|
143 | 143 |
|
144 | 144 |
else:
|
145 |
- raise InvalidArgumentError("Invalid resource name: {}".format(first_request.resource_name))
|
|
145 |
+ raise InvalidArgumentError("Invalid resource name: [{}]".format(first_request.resource_name))
|
|
146 | 146 |
|
147 | 147 |
instance = self._get_instance(instance_name)
|
148 | 148 |
return instance.write(requests)
|
... | ... | @@ -169,4 +169,4 @@ class ByteStreamService(bytestream_pb2_grpc.ByteStreamServicer): |
169 | 169 |
return self._instances[instance_name]
|
170 | 170 |
|
171 | 171 |
except KeyError:
|
172 |
- raise InvalidArgumentError("Invalid instance name: {}".format(instance_name))
|
|
172 |
+ raise InvalidArgumentError("Invalid instance name: [{}]".format(instance_name))
|
... | ... | @@ -47,7 +47,7 @@ class ExecutionInstance: |
47 | 47 |
do_not_cache = action.do_not_cache
|
48 | 48 |
|
49 | 49 |
job = Job(action_digest, do_not_cache, message_queue)
|
50 |
- self.logger.info("Operation name: {}".format(job.name))
|
|
50 |
+ self.logger.info("Operation name: [{}]".format(job.name))
|
|
51 | 51 |
|
52 | 52 |
self._scheduler.append_job(job, skip_cache_lookup)
|
53 | 53 |
|
... | ... | @@ -58,14 +58,14 @@ class ExecutionInstance: |
58 | 58 |
self._scheduler.register_client(name, queue)
|
59 | 59 |
|
60 | 60 |
except KeyError:
|
61 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
61 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
62 | 62 |
|
63 | 63 |
def unregister_message_client(self, name, queue):
|
64 | 64 |
try:
|
65 | 65 |
self._scheduler.unregister_client(name, queue)
|
66 | 66 |
|
67 | 67 |
except KeyError:
|
68 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
68 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
69 | 69 |
|
70 | 70 |
def stream_operation_updates(self, message_queue, operation_name):
|
71 | 71 |
operation = message_queue.get()
|
... | ... | @@ -92,4 +92,4 @@ class ExecutionService(remote_execution_pb2_grpc.ExecutionServicer): |
92 | 92 |
return self._instances[name]
|
93 | 93 |
|
94 | 94 |
except KeyError:
|
95 |
- raise InvalidArgumentError("Instance doesn't exist on server: {}".format(name))
|
|
95 |
+ raise InvalidArgumentError("Instance doesn't exist on server: [{}]".format(name))
|
... | ... | @@ -34,7 +34,7 @@ class OperationsInstance: |
34 | 34 |
operation = self._scheduler.jobs.get(name)
|
35 | 35 |
|
36 | 36 |
if operation is None:
|
37 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
37 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
38 | 38 |
|
39 | 39 |
else:
|
40 | 40 |
return operation.get_operation()
|
... | ... | @@ -49,21 +49,21 @@ class OperationsInstance: |
49 | 49 |
self._scheduler.jobs.pop(name)
|
50 | 50 |
|
51 | 51 |
except KeyError:
|
52 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
52 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
53 | 53 |
|
54 | 54 |
def register_message_client(self, name, queue):
|
55 | 55 |
try:
|
56 | 56 |
self._scheduler.register_client(name, queue)
|
57 | 57 |
|
58 | 58 |
except KeyError:
|
59 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
59 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
60 | 60 |
|
61 | 61 |
def unregister_message_client(self, name, queue):
|
62 | 62 |
try:
|
63 | 63 |
self._scheduler.unregister_client(name, queue)
|
64 | 64 |
|
65 | 65 |
except KeyError:
|
66 |
- raise InvalidArgumentError("Operation name does not exist: {}".format(name))
|
|
66 |
+ raise InvalidArgumentError("Operation name does not exist: [{}]".format(name))
|
|
67 | 67 |
|
68 | 68 |
def stream_operation_updates(self, message_queue, operation_name):
|
69 | 69 |
operation = message_queue.get()
|
... | ... | @@ -132,4 +132,4 @@ class OperationsService(operations_pb2_grpc.OperationsServicer): |
132 | 132 |
return self._instances[instance_name]
|
133 | 133 |
|
134 | 134 |
except KeyError:
|
135 |
- raise InvalidArgumentError("Instance doesn't exist on server: {}".format(name))
|
|
135 |
+ raise InvalidArgumentError("Instance doesn't exist on server: [{}]".format(name))
|
... | ... | @@ -86,4 +86,4 @@ class ReferenceStorageService(buildstream_pb2_grpc.ReferenceStorageServicer): |
86 | 86 |
return self._instances[instance_name]
|
87 | 87 |
|
88 | 88 |
except KeyError:
|
89 |
- raise InvalidArgumentError("Invalid instance name: {}".format(instance_name))
|
|
89 |
+ raise InvalidArgumentError("Invalid instance name: [{}]".format(instance_name))
|