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

CLDSRV-498 Handling isNull master version with no versionId #5526

Merged
merged 1 commit into from
Feb 21, 2024
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
2 changes: 1 addition & 1 deletion lib/api/apiUtils/object/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function processVersioningState(mst, vstat) {
options.versioning = true;
if (mst.exists) {
// store master version in a new key
const versionId = mst.isNull ? mst.versionId : nonVersionedObjId;
const versionId = (mst.isNull && mst.versionId) ? mst.versionId : nonVersionedObjId;
storeOptions.versionId = versionId;
storeOptions.isNull = true;
options.nullVersionId = versionId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,73 @@ describeSkipIfAWS('backbeat routes for replication', () => {
return done();
});
});

it('should successfully put object after replicating a null version', done => {
let objMD;
let expectedVersionId;

async.series({
putObjectSource: next => s3.putObject(
{ Bucket: bucketSource, Key: keyName, Body: Buffer.from(testData) }, next),
enableVersioningSource: next => s3.putBucketVersioning(
{ Bucket: bucketSource, VersioningConfiguration: { Status: 'Enabled' } }, next),
enableVersioningDestination: next => s3.putBucketVersioning(
{ Bucket: bucketDestination, VersioningConfiguration: { Status: 'Enabled' } }, next),
getMetadata: next => makeBackbeatRequest({
method: 'GET',
resourceType: 'metadata',
bucket: bucketSource,
objectKey: keyName,
queryObj: {
versionId: 'null',
},
authCredentials: backbeatAuthCredentials,
}, (err, data) => {
if (err) {
return next(err);
}
objMD = JSON.parse(data.body).Body;
return next();
}),
replicateMetadata: next => makeBackbeatRequest({
method: 'PUT',
resourceType: 'metadata',
bucket: bucketDestination,
objectKey: keyName,
queryObj: {
versionId: 'null',
},
authCredentials: backbeatAuthCredentials,
requestBody: objMD,
}, next),
putObjectDestination: next => s3.putObject(
{ Bucket: bucketDestination, Key: keyName, Body: Buffer.from(testData) }, (err, data) => {
if (err) {
return next(err);
}
expectedVersionId = data.VersionId;
return next();
}),
headObject: next => s3.headObject({ Bucket: bucketDestination, Key: keyName, VersionId: 'null' }, next),
listObjectVersions: next => s3.listObjectVersions({ Bucket: bucketDestination }, next),
}, (err, results) => {
if (err) {
return done(err);
}

const headObjectRes = results.headObject;
assert.strictEqual(headObjectRes.VersionId, 'null');

const listObjectVersionsRes = results.listObjectVersions;
const { Versions } = listObjectVersionsRes;

assert.strictEqual(Versions.length, 2);

const [currentVersion, nonCurrentVersion] = Versions;
assert.strictEqual(currentVersion.VersionId, expectedVersionId);
assert.strictEqual(nonCurrentVersion.VersionId, 'null');

return done();
});
});
});
Loading