You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ak...@apache.org on 2023/01/16 18:52:10 UTC

[buildstream] branch abderrahim/nogrpc created (now ba0df1b1a)

This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a change to branch abderrahim/nogrpc
in repository https://gitbox.apache.org/repos/asf/buildstream.git


      at ba0df1b1a elementsourcescache: don't try catching grpc.RpcError

This branch includes the following new commits:

     new ba0df1b1a elementsourcescache: don't try catching grpc.RpcError

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/01: elementsourcescache: don't try catching grpc.RpcError

Posted by ak...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

akitouni pushed a commit to branch abderrahim/nogrpc
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ba0df1b1ac5280af84d1bacdd09e7b61f824d65b
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Mon Jan 16 19:51:11 2023 +0100

    elementsourcescache: don't try catching grpc.RpcError
    
    Nothing that it calls raises this exception; everything should raise either
    AssetCacheError or CasRemoteError.
---
 src/buildstream/_elementsourcescache.py | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/buildstream/_elementsourcescache.py b/src/buildstream/_elementsourcescache.py
index 8330851f2..ee5461076 100644
--- a/src/buildstream/_elementsourcescache.py
+++ b/src/buildstream/_elementsourcescache.py
@@ -12,7 +12,6 @@
 #  limitations under the License.
 #
 import os
-import grpc
 
 from ._cas.casremote import BlobNotFound
 from ._assetcache import AssetCache
@@ -227,12 +226,6 @@ class ElementSourcesCache(AssetCache):
             if cas_error.reason != "cache-too-full":
                 raise SourceCacheError("Failed to push source blobs: {}".format(cas_error))
             return False
-        except grpc.RpcError as e:
-            if e.code() != grpc.StatusCode.RESOURCE_EXHAUSTED:
-                raise SourceCacheError(
-                    "Failed to push source blobs with status {}: {}".format(e.code().name, e.details()), temporary=True
-                )
-            return False
 
         return True
 
@@ -269,7 +262,7 @@ class ElementSourcesCache(AssetCache):
                 source_digest,
                 references_directories=referenced_directories,
             )
-        except grpc.RpcError as e:
+        except AssetCacheError as e:
             raise SourceCacheError(
                 "Failed to push source with status {}: {}".format(e.code().name, e.details()), temporary=True
             )
@@ -305,11 +298,10 @@ class ElementSourcesCache(AssetCache):
                 f.write(source.SerializeToString())
 
             self.cas._fetch_directory(remote, source.files)
-        except grpc.RpcError as e:
-            if e.code() != grpc.StatusCode.NOT_FOUND:
-                raise SourceCacheError(
-                    "Failed to pull source with status {}: {}".format(e.code().name, e.details()), temporary=True
-                )
+        except BlobNotFound:
+            pass
+        except CasRemoteError as e:
+            raise SourceCacheError("Failed to pull source: {}".format(e.details()), temporary=True)
             return False
 
         return True
@@ -323,9 +315,6 @@ class ElementSourcesCache(AssetCache):
             remote.push_directory([uri], source_proto.files)
             return True
 
-        except grpc.RpcError as e:
-            if e.code() != grpc.StatusCode.RESOURCE_EXHAUSTED:
-                raise SourceCacheError(
-                    "Failed to push source with status {}: {}".format(e.code().name, e.details()), temporary=True
-                )
-            return False
+        except AssetCacheError as e:
+            raise SourceCacheError("Failed to push source: {}".format(e), temporary=True)
+        return False