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

Add resource size info to transfer type OCM share #2104

Closed
redblom opened this issue Sep 24, 2021 · 3 comments
Closed

Add resource size info to transfer type OCM share #2104

redblom opened this issue Sep 24, 2021 · 3 comments

Comments

@redblom
Copy link
Contributor

redblom commented Sep 24, 2021

At WP4.4 it is discussed that it would be useful for a receiver of a transfer type OCM share to know the size of the transfer before accepting it. Although the size cannot be guaranteed, a sender could still add more files to a transfer folder which would also be transferred after acceptance in case of a transfer retry, the receiving end could limit the transfer to the expected size (data cap). Or, from the end user viewpoint, have an idea of what to expect.
For the receiver it is not possible to stat the resource to be transferred before accepting it because the webdav reference to it is only created after accepting the share. Thus, the size info must be send by the creator of the resource as a specific size parameter.

The initiator of the datatx type OCM share adds the current size to the opaque field of the request:

createShareReq := &ocm.CreateOCMShareRequest{

		createShareReq := &ocm.CreateOCMShareRequest{
			Opaque: &types.Opaque{
				Map: map[string]*types.OpaqueEntry{
					"permissions": {
						Decoder: "plain",
						Value:   []byte(strconv.Itoa(pint)),
					},
					"name": {
						Decoder: "plain",
						Value:   []byte(statRes.Info.Path),
					},
					"protocol": {
						Decoder: "plain",
						Value:   []byte("datatx"),
					},
					"size": {
						Decoder: "plain",
						Value:   []byte("60000000"),
					},
				},
			},

Next we add the size as an option of the protocol section of the OCM share request:

protocol := map[string]interface{}{

		protocol := map[string]interface{}{
			"name": "webdav",
			"options": map[string]string{
				"permissions": pm,
				"token":       ctxpkg.ContextMustGetToken(ctx),
				"size": size,
			},
		}

And the datatx driver will be called specifying the size in a new options parameter:

StartTransfer(ctx context.Context, srcRemote string, srcPath string, srcToken string, destRemote string, destPath string, destToken string) (*datatx.TxInfo, error)

type Manager interface {
	// StartTransfer initiates a transfer job and returns a TxInfo object including a unique transfer id, and error if any.
	StartTransfer(
		ctx context.Context, 
		srcRemote string, 
		srcPath string, 
		srcToken string, 
		destRemote string, 
		destPath string, 
		destToken string, 
		options map[string]interface{}) (*datatx.TxInfo, error)
	...

In the driver implementation the decision to cap on size is based on the value of 2 new datatx config flags:

# if true and size option (set in bytes) is specified in the received datatx type share, the transfer will stop if that size has been reached
limit_transfer = true/false
# will stop the transfer if max_transfer_size (set in bytes) has been reached and limit_transfer is set to true
max_transfer_size = 60000000
@redblom
Copy link
Contributor Author

redblom commented May 4, 2023

@glpatcern @michielbdejong @gmgigi96 do we regard discovering the size of the transfer a task of reva or the efss ? (ps. I know its a required field, but are we aiming to keep reva as light as possible in that regard or spare the efss ?)

@glpatcern
Copy link
Member

@redblom well someone would have to traverse the tree to be sent out and execute du on it: if it is the Reva gateway implementing the loop, the Reva storage providers (and the underlying EFSSs) have no extra requirement as it will just be a bunch of stat calls. Otherwise, each storage provider (or ultimately the EFSS? but there's no such functionality via WebDAV AFAIK) would have to implement such a discovery.

I'd implement it in the Reva gateway, factored out for everyone.

@redblom
Copy link
Contributor Author

redblom commented May 19, 2023

Implemented with #3891

@redblom redblom closed this as completed May 19, 2023
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

No branches or pull requests

2 participants