diff --git a/docker/importer/importer.py b/docker/importer/importer.py index a7675e46c77..9975f598531 100755 --- a/docker/importer/importer.py +++ b/docker/importer/importer.py @@ -34,6 +34,7 @@ from google.cloud import ndb from google.cloud import pubsub_v1 from google.cloud import storage +from google.cloud.storage import retry import pygit2.enums import osv @@ -87,7 +88,8 @@ def replace_importer_log(client: storage.Client, source_name: str, bucket: storage.Bucket = client.bucket(bucket_name) upload_string = '--- ' + datetime.datetime.utcnow().isoformat() + ' ---\n' upload_string += '\n'.join(import_failure_logs) - bucket.blob(source_name).upload_from_string(upload_string) + bucket.blob(source_name).upload_from_string( + upload_string, retry=retry.DEFAULT_RETRY) def log_run_duration(start: float): diff --git a/docker/worker/worker.py b/docker/worker/worker.py index 9b1c9cc4fd9..8a488299531 100644 --- a/docker/worker/worker.py +++ b/docker/worker/worker.py @@ -32,6 +32,7 @@ from google.cloud import ndb from google.cloud import pubsub_v1 from google.cloud import storage +from google.cloud.storage import retry sys.path.append(os.path.dirname(os.path.realpath(__file__))) import osv @@ -378,7 +379,7 @@ def _source_update(self, message): storage_client = storage.Client() bucket = storage_client.bucket(source_repo.bucket) try: - blob = bucket.blob(path).download_as_bytes() + blob = bucket.blob(path).download_as_bytes(retry=retry.DEFAULT_RETRY) except google.cloud.exceptions.NotFound: logging.exception('Bucket path %s does not exist.', path) return