Skip to content
Draft
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
46 changes: 36 additions & 10 deletions lib/metadata/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,43 @@ const acl = {
objectMD.acl = addACLParams;
objectMD.originOp = 's3:ObjectAcl:Put';

// Use storageType to determine if replication update is needed, as it is set only for
// "cloud" locations. This ensures that we reset replication when CRR is used, but not
// when multi-backend replication (i.e. Zenko) is used.
// TODO: this should be refactored to properly update the replication info, accounting
// for multiple rules and resetting the status only if needed CLDSRV-646
const replicationInfo = getReplicationInfo(config, objectKey, bucket, true);
if (replicationInfo && !replicationInfo.storageType) {
objectMD.replicationInfo = {
...objectMD.replicationInfo,
...replicationInfo,
};

// Split the storageClass and iterate over each one
if (replicationInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not seem the right place to do this:

  • it is the goal of _getReplicationInfo to build the replication info
  • that function is already doing the parsing/splitting of storageClasses, and associated locationConstrainsts
  • the last param to getReplicationInfo indicates this is a MD-only operation (which currently should be replicated only to CRR), so this can be used deeper (currently this gets obfuscated in getReplicationInfo by converting it to const content = isMD || objSize === 0 ? ['METADATA'] : ['DATA', 'METADATA'], but this may be moved to _getReplicationInfo)

const storageClasses = replicationInfo.storageClass ? replicationInfo.storageClass.split(',') : [];
const crrStorageClasses = [];
const crrBackends = [];

// Iterate over each storage class and check isCRR
storageClasses.forEach((storageClass, index) => {
const trimmedStorageClass = storageClass.trim();
if (config.locationConstraints &&
config.locationConstraints[trimmedStorageClass] &&
config.locationConstraints[trimmedStorageClass].isCRR) {
// This storage class has CRR enabled, include it
crrStorageClasses.push(trimmedStorageClass);

// Include corresponding backend if it exists
if (replicationInfo.backends && replicationInfo.backends[index]) {
crrBackends.push(replicationInfo.backends[index]);
}
}
});

// Only set replication info for storage classes that have isCRR = true
if (crrStorageClasses.length > 0) {
const filteredReplicationInfo = {
...replicationInfo,
storageClass: crrStorageClasses.join(','),
backends: crrBackends
};

objectMD.replicationInfo = {
...objectMD.replicationInfo,
...filteredReplicationInfo,
};
}
}

return metadata.putObjectMD(bucket.getName(), objectKey, objectMD, params, log, cb);
Expand Down
1 change: 1 addition & 0 deletions tests/unit/api/objectReplicationMD.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ describe('Replication object MD without bucket replication config', () => {
config.locationConstraints['zenko'] = {
...config.locationConstraints['zenko'],
type: '',
isCRR: true,
};

async.series([
Expand Down
Loading