-
Notifications
You must be signed in to change notification settings - Fork 343
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
refactor(general): Increase restore progress granularity #3655
refactor(general): Increase restore progress granularity #3655
Conversation
@KastenMike @julio-lopez could you please review ? |
repo/object/object_reader.go
Outdated
@@ -35,6 +35,10 @@ func VerifyObject(ctx context.Context, cr contentReader, oid ID) ([]content.ID, | |||
return tracker.contentIDs(), nil | |||
} | |||
|
|||
// FileReadingProgressCallback is a callback intended to be used during file copying | |||
// to report amount of data sent to destination. | |||
type FileReadingProgressCallback func(chunkSize int64) |
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.
why do we need to change object reader at all, can't we just emit the progress as we're reading the bytes during restore?
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.
this does not seem used anywhere, the rest looks good
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3655 +/- ##
==========================================
+ Coverage 75.86% 77.18% +1.31%
==========================================
Files 470 479 +9
Lines 37301 28756 -8545
==========================================
- Hits 28299 22194 -6105
+ Misses 7071 4660 -2411
+ Partials 1931 1902 -29 ☔ View full report in Codecov by Sentry. |
snapshot/restore/local_fs_output.go
Outdated
@@ -403,6 +404,14 @@ func (o *FilesystemOutput) copyFileContent(ctx context.Context, targetPath strin | |||
} | |||
defer r.Close() //nolint:errcheck | |||
|
|||
type withProgressTracking interface { |
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 think it's easier to wrap "r" so that it reports bytes written in the callback.
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.
Thank you for the idea, I've changed the code, is it what you meant ?
@jkowalski do you think the changes could be merged ? Or something else has to be done before ? |
Don't want to be annoying, just a friendly reminder :) |
@jkowalski @redgoat650 @julio-lopez could you please check this PR? |
} | ||
|
||
return write(targetPath, r, f.Size(), o.copier) | ||
return write(targetPath, wr, f.Size(), o.copier) |
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.
@e-sumin Question about the progress reporting using the reader tracking mechanism:
What is the best way to evaluate progress, as in the definition of done on processing X bytes ? When we have read X bytes from the reader does that mean we are done writing X bytes to the target ? In other words, would it be possible to get in a scenario where we have read 100% of the data from repository and are still stuck writing the final block due to a network issue (NFS) or similar ?
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.
That's true, but this way of progress update was chosen because it is less intrusive. Also, when reading, usually, the block is very small in comparison with total amount of data. So, we, anyway, can get 100% earlier than last block will be read. So, I'd not consider this as critical flaw.
bytesWritten := int64(0) | ||
progressCallback := func(chunkSize int64) { | ||
bytesWritten += chunkSize | ||
c.stats.RestoredTotalFileSize.Add(chunkSize) |
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.
nit; this callback is hit each time we have read chunkSize
from the repository, not necessarily "bytes written". Is that correct ? This is w.r.t. to the my other comment as well.
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.
Yes, that's correct. This progress calculation way treats bytes read as bytes written.
Wrapping is not needed while we are just proxifying requests.
I did some refactoring of snapshot restore:
Some of changes I've done was done to be able to have an unit test which verifies that progress is reported properly. |
I've fixed the test and merged master into my branch. The tests should pass now. |
|
||
// Progress is invoked by copier to report status of snapshot restoration. | ||
type Progress interface { | ||
SetCounters( |
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.
Too late to comment here, but I believe having an args struct would be better.
When restoring huge file(s), the progress reporting is done in a bit weird way:
In fact, the amount of restored data is dumped when particular file completely restored.
This PR contains the least invasive change, which allows us to see progress update while file is downloaded from object storage.