summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-12-06 10:28:08 +0100
committerValentin David <valentin.david@codethink.co.uk>2018-12-06 10:28:08 +0100
commit8610a8a4de3480c4fb1fbb657b37b475da8174ec (patch)
tree4b0540f43875cc48de00f93be2cf987571d09514
parenta53d6d1f81913d639175cbd503d9d71ec7133a4e (diff)
downloadbuildstream-valentindavid/handle_grpc_unavailable.tar.gz
Handle grpc.StatusCode.UNAVAILABLE in first request in case connect() failsvalentindavid/handle_grpc_unavailable
This should allow retrying. CAS cache server seems to not accept connections in time.
-rw-r--r--buildstream/_artifactcache/cascache.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 9ca757d4d..ac7c5fb4c 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -1199,8 +1199,12 @@ class CASRemote():
if 0 < server_max_batch_total_size_bytes < self.max_batch_total_size_bytes:
self.max_batch_total_size_bytes = server_max_batch_total_size_bytes
except grpc.RpcError as e:
- # Simply use the defaults for servers that don't implement GetCapabilities()
- if e.code() != grpc.StatusCode.UNIMPLEMENTED:
+ if e.code() == grpc.StatusCode.UNIMPLEMENTED:
+ # Simply use the defaults for servers that don't implement GetCapabilities()
+ pass
+ elif e.code() == grpc.StatusCode.UNAVAILABLE:
+ raise CASError("Failed to connect to CAS service: {}".format(e.details())) from e
+ else:
raise
# Check whether the server supports BatchReadBlobs()