-
Notifications
You must be signed in to change notification settings - Fork 113
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
Enforce space quota on uploads #2164
Conversation
// containedWithinSpace is a working name. It checks whether a reference is contained within a Storage Space or not. If | ||
// it is, it will return the root node of the storage space. | ||
func (fs *Decomposedfs) containedWithinSpace(ctx context.Context, n *node.Node) (*node.Node, bool) { | ||
// get home or root node |
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 haven't tested it but I think this method will not work correctly when you start at a sub-sub-folder.
/<space-root>/f1/f2
f2.Parent()
= f1
and f1
has a name so that will return f1, if I'm not mistaken.
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.
reva/pkg/storage/utils/decomposedfs/spaces.go
Lines 92 to 94 in 1b66c13
if err := n.SetMetadata(xattrs.SpaceNameAttr, req.Name); err != nil { | |
return nil, err | |
} |
AFAIK we only set the name attribute at the root of the space 🤔
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.
If what you meant to say is that if a file does not contain a name the function will early return, then you're right :p. This is the tests I'm running:
Test with a nested folder:
- create test folders under space's root:
<root>/f1/f2
curl -k -X MKCOL https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157\!492dc039-70c3-44e2-8a71-bdcf690a9dbe/f1 -u admin:admin
curl -k -X MKCOL https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157\!492dc039-70c3-44e2-8a71-bdcf690a9dbe/f1 -u admin:admin
- upload in
f2
curl -k -X PUT https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157\!492dc039-70c3-44e2-8a71-bdcf690a9dbe/f1/f2/test.txt -d "12345678901" -u admin:admin -v
- update the space quota
xattr -w user.ocis.quota 10 /var/tmp/ocis/storage/users/spaces/project/492dc039-70c3-44e2-8a71-bdcf690a9dbe
- upload again
curl -k -X PUT https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157\!492dc039-70c3-44e2-8a71-bdcf690a9dbe/f1/f2/test3.txt -d "12345678901" -u admin:admin -v
Should and must fail with insufficient storage.
I will push the new patch.
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.
Ah now I found my mistake. I was thinking of the attribute name
not spaceName
. Every node has a name
but not every node has a spaceName
. So this is fine. 👍
DO NOT MERGE just yet. This reports the wrong real disk usage of the blobs, as |
Acceptance Criteria
TODO
Regression found
The create storage space response returns an invalid webdav url. Needs to be fixed.
Questions
What is the behavior if:
i.e: space quota: 50 bytes, root FS quota: 20 bytes
Technical Debt
Testing
curl -k -X POST 'https://localhost:9200/graph/v1.0/drives' -u admin:admin -d '{"name":"marketing", "quota": {"total": 20}}' -v
The resulting node will use up 39 bytes (because of the metadata)
curl -k -X PUT https://localhost:9200/dav/spaces/1284d238-aa92-42ce-bdc4-0b0000009157\!d36bfa36-9441-4ec4-9d32-f2e8880bd301/test.txt -d "1234567890" -u admin:admin -v