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

bf(CLDSRV-250): Set replication status to PENDING when putting an ACL #4689

Merged
merged 2 commits into from
Jul 26, 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
7 changes: 7 additions & 0 deletions lib/metadata/acl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { errors } = require('arsenal');

const getReplicationInfo = require('../api/apiUtils/object/getReplicationInfo');
const aclUtils = require('../utilities/aclUtils');
const constants = require('../../constants');
const metadata = require('../metadata/wrapper');
Expand All @@ -16,6 +17,12 @@ const acl = {
log.trace('updating object acl in metadata');
// eslint-disable-next-line no-param-reassign
objectMD.acl = addACLParams;
const replicationInfo = getReplicationInfo(objectKey, bucket, true);
if (replicationInfo) {
// eslint-disable-next-line no-param-reassign
objectMD.replicationInfo = Object.assign({},
objectMD.replicationInfo, replicationInfo);
}
metadata.putObjectMD(bucket.getName(), objectKey, objectMD, params, log,
cb);
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "s3",
"version": "7.10.6",
"version": "7.10.7",
"description": "S3 connector",
"main": "index.js",
"engines": {
Expand Down
33 changes: 18 additions & 15 deletions tests/unit/api/objectReplicationMD.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,19 @@ describe('Replication object MD without bucket replication config', () => {
return done();
}));

it("should update status to 'PENDING' and content to '['METADATA']' " +
'if putting object ACL', done =>
async.series([
next => putObjectAndCheckMD(keyA, newReplicationMD, next),
next => objectPutACL(authInfo, objectACLReq, log, next),
], err => {
if (err) {
return done(err);
}
checkObjectReplicationInfo(keyA, replicateMetadataOnly);
return done();
}));

it('should update metadata if putting a delete marker', done =>
async.series([
next => putObjectAndCheckMD(keyA, newReplicationMD, err => {
Expand Down Expand Up @@ -534,29 +547,19 @@ describe('Replication object MD without bucket replication config', () => {
return done();
}));

it('should update on a put object ACL request', done => {
let completedReplicationInfo;
it('should update on a put object ACL request', done =>
async.series([
next => putObjectAndCheckMD(keyA,
expectedReplicationInfo, next),
next => {
const objectMD = metadata.keyMaps
.get(bucketName).get(keyA);
// Update metadata to a status after replication
// has occurred.
objectMD.replicationInfo.status = 'COMPLETED';
completedReplicationInfo = JSON.parse(
JSON.stringify(objectMD.replicationInfo));
objectPutACL(authInfo, objectACLReq, log, next);
},
next => objectPutACL(authInfo, objectACLReq, log, next),
], err => {
if (err) {
return done(err);
}
checkObjectReplicationInfo(keyA, completedReplicationInfo);
checkObjectReplicationInfo(keyA,
expectedReplicationInfoMD);
return done();
});
});
}));

it('should update on a put object tagging request', done =>
async.series([
Expand Down