Repository: google/clusterfuzz

Issue:
google_cloud_utils.storage should not retry on out of disk exceptions.



Discussion:

Resolving patch:
diff --git a/src/python/google_cloud_utils/storage.py b/src/python/google_cloud_utils/storage.py
--- a/src/python/google_cloud_utils/storage.py
+++ b/src/python/google_cloud_utils/storage.py
@@ -752,7 +752,8 @@ def generate_life_cycle_config(action, age=None, num_newer_versions=None):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.copy_file_from')
+    function='google_cloud_utils.storage.copy_file_from',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def copy_file_from(cloud_storage_file_path, local_file_path, use_cache=False):
   """Saves a cloud storage file locally."""
   if use_cache and get_file_from_cache_if_exists(local_file_path):
@@ -771,7 +772,8 @@ def copy_file_from(cloud_storage_file_path, local_file_path, use_cache=False):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.copy_file_to')
+    function='google_cloud_utils.storage.copy_file_to',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def copy_file_to(local_file_path_or_handle,
                  cloud_storage_file_path,
                  metadata=None):
@@ -788,7 +790,8 @@ def copy_file_to(local_file_path_or_handle,
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.copy_blob')
+    function='google_cloud_utils.storage.copy_blob',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def copy_blob(cloud_storage_source_path, cloud_storage_target_path):
   """Copy two blobs on GCS 'in the cloud' without touching local disk."""
   return _provider().copy_blob(cloud_storage_source_path,
@@ -798,7 +801,8 @@ def copy_blob(cloud_storage_source_path, cloud_storage_target_path):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.delete')
+    function='google_cloud_utils.storage.delete',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def delete(cloud_storage_file_path):
   """Delete a cloud storage file given its path."""
   return _provider().delete(cloud_storage_file_path)
@@ -823,7 +827,8 @@ def exists(cloud_storage_file_path, ignore_errors=False):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.last_updated')
+    function='google_cloud_utils.storage.last_updated',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def last_updated(cloud_storage_file_path):
   """Return last updated value by parsing stats for all blobs under a cloud
   storage path."""
@@ -840,7 +845,8 @@ def last_updated(cloud_storage_file_path):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.read_data')
+    function='google_cloud_utils.storage.read_data',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def read_data(cloud_storage_file_path):
   """Return content of a cloud storage file."""
   return _provider().read_data(cloud_storage_file_path)
@@ -849,7 +855,8 @@ def read_data(cloud_storage_file_path):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.write_data')
+    function='google_cloud_utils.storage.write_data',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def write_data(data, cloud_storage_file_path, metadata=None):
   """Return content of a cloud storage file."""
   return _provider().write_data(
@@ -859,7 +866,8 @@ def write_data(data, cloud_storage_file_path, metadata=None):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.get_blobs')
+    function='google_cloud_utils.storage.get_blobs',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def get_blobs(cloud_storage_path, recursive=True):
   """Return blobs under the given cloud storage path."""
   for blob in _provider().list_blobs(cloud_storage_path, recursive=recursive):
@@ -869,7 +877,8 @@ def get_blobs(cloud_storage_path, recursive=True):
 @retry.wrap(
     retries=DEFAULT_FAIL_RETRIES,
     delay=DEFAULT_FAIL_WAIT,
-    function='google_cloud_utils.storage.list_blobs')
+    function='google_cloud_utils.storage.list_blobs',
+    exception_type=google.cloud.exceptions.GoogleCloudError)
 def list_blobs(cloud_storage_path, recursive=True):
   """Return blob names under the given cloud storage path."""
   for blob in _provider().list_blobs(cloud_storage_path, recursive=recursive):


Test patch: