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

[WIP] Allow to use bucket storage policy #220

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

AymericDu
Copy link
Member

@AymericDu AymericDu commented Jun 15, 2020

Enable or disable the use of bucket storage policy.

When enabled, and if a storage policy is defined for a bucket (root container), all objects in this bucket will be uploaded with this storage policy.

The bucket storage policy can optionally be kept in the cache with its old value. To force the update of this value, it is enough to modify a property of this bucket via the AWS CLI (for example: add a tag).

$ $AWS s3 mb "s3://mybucket0"
make_bucket: mybucket0
$ $AWS s3 cp /etc/magic "s3://mybucket0/dir/magic"
upload: ../../../etc/magic to s3://mybucket0/dir/magic            
$ openio --oio-account AUTH_demo object show mybucket0%2Fdir magic
+---------------------------------------+-------------------------------------------------------------------------------------+
| Field                                 | Value                                                                               |
+---------------------------------------+-------------------------------------------------------------------------------------+
| account                               | AUTH_demo                                                                           |
| container                             | mybucket0%2Fdir                                                                     |
| ctime                                 | 1592432652                                                                          |
| hash                                  | 272913026300E7AE9B5E2D51F138E674                                                    |
| id                                    | D3758F1E4FA80500EED85C409D1F62E1                                                    |
| meta.x-object-sysmeta-oio-bucket-name | mybucket0                                                                           |
| meta.x-object-sysmeta-swift3-acl      | {"Owner":"demo:demo","Grant":[{"Grantee":"demo:demo","Permission":"FULL_CONTROL"}]} |
| mime-type                             | application/octet-stream                                                            |
| mtime                                 | 1592432652                                                                          |
| object                                | magic                                                                               |
| policy                                | THREECOPIES                                                                         |
| size                                  | 111                                                                                 |
| version                               | 1592432652154332                                                                    |
+---------------------------------------+-------------------------------------------------------------------------------------+      
$ openio --oio-account AUTH_demo container set mybucket0 --storage-policy TWOCOPIES
$ $AWS s3 cp /etc/magic "s3://mybucket0/dir/magic"
upload: ../../../etc/magic to s3://mybucket0/dir/magic            
$ openio --oio-account AUTH_demo object show mybucket0%2Fdir magic
+---------------------------------------+-------------------------------------------------------------------------------------+
| Field                                 | Value                                                                               |
+---------------------------------------+-------------------------------------------------------------------------------------+
| account                               | AUTH_demo                                                                           |
| container                             | mybucket0%2Fdir                                                                     |
| ctime                                 | 1592432652                                                                          |
| hash                                  | 272913026300E7AE9B5E2D51F138E674                                                    |
| id                                    | C46CD5224FA805005D12AD8A9D1F0FDF                                                    |
| meta.x-object-sysmeta-oio-bucket-name | mybucket0                                                                           |
| meta.x-object-sysmeta-swift3-acl      | {"Owner":"demo:demo","Grant":[{"Grantee":"demo:demo","Permission":"FULL_CONTROL"}]} |
| mime-type                             | application/octet-stream                                                            |
| mtime                                 | 1592432723                                                                          |
| object                                | magic                                                                               |
| policy                                | THREECOPIES                                                                         |
| size                                  | 111                                                                                 |
| version                               | 1592432723848390                                                                    |
+---------------------------------------+-------------------------------------------------------------------------------------+
$ $AWS s3api put-bucket-tagging --tagging 'TagSet=[{Key=storage,Value=policy}]' --bucket mybucket0
$ $AWS s3 cp /etc/magic "s3://mybucket0/dir/magic"
upload: ../../../etc/magic to s3://mybucket0/dir/magic            
$ openio --oio-account AUTH_demo object show mybucket0%2Fdir magic
+---------------------------------------+-------------------------------------------------------------------------------------+
| Field                                 | Value                                                                               |
+---------------------------------------+-------------------------------------------------------------------------------------+
| account                               | AUTH_demo                                                                           |
| container                             | mybucket0%2Fdir                                                                     |
| ctime                                 | 1592432652                                                                          |
| hash                                  | 272913026300E7AE9B5E2D51F138E674                                                    |
| id                                    | B5A448324FA80500BF750ADA9D1F32E1                                                    |
| meta.x-object-sysmeta-oio-bucket-name | mybucket0                                                                           |
| meta.x-object-sysmeta-swift3-acl      | {"Owner":"demo:demo","Grant":[{"Grantee":"demo:demo","Permission":"FULL_CONTROL"}]} |
| mime-type                             | application/octet-stream                                                            |
| mtime                                 | 1592432983                                                                          |
| object                                | magic                                                                               |
| policy                                | TWOCOPIES                                                                           |
| size                                  | 111                                                                                 |
| version                               | 1592432983057591                                                                    |
+---------------------------------------+-------------------------------------------------------------------------------------+

@AymericDu AymericDu requested review from murlock and fvennetier June 15, 2020 16:40
conf/default.cfg Outdated Show resolved Hide resolved
oioswift/proxy/controllers/obj.py Outdated Show resolved Hide resolved
@AymericDu AymericDu force-pushed the allow-to-use-bucket-storage-policy branch from f166759 to f58dca4 Compare June 17, 2020 12:51
@AymericDu AymericDu force-pushed the allow-to-use-bucket-storage-policy branch from f58dca4 to 4a58605 Compare June 17, 2020 16:22
@AymericDu AymericDu force-pushed the allow-to-use-bucket-storage-policy branch from 4a58605 to e4ee404 Compare June 17, 2020 22:40
@AymericDu AymericDu force-pushed the allow-to-use-bucket-storage-policy branch from e4ee404 to 2d0041a Compare June 17, 2020 22:57
@AymericDu AymericDu requested a review from fvennetier June 17, 2020 22:59
if memcache is not None:
memcache_key = "/".join(
("versioning", self.account_name, root_container))
version_policy = memcache.get(memcache_key)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it possible to put that somewhere in the container sysmeta? This would allow to use the usual cache functions (e.g. clear_info_cache).

Copy link
Contributor

@murlock murlock left a comment

Choose a reason for hiding this comment

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

A functional test should be nice

@AymericDu AymericDu changed the title Allow to use bucket storage policy [WIP] Allow to use bucket storage policy Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants