Skip to content

Commit

Permalink
Removed retries for getting a bucket.
Browse files Browse the repository at this point in the history
  • Loading branch information
VJalili committed Sep 5, 2017
1 parent cfce6c2 commit b555837
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/galaxy/objectstore/cloud.py
Expand Up @@ -171,21 +171,17 @@ def __clean_cache(self, file_list, delete_this_much):
return

def _get_bucket(self, bucket_name):
""" Sometimes a handle to a bucket is not established right away so try
it a few times. Raise error if connection is not established. """
for i in range(5):
try:
bucket = self.conn.object_store.get(bucket_name)
if bucket is None:
log.debug("Bucket not found, creating a bucket with handle '%s'", bucket_name)
bucket = self.conn.object_store.create(bucket_name)
log.debug("Using cloud object store with bucket '%s'", bucket.name)
return bucket
except Exception:
log.exception("Could not get bucket '%s', attempt %s/5", bucket_name, i + 1)
time.sleep(2)
# All the attempts have been exhausted and connection was not established,
# raise error
try:
bucket = self.conn.object_store.get(bucket_name)
if bucket is None:
log.debug("Bucket not found, creating a bucket with handle '%s'", bucket_name)
bucket = self.conn.object_store.create(bucket_name)
log.debug("Using cloud ObjectStore with bucket '%s'", bucket.name)
return bucket
except Exception:
# These two generic exceptions will be replaced by specific exceptions
# once proper exceptions are exposed by CloudBridge.
log.exception("Could not get bucket '%s'.", bucket_name)
raise Exception

def _fix_permissions(self, rel_path):
Expand Down

0 comments on commit b555837

Please sign in to comment.