-
Notifications
You must be signed in to change notification settings - Fork 257
CLDSRV-925: UploadPartCopy handle checksums #6188
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
Open
leif-scality
wants to merge
10
commits into
development/9.4
Choose a base branch
from
improvement/CLDSRV-925-uploadpartcopy-checksums
base: development/9.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4f1c64b
CLDSRV-925: fix UploadPart returns default checksums breaking SDK's t…
leif-scality d8b98f6
CLDSRV-925: fix CopyObject allow in-place checksum change on self-copy
leif-scality 0fef152
CLDSRV-925: fix reject Parts missing a COMPOSITE checksum when required
leif-scality 2a265f9
CLDSRV-925: extract computeChecksumFromDataLocator from CopyObject
leif-scality bfeb7ab
CLDSRV-925: add checksum to metadataStorePart
leif-scality 3d9f7b1
CLDSRV-925: UploadPartCopy handle checksums
leif-scality ce95c12
CLDSRV-925: UploadPartCopy handle checksums functional tests
leif-scality f7a9bfb
CLDSRV-925: UploadPartCopy don't compute checksums for external backe…
leif-scality ffdfeb8
CLDSRV-925: CompleteMPU don't require per-part checksums for external…
leif-scality 967cc06
CLDSRV-925: fix leaked metadataBackend.deleteObject override in unit …
leif-scality File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| const { PassThrough } = require('stream'); | ||
| const async = require('async'); | ||
| const { jsutil } = require('arsenal'); | ||
|
|
||
| const { data } = require('../../../data/wrapper'); | ||
| const ChecksumWritable = require('../../../auth/streamingV4/ChecksumWritable'); | ||
|
|
||
| /** | ||
| * Sequentially GET the ordered source `dataLocator` parts into a single | ||
| * readable stream, reading them in order through `data.get`. Returns the | ||
| * PassThrough immediately; consumers should pipe it onward and observe | ||
| * `error` for any read failure along the way. | ||
| * | ||
| * @param {Array} dataLocator - ordered source parts | ||
| * @param {object} log - request logger | ||
| * @return {PassThrough} | ||
| */ | ||
| function buildSourcePartsStream(dataLocator, log) { | ||
| const passthrough = new PassThrough(); | ||
| const wrapErr = (err, part) => | ||
| Object.assign(err, { | ||
| copyPart: { key: part.key, dataStoreName: part.dataStoreName, dataStoreType: part.dataStoreType }, | ||
| }); | ||
| async.eachSeries( | ||
| dataLocator, | ||
| (part, cb) => { | ||
| const done = jsutil.once(cb); | ||
| if (part.dataStoreType === 'azure') { | ||
| // Azure's data.get writes part bytes into the provided writable | ||
| // instead of returning a Readable. Pipe a per-part PassThrough | ||
| // into the master passthrough and use its 'end' as the completion | ||
| // signal — same pattern arsenal's data.copyObject uses. | ||
| const perPart = new PassThrough(); | ||
| perPart.once('error', err => done(wrapErr(err, part))); | ||
| perPart.once('end', () => done()); | ||
| perPart.pipe(passthrough, { end: false }); | ||
| return data.get(part, perPart, log, err => { | ||
| if (err) { | ||
| perPart.destroy(err); | ||
| done(wrapErr(err, part)); | ||
| } | ||
| }); | ||
| } | ||
| return data.get(part, null, log, (err, partStream) => { | ||
| if (err) { | ||
| return done(wrapErr(err, part)); | ||
| } | ||
| partStream.once('error', err => done(wrapErr(err, part))); | ||
| partStream.once('end', () => done()); | ||
| partStream.pipe(passthrough, { end: false }); | ||
| return undefined; | ||
| }); | ||
| }, | ||
Check noticeCode scanning / CodeQL Callback-style function (async migration) Note
This function uses a callback parameter ('cb'). Refactor to async/await.
|
||
| err => { | ||
| if (err) { | ||
| passthrough.destroy(err); | ||
| } else { | ||
| passthrough.end(); | ||
| } | ||
| }, | ||
| ); | ||
| return passthrough; | ||
| } | ||
|
|
||
| /** | ||
| * Compute the checksum of the (range-adjusted) source bytes by streaming them | ||
| * through a ChecksumWritable sink. An empty `dataLocator` ends the stream | ||
| * immediately, yielding the empty-input digest. | ||
| * | ||
| * @param {Array} dataLocator - ordered source parts | ||
| * @param {string} algorithm - lowercase checksum algorithm name | ||
| * @param {object} log - request logger | ||
| * @param {function} cb - cb(err, { algorithm, value }) | ||
| * @return {undefined} | ||
| */ | ||
| function computeChecksumFromDataLocator(dataLocator, algorithm, log, cb) { | ||
| const onceCb = jsutil.once(cb); | ||
| const sourceStream = buildSourcePartsStream(dataLocator || [], log); | ||
| const checksumSink = new ChecksumWritable(algorithm, log); | ||
| sourceStream.once('error', err => { | ||
| checksumSink.destroy(err); | ||
| onceCb(err); | ||
| }); | ||
| checksumSink.once('error', onceCb); | ||
| checksumSink.once('finish', () => onceCb(null, { algorithm, value: checksumSink.digest })); | ||
| sourceStream.pipe(checksumSink); | ||
| } | ||
Check noticeCode scanning / CodeQL Callback-style function (async migration) Note
This function uses a callback parameter ('cb'). Refactor to async/await.
|
||
|
leif-scality marked this conversation as resolved.
|
||
|
|
||
| module.exports = { buildSourcePartsStream, computeChecksumFromDataLocator }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.