Skip to content

Commit

Permalink
bf(CLDSRV-250): Set replication status to PENDING when putting an ACL
Browse files Browse the repository at this point in the history
Rollback objectPutACL changes from - feature: CLDSRV-162 use metadata and data from new arsenal fbd68e6
  • Loading branch information
tmacro committed Jul 26, 2022
1 parent b2ad4df commit 885315b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
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
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

0 comments on commit 885315b

Please sign in to comment.