Remove createbucket option (#1841)

AWS CLI can do this.  Fixes #1840.
This commit is contained in:
Andrew Gaul 2022-01-05 01:59:31 +09:00 committed by GitHub
parent 37af08bacf
commit e734763002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 75 deletions

View File

@ -89,7 +89,6 @@ static bool is_ecs = false;
static bool is_ibm_iam_auth = false;
static bool is_use_xattr = false;
static bool is_use_session_token = false;
static bool create_bucket = false;
static off_t multipart_threshold = 25 * 1024 * 1024;
static int64_t singlepart_copy_limit = 512 * 1024 * 1024;
static bool is_specified_endpoint = false;
@ -864,56 +863,6 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
return 0;
}
static int do_create_bucket()
{
S3FS_PRN_INFO2("/");
FILE* ptmpfp;
int tmpfd;
if(endpoint == "us-east-1"){
ptmpfp = NULL;
tmpfd = -1;
}else{
if(NULL == (ptmpfp = tmpfile()) ||
-1 == (tmpfd = fileno(ptmpfp)) ||
0 >= fprintf(ptmpfp, "<CreateBucketConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">\n"
" <LocationConstraint>%s</LocationConstraint>\n"
"</CreateBucketConfiguration>", endpoint.c_str()) ||
0 != fflush(ptmpfp) ||
-1 == fseek(ptmpfp, 0L, SEEK_SET))
{
S3FS_PRN_ERR("failed to create temporary file. err(%d)", errno);
if(ptmpfp){
fclose(ptmpfp);
}
return (0 == errno ? -EIO : -errno);
}
}
headers_t meta;
S3fsCurl s3fscurl(true);
int res = s3fscurl.PutRequest("/", meta, tmpfd);
if(res < 0){
long responseCode = s3fscurl.GetLastResponseCode();
if((responseCode == 400 || responseCode == 403) && S3fsCurl::GetSignatureType() == V2_OR_V4){
S3FS_PRN_ERR("Could not connect, so retry to connect by signature version 2.");
S3fsCurl::SetSignatureType(V2_ONLY);
// retry to check
s3fscurl.DestroyCurlHandle();
res = s3fscurl.PutRequest("/", meta, tmpfd);
}else if(responseCode == 409){
// bucket already exists
res = 0;
}
}
if(ptmpfp != NULL){
fclose(ptmpfp);
}
return res;
}
// common function for creation of a plain object
static int create_file_object(const char* path, mode_t mode, uid_t uid, gid_t gid)
{
@ -3399,14 +3348,6 @@ static void* s3fs_init(struct fuse_conn_info* conn)
S3FS_PRN_INFO("loaded IAM role name = %s", S3fsCurl::GetIAMRole());
}
if (create_bucket){
int result = do_create_bucket();
if(result != 0){
s3fs_exit_fuseloop(result);
return NULL;
}
}
// Check Bucket
{
int result;
@ -4716,10 +4657,6 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
S3fsCurl::SetSignatureType(V4_ONLY);
return 0;
}
if(0 == strcmp(arg, "createbucket")){
create_bucket = true;
return 0;
}
if(is_prefix(arg, "endpoint=")){
endpoint = strchr(arg, '=') + sizeof(char);
is_specified_endpoint = true;
@ -5183,13 +5120,6 @@ int main(int argc, char* argv[])
exit(EXIT_FAILURE);
}
if(create_bucket && !S3fsCurl::IsSetAccessKeyID()){
S3FS_PRN_EXIT("missing service instance ID for bucket creation");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
exit(EXIT_FAILURE);
}
}
// set user agent

View File

@ -222,9 +222,6 @@ function start_s3fs {
#
# use_path_request_style
# The test env doesn't have virtual hosts
# createbucket
# S3Proxy always starts with no buckets, this tests the s3fs-fuse
# automatic bucket creation path.
# $AUTH_OPT
# Will be either "-o public_bucket=1"
# or
@ -248,7 +245,6 @@ function start_s3fs {
-o no_check_certificate \
-o ssl_verify_hostname=0 \
-o use_xattr=1 \
-o createbucket \
-o enable_unsigned_payload \
${AUTH_OPT} \
${DIRECT_IO_OPT} \

View File

@ -61,6 +61,8 @@ fi
start_s3proxy
aws_cli s3 mb "s3://${TEST_BUCKET_1}" --region "${S3_ENDPOINT}"
for flag in "${FLAGS[@]}"; do
echo "testing s3fs flag: $flag"

View File

@ -315,7 +315,7 @@ function get_disk_avail_size() {
}
function aws_cli() {
FLAGS=""
local FLAGS=""
if [ -n "${S3FS_PROFILE}" ]; then
FLAGS="--profile ${S3FS_PROFILE}"
fi