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

[Storage] Make s3 bucket creation log visible to the users #3730

Merged
Merged
Changes from 2 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
28 changes: 13 additions & 15 deletions sky/data/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,24 +1368,22 @@ def _create_s3_bucket(self,
"""
s3_client = self.client
try:
if region is None:
s3_client.create_bucket(Bucket=bucket_name)
else:
if region == 'us-east-1':
# If default us-east-1 region is used, the
# LocationConstraint must not be specified.
# https://stackoverflow.com/a/51912090
s3_client.create_bucket(Bucket=bucket_name)
else:
location = {'LocationConstraint': region}
s3_client.create_bucket(Bucket=bucket_name,
CreateBucketConfiguration=location)
logger.info(f'Created S3 bucket {bucket_name} in {region}')
create_bucket_config: Dict[str, Any] = {'Bucket': bucket_name}
# If default us-east-1 region of create_bucket API is used,
# the LocationConstraint must not be specified.
# Reference: https://stackoverflow.com/a/51912090
if region and region != 'us-east-1':
landscapepainter marked this conversation as resolved.
Show resolved Hide resolved
create_bucket_config['CreateBucketConfiguration'] = {
'LocationConstraint': region
}
s3_client.create_bucket(**create_bucket_config)
logger.info(
f'Created S3 bucket {bucket_name!r} in {region or "us-east-1"}')
except aws.botocore_exceptions().ClientError as e:
with ux_utils.print_exception_no_traceback():
raise exceptions.StorageBucketCreateError(
f'Attempted to create a bucket '
f'{self.name} but failed.') from e
f'Attempted to create a bucket {self.name} but failed.'
) from e
return aws.resource('s3').Bucket(bucket_name)

def _delete_s3_bucket(self, bucket_name: str) -> bool:
Expand Down
Loading