chore: handle errors in app-configure-blobstore.py (#8567)

This commit is contained in:
Jennifer Richards 2025-02-20 16:45:22 -04:00 committed by GitHub
parent aeba63bb41
commit 041fa83d21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,8 @@
# Copyright The IETF Trust 2024, All Rights Reserved
import boto3
import botocore.config
import botocore.exceptions
import os
import sys
@ -16,13 +18,19 @@ def init_blobstore():
aws_secret_access_key=os.environ.get("BLOB_STORE_SECRET_KEY", "minio_pass"),
aws_session_token=None,
config=botocore.config.Config(signature_version="s3v4"),
verify=False,
)
for bucketname in MORE_STORAGE_NAMES:
blobstore.create_bucket(
Bucket=f"{os.environ.get('BLOB_STORE_BUCKET_PREFIX', '')}{bucketname}".strip()
)
try:
blobstore.create_bucket(
Bucket=f"{os.environ.get('BLOB_STORE_BUCKET_PREFIX', '')}{bucketname}".strip()
)
except botocore.exceptions.ClientError as err:
if err.response["Error"]["Code"] == "BucketAlreadyExists":
print(f"Bucket {bucketname} already exists")
else:
print(f"Error creating {bucketname}: {err.response['Error']['Code']}")
else:
print(f"Bucket {bucketname} created")
if __name__ == "__main__":
sys.exit(init_blobstore())