-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
ARROW-15906: [C++][Python][R] By default, don't create or delete S3 buckets #13206
Conversation
cpp/src/arrow/filesystem/s3fs.h
Outdated
@@ -130,6 +130,9 @@ struct ARROW_EXPORT S3Options { | |||
/// Whether OutputStream writes will be issued in the background, without blocking. | |||
bool background_writes = true; | |||
|
|||
/// Whether to allow creation of new buckets | |||
bool allow_create_buckets = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also update S3Options::FromUri()
to support this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I've added that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it two options for flexibility (creation and deletion).
Also wrt. naming, should this be allow_bucket_creation
? @lidavidm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps create_buckets
and delete_buckets
? That reads more consistently with background_writes
to me. Or allow_creating_buckets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked create_buckets
but since there is a setter method and I want it named the same thing as the property (for clear error hints), I felt like allow_bucket_creation
was the better choice.
4409d3d
to
06b10bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you send an e-mail to dev@
to confirm whether this default behavior change is acceptable? I can't decide this because I haven't used Apache Arrow to access S3 yet.
cpp/src/arrow/filesystem/s3fs.h
Outdated
@@ -130,6 +130,14 @@ struct ARROW_EXPORT S3Options { | |||
/// Whether OutputStream writes will be issued in the background, without blocking. | |||
bool background_writes = true; | |||
|
|||
/// Whether to allow creation or deletion of buckets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that "deletion" depends on allow_create_buckets
confuses users. How about renaming allow_create_buckets
or create one more option?
BTW, why should we disable "deletion" by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't have to. Buckets can only be deleted if already empty, so hard to accidentally delete an important one I suppose.
Sure, I've done that here: https://lists.apache.org/thread/2wnmq72trrtcxyvxzw261gq0t6grq18g |
cpp/src/arrow/filesystem/s3fs.h
Outdated
@@ -130,6 +130,9 @@ struct ARROW_EXPORT S3Options { | |||
/// Whether OutputStream writes will be issued in the background, without blocking. | |||
bool background_writes = true; | |||
|
|||
/// Whether to allow creation of new buckets | |||
bool allow_create_buckets = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it two options for flexibility (creation and deletion).
Also wrt. naming, should this be allow_bucket_creation
? @lidavidm
cpp/src/arrow/filesystem/s3fs.cc
Outdated
::arrow::internal::AsciiEqualsCaseInsensitive(kv.second, "true"); | ||
} else if (kv.first == "allow_bucket_deletion") { | ||
options.allow_bucket_deletion = | ||
::arrow::internal::AsciiEqualsCaseInsensitive(kv.second, "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think we should be a bit stricter and not blindly interpret any other value as "false".
How about allowing the following values:
- "0", "false" (case-insensitive) -> boolean false
- "1", "true" (case-insensitive) -> boolean true
- any other value -> raise
Status::Invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I didn't see any existing utility function to do this, so maybe I will create one.
cpp/src/arrow/filesystem/s3fs.h
Outdated
@@ -218,6 +229,12 @@ class ARROW_EXPORT S3FileSystem : public FileSystem { | |||
/// Return the actual region this filesystem connects to | |||
std::string region() const; | |||
|
|||
/// Set create_buckets property of options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These trivial setters are not needed as people can access the attributes directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options()
returns a const reference; they could access but I don't think they could mutate right?
Being able to change this setting later felt important when I didn't support in FromURI
, but maybe it's not as important now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These trivial setters are not needed as people can access the attributes directly.
I'm not so sure that's true. This fails:
auto options = fs_->options();
options.allow_bucket_creation = true;
options.allow_bucket_deletion = true;
ASSERT_EQ(fs_->options().allow_bucket_creation, true);
ASSERT_EQ(fs_->options().allow_bucket_deletion, true);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is not really supported, though. You should set options before creating the filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think I'm fine at this point with only allowing setting them during construction, since we've added them to the URI parsing.
python/pyarrow/_s3fs.pyx
Outdated
@property | ||
def allow_bucket_creation(self): | ||
""" | ||
Whether to allow CreateDir at the bucket-level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use the same docstring for constructor parameters and the associated properties.
Personally, I like "Whether to allow CreateDir at the bucket-level."
3703808
to
b25cedf
Compare
b25cedf
to
02a1db0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @wjones127 . Here are some more comments needing addressing.
scheme='http' | ||
scheme='http', | ||
allow_bucket_creation=True, | ||
allow_bucket_deletion=True | ||
) | ||
fs.create_dir(bucket) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add tests in test_s3_options
?
@thisisnic @dragosmg Can one of you perhaps review the R changes? |
LGTM, but I'd like the opinion of someone more experienced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, just one small comment/suggestions on the R tests.
r/tests/testthat/test-s3-minio.R
Outdated
test_that("CreateDir fails on bucket if allow_bucket_creation=False", { | ||
now_tmp <- paste0(now, "-test-fail-delete") | ||
fs$CreateDir(now_tmp) | ||
|
||
expect_error( | ||
limited_fs$CreateDir("should-fail"), | ||
regexp = "Bucket does not exist" | ||
) | ||
expect_error( | ||
limited_fs$DeleteDir(now_tmp), | ||
regexp = "Would delete bucket" | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if these tests might be better without the regexp
parameter, given that the specific phrasing of them comes from the C++ layer, and we tend to avoid testing that component of the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll rewrite it so these messages are tested in C++ instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wjones127 !
…Hub issue numbers (#34260) Rewrite the Jira issue numbers to the GitHub issue numbers, so that the GitHub issue numbers are automatically linked to the issues by pkgdown's auto-linking feature. Issue numbers have been rewritten based on the following correspondence. Also, the pkgdown settings have been changed and updated to link to GitHub. I generated the Changelog page using the `pkgdown::build_news()` function and verified that the links work correctly. --- ARROW-6338 #5198 ARROW-6364 #5201 ARROW-6323 #5169 ARROW-6278 #5141 ARROW-6360 #5329 ARROW-6533 #5450 ARROW-6348 #5223 ARROW-6337 #5399 ARROW-10850 #9128 ARROW-10624 #9092 ARROW-10386 #8549 ARROW-6994 #23308 ARROW-12774 #10320 ARROW-12670 #10287 ARROW-16828 #13484 ARROW-14989 #13482 ARROW-16977 #13514 ARROW-13404 #10999 ARROW-16887 #13601 ARROW-15906 #13206 ARROW-15280 #13171 ARROW-16144 #13183 ARROW-16511 #13105 ARROW-16085 #13088 ARROW-16715 #13555 ARROW-16268 #13550 ARROW-16700 #13518 ARROW-16807 #13583 ARROW-16871 #13517 ARROW-16415 #13190 ARROW-14821 #12154 ARROW-16439 #13174 ARROW-16394 #13118 ARROW-16516 #13163 ARROW-16395 #13627 ARROW-14848 #12589 ARROW-16407 #13196 ARROW-16653 #13506 ARROW-14575 #13160 ARROW-15271 #13170 ARROW-16703 #13650 ARROW-16444 #13397 ARROW-15016 #13541 ARROW-16776 #13563 ARROW-15622 #13090 ARROW-18131 #14484 ARROW-18305 #14581 ARROW-18285 #14615 * Closes: #33631 Authored-by: SHIMA Tatsuya <ts1s1andn@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
…to GitHub issue numbers (apache#34260) Rewrite the Jira issue numbers to the GitHub issue numbers, so that the GitHub issue numbers are automatically linked to the issues by pkgdown's auto-linking feature. Issue numbers have been rewritten based on the following correspondence. Also, the pkgdown settings have been changed and updated to link to GitHub. I generated the Changelog page using the `pkgdown::build_news()` function and verified that the links work correctly. --- ARROW-6338 apache#5198 ARROW-6364 apache#5201 ARROW-6323 apache#5169 ARROW-6278 apache#5141 ARROW-6360 apache#5329 ARROW-6533 apache#5450 ARROW-6348 apache#5223 ARROW-6337 apache#5399 ARROW-10850 apache#9128 ARROW-10624 apache#9092 ARROW-10386 apache#8549 ARROW-6994 apache#23308 ARROW-12774 apache#10320 ARROW-12670 apache#10287 ARROW-16828 apache#13484 ARROW-14989 apache#13482 ARROW-16977 apache#13514 ARROW-13404 apache#10999 ARROW-16887 apache#13601 ARROW-15906 apache#13206 ARROW-15280 apache#13171 ARROW-16144 apache#13183 ARROW-16511 apache#13105 ARROW-16085 apache#13088 ARROW-16715 apache#13555 ARROW-16268 apache#13550 ARROW-16700 apache#13518 ARROW-16807 apache#13583 ARROW-16871 apache#13517 ARROW-16415 apache#13190 ARROW-14821 apache#12154 ARROW-16439 apache#13174 ARROW-16394 apache#13118 ARROW-16516 apache#13163 ARROW-16395 apache#13627 ARROW-14848 apache#12589 ARROW-16407 apache#13196 ARROW-16653 apache#13506 ARROW-14575 apache#13160 ARROW-15271 apache#13170 ARROW-16703 apache#13650 ARROW-16444 apache#13397 ARROW-15016 apache#13541 ARROW-16776 apache#13563 ARROW-15622 apache#13090 ARROW-18131 apache#14484 ARROW-18305 apache#14581 ARROW-18285 apache#14615 * Closes: apache#33631 Authored-by: SHIMA Tatsuya <ts1s1andn@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
BREAKING CHANGE: modifies
S3FileSystem
to not allow creating or deleting buckets by default. Two new options are added:allow_bucket_creation
, which enables creating buckets, andallow_bucket_deletion
, which enables deleting buckets.Outside of tests, most use cases will not want to create or delete buckets, and doing so accidentally is not desirable either. Buckets have governance controls like permissions and cost-tracking tags.
To make it easy for users to transition, the
FromUri
method also supports these arguments: