Skip to content

Commit

Permalink
Add debug logs to bucket_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorbonas committed May 7, 2024
1 parent 0e8cd41 commit 1ef6319
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/python/influx-migration/influx_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,26 @@ def bucket_exists(host, token, bucket_name, skip_verify=False, org_name=None):
logging.debug(f"{len(org_list)} orgs matched with name {org_name}")
bucket = client.buckets_api().find_bucket_by_name(bucket_name)
if bucket is None:
logging.debug(f"Bucket with name {bucket_name} could not be found "
f"in host {host}")
return False
if len(org_list) > 0:
for org in org_list:
if org.id == bucket.org_id:
logging.debug(f"Bucket with name {bucket_name} found in org "
f"{org_name} with org ID {org.id} in host {host}")
return True
# Bucket could not be found in any org with matching org_name
logging.debug(f"Bucket with name {bucket_name} could not be found "
f"in any org with name {org_name} in host {host}")
return False
# Org not specified and bucket has been found
logging.debug(f"Bucket with name {bucket_name} found in host {host}")
return True
except InfluxDBError as error:
logging.error(str(error))
logging.debug("An unexpected error occurred while checking the existence "
f"a bucket with name {bucket_name} in host {host}")
return False

def cleanup(mount_point=None, exec_s3_bucket_mount=None):
Expand Down

0 comments on commit 1ef6319

Please sign in to comment.