chore: handle errors in app-configure-blobstore.py (#8567)
This commit is contained in:
parent
aeba63bb41
commit
041fa83d21
|
@ -2,6 +2,8 @@
|
||||||
# Copyright The IETF Trust 2024, All Rights Reserved
|
# Copyright The IETF Trust 2024, All Rights Reserved
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
import botocore.config
|
||||||
|
import botocore.exceptions
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -16,13 +18,19 @@ def init_blobstore():
|
||||||
aws_secret_access_key=os.environ.get("BLOB_STORE_SECRET_KEY", "minio_pass"),
|
aws_secret_access_key=os.environ.get("BLOB_STORE_SECRET_KEY", "minio_pass"),
|
||||||
aws_session_token=None,
|
aws_session_token=None,
|
||||||
config=botocore.config.Config(signature_version="s3v4"),
|
config=botocore.config.Config(signature_version="s3v4"),
|
||||||
verify=False,
|
|
||||||
)
|
)
|
||||||
for bucketname in MORE_STORAGE_NAMES:
|
for bucketname in MORE_STORAGE_NAMES:
|
||||||
blobstore.create_bucket(
|
try:
|
||||||
Bucket=f"{os.environ.get('BLOB_STORE_BUCKET_PREFIX', '')}{bucketname}".strip()
|
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__":
|
if __name__ == "__main__":
|
||||||
sys.exit(init_blobstore())
|
sys.exit(init_blobstore())
|
||||||
|
|
Loading…
Reference in a new issue