diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-12-06 10:28:08 +0100 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-12-06 10:28:08 +0100 |
commit | 8610a8a4de3480c4fb1fbb657b37b475da8174ec (patch) | |
tree | 4b0540f43875cc48de00f93be2cf987571d09514 | |
parent | a53d6d1f81913d639175cbd503d9d71ec7133a4e (diff) | |
download | buildstream-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.py | 8 |
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() |