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

More Async Upload Fixes #3571

Merged
merged 3 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion changelog/unreleased/async-uploads-improvements.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Enhancement: Async Upload Improvements

Collection of smaller fixes and quality of life improvements for async postprocessing, especially the upload part.
Contains unit tests, 0 byte uploads, adjusted endpoint responses and more
Contains unit tests, 0 byte uploads, adjusted endpoint responses and more. Adjust mtime when requested from upload.
Add etag to upload info.

https://github.com/cs3org/reva/pull/3556

https://github.com/cs3org/reva/pull/3571
14 changes: 14 additions & 0 deletions pkg/storage/utils/decomposedfs/upload/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ func CreateNodeForUpload(upload *Upload, initAttrs map[string]string) (*node.Nod
return nil, errors.Wrap(err, "Decomposedfs: could not write metadata")
}

// overwrite mtime if requested
if upload.Info.MetaData["mtime"] != "" {
if err := n.SetMtimeString(upload.Info.MetaData["mtime"]); err != nil {
return nil, err
}
}

// add etag to metadata
nfi, err := os.Stat(n.InternalPath())
if err != nil {
return nil, err
}
upload.Info.MetaData["etag"], _ = node.CalculateEtag(n.ID, nfi.ModTime())

// update nodeid for later
upload.Info.Storage["NodeId"] = n.ID
if err := upload.writeInfo(); err != nil {
Expand Down
43 changes: 7 additions & 36 deletions pkg/storage/utils/decomposedfs/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,13 @@ func (upload *Upload) FinishUpload(_ context.Context) error {
}
}

if upload.async {
// handle postprocessing asynchronously but inform there is something in progress
return upload.tp.Propagate(upload.Ctx, n, upload.sizeDiff)
Copy link
Member

Choose a reason for hiding this comment

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

not needed anymore? where do we propagate now?

Copy link
Contributor Author

@kobergj kobergj Dec 29, 2022

Choose a reason for hiding this comment

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

We still propagate. I just switched the code parts so we need to call to upload.tp.Propagate only once

}

err = upload.Finalize()
Cleanup(upload, err != nil, false)
if err != nil {
return err
if !upload.async {
// handle postprocessing synchronously
err = upload.Finalize()
Cleanup(upload, err != nil, false)
if err != nil {
return err
}
}

return upload.tp.Propagate(upload.Ctx, n, upload.sizeDiff)
Expand Down Expand Up @@ -347,33 +345,6 @@ func (upload *Upload) Finalize() (err error) {
return errors.Wrap(err, "failed to upload file to blostore")
}

if upload.async {
return nil
}

sublog := appctx.GetLogger(upload.Ctx).
With().
Interface("info", upload.Info).
Str("binPath", upload.binPath).
Str("targetPath", n.InternalPath()).
Str("spaceID", upload.Info.Storage["SpaceRoot"]).
Logger()

// tests sometimes set the mtime
if upload.Info.MetaData["mtime"] != "" {
if err := n.SetMtimeString(upload.Info.MetaData["mtime"]); err != nil {
sublog.Err(err).Interface("info", upload.Info).Msg("Decomposedfs: could not set mtime metadata")
return err
}
}

// some clients need the etag in the upload metadata
fi, err := os.Stat(n.InternalPath())
if err != nil {
sublog.Err(err).Interface("info", upload.Info).Str("path", n.InternalPath()).Msg("Decomposedfs: could not stat file")
return err
}
upload.Info.MetaData["etag"], _ = node.CalculateEtag(n.ID, fi.ModTime())
return nil
}

Expand Down