Merge "Replace asserts with exceptions"

This commit is contained in:
Zuul 2021-11-16 01:40:52 +00:00 committed by Gerrit Code Review
commit 7bee0b5861
3 changed files with 8 additions and 4 deletions

View File

@ -7089,7 +7089,8 @@ class Layout(object):
# configured pipeline, if so return an empty JobGraph.
if old:
job_map = item.current_build_set._old_jobs
assert(context is None)
if context is not None:
raise RuntimeError("Context should be none for old job graphs")
context = zkobject.LocalZKContext(self.log)
else:
job_map = item.current_build_set.jobs

View File

@ -198,8 +198,10 @@ class JobRequestQueue(ZooKeeperSimpleBase):
path = "/".join([self.REQUEST_ROOT, request.uuid])
request.path = path
assert isinstance(request, self.request_class)
assert request.state == self.request_class.UNSUBMITTED
if not isinstance(request, self.request_class):
raise RuntimeError("Request of wrong class")
if request.state != self.request_class.UNSUBMITTED:
raise RuntimeError("Request state must be unsubmitted")
request.state = self.initial_state
result = None

View File

@ -64,7 +64,8 @@ class RawShardIO(io.RawIOBase):
# Only write one key at a time and defer writing the rest to the caller
shard_bytes = bytes(shard_data[0:NODE_BYTE_SIZE_LIMIT])
shard_bytes = zlib.compress(shard_bytes)
assert(len(shard_bytes) < NODE_BYTE_SIZE_LIMIT)
if not (len(shard_bytes) < NODE_BYTE_SIZE_LIMIT):
raise RuntimeError("Shard too large")
self.client.create(
"{}/".format(self.shard_base),
shard_bytes,