Skip to content

Commit

Permalink
Add versionId user-metadata when restoring OOB object
Browse files Browse the repository at this point in the history
When restoring to OOB bucket, we cannot force the versionId of the object written to the
backend, and it is thus not match the versionId of the ingested object. Thus we add extra
user metadata to allow OOB to allow ingestion processor to "match" the (new) restored
object with the existing ingested object.

Issue: CLDSRV-563
  • Loading branch information
francoisferrand committed Oct 15, 2024
1 parent bce42c8 commit f2f6275
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/api/apiUtils/object/createAndStoreObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ function createAndStoreObject(bucketName, bucketMD, objectKey, objMD, authInfo,
metadataStoreParams.oldReplayId = objMD.uploadId;
}

if (isPutVersion && location === bucketMD.getLocationConstraint() && bucketMD.isIngestionBucket()) {
// When restoring to OOB bucket, we cannot force the versionId of the object written to the
// backend, and it is thus not match the versionId of the ingested object. Thus we add extra
// user metadata to allow OOB to allow ingestion processor to "match" the (new) restored
// object with the existing ingested object.
objectKeyContext.metaHeaders = {
...objectKeyContext.metaHeaders,
'x-amz-meta-scal-version-id': putVersionId,
'x-amz-meta-scal-restore-info': objMD['x-scal-restore-info'],
};
}

/* eslint-disable camelcase */
const dontSkipBackend = externalBackends;
/* eslint-enable camelcase */
Expand Down
15 changes: 15 additions & 0 deletions lib/api/initiateMultipartUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@ function initiateMultipartUpload(authInfo, request, log, callback) {
destinationBucket,
tagging,
};

// TODO: implement the following code (but we don't have access to the object MD at this
// point, but we know it's versionID)
// if (isPutVersion && location === bucketMD.getLocationConstraint() && bucketMD.isIngestionBucket()) {
// // When restoring to OOB bucket, we cannot force the versionId of the object written to the
// // backend, and it is thus not match the versionId of the ingested object. Thus we add extra
// // user metadata to allow OOB to allow ingestion processor to "match" the (new) restored
// // object with the existing ingested object.
// objectKeyContext.metaHeaders = {
// ...objectKeyContext.metaHeaders,
// 'x-amz-meta-scal-version-id': putVersionId,
// 'x-amz-meta-scal-restore-info': objMD['x-scal-restore-info'],
// };
// }

return data.initiateMPU(mpuInfo, websiteRedirectHeader, log,
(err, dataBackendResObj, isVersionedObj) => {
// will return as true and a custom error if external backend does
Expand Down

0 comments on commit f2f6275

Please sign in to comment.