Creating buckets for S3 compatible storage fails

We setup an S3 compatible backup storage location (we use SWIFT to provide the S3 compatible backup).

Unfortunately, the function "Create a new S3 bucket" does not work.

The following fixes the problem, but this should go into a Virtualmin as a bugfix, because this is too much for most users to handle.

Interestingly it only works with a location called "US" - none of the other location names work.

Start: fixes

  1. Enable "Create a new S3 bucket"

To enable "Create bucket" function - we need to patch virtualmin sources.

Out-of-the box virtualmin doesn't support US location for buckets. And with non-US location - our storage will return Error during creating bucket. US location for buckets - mean default location (so it's bug in virtualmin, that not such location in list) Add US location to pop-up list:

vim /usr/share/webmin/virtual-server/s3-lib.pl

Find s3_list_locations function and add "US" to return() as first item

Before:

# s3_list_locations(access-key, secret-key) # Returns a list of all possible S3 locations for buckets sub s3_list_locations { my ($akey, $skey) = @_; return ( "us-west-1", "us-west-2", "EU", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "sa-east-1", "eu-central-1" ); }

Now:

# s3_list_locations(access-key, secret-key) # Returns a list of all possible S3 locations for buckets sub s3_list_locations { my ($akey, $skey) = @_; return ( "US", "us-west-1", "us-west-2", "EU", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "sa-east-1", "eu-central-1" ); }

Set US location as default for Create bucket form

vim /usr/share/webmin/virtual-server/edit_bucket.cgi

Find print &ui_table_start( and inside condition if ($in{'new'}) { change default output from "us-west-1" to ""

Before:

print &ui_table_row($text{'bucket_location'}, &ui_select("location", "us-west-1", [ &s3_list_locations(@$account) ])); }

Now:

print &ui_table_row($text{'bucket_location'}, &ui_select("location", "US", [ &s3_list_locations(@$account) ])); }

Disable ACL and lifecycle policy applying during creating new bucket due buggy ACL list in virtualmin

We can't leave it blank, as unproper XML will be formed, from other side - user haven't opportunity to type right data there, as he need to know tenant:username - but we generate it with random text and don't display to user. So only 1 proper solution - disable this step. Inside storage all will be fine - default user will be applied (so, account owner user will be applied)

vim /usr/share/webmin/virtual-server/save_bucket.cgi

Comment line with s3_put_bucket_acl and s3_put_bucket_lifecycle

#$err = &s3_put_bucket_acl(@$account, $in{'name'}, $acl); .... #$err = &s3_put_bucket_lifecycle(@$account, $in{'name'}, $lifecycle);

Restart virtualmin

service webmin restart

Refresh page in browser.

End: fixes

Status: 
Active

Comments

Interesting - so it sounds like the main problem here is that this S3-compatible service doesn't use the same locations as the real S3 service.

Does real S3 support a location named "US" ?