Skip to content

Improvement/cldsrv 646 #5853

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

Draft
wants to merge 2 commits into
base: development/9.1
Choose a base branch
from
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) {
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