Skip to content

Correctly handle TooManyBuckets error_code in default_bucket method #40

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

Merged
merged 2 commits into from
Jan 12, 2018
Merged
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions src/sagemaker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def default_bucket(self):
elif error_code == 'OperationAborted' and 'conflicting conditional operation' in message:
# If this bucket is already being concurrently created, we don't need to create it again.
pass
elif error_code == 'TooManyBuckets':
try:
s3.meta.client.head_bucket(Bucket=default_bucket)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little esoteric - if we remove the logging below, can you add some developer documentation:

# Succeed if the default bucket exists

LOGGER.info('S3 bucket {} already exists'.format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this logging message, in the normal case we don't log this.

default_bucket))
pass
except ClientError:
raise
else:
raise

Expand Down