Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query all controllers for backups #67

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/openstack_billing_db/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ def download_latest_dump_from_s3() -> str:
aws_secret_access_key=s3_secret,
)

key = None
today = datetime.today().strftime("%Y%m%d")
dumps = s3.list_objects_v2(Bucket=s3_bucket, Prefix=f"dbs/nerc-ctl-0/nova-{today}")

if len(dumps["Contents"]) == 0:
for ctl in ["nerc-ctl-0", "nerc-ctl-1", "nerc-ctl-2"]:
dumps = s3.list_objects_v2(Bucket=s3_bucket, Prefix=f"dbs/{ctl}/nova-{today}")

if "Contents" in dumps:
key = dumps["Contents"][0]["Key"]
break

if not key:
raise Exception(f"No database dumps found for {today}")

key = dumps["Contents"][0]["Key"]
filename = os.path.basename(key)
download_location = f"/tmp/{filename}"

Expand Down
Loading