-
Notifications
You must be signed in to change notification settings - Fork 23
Support per-backend role and destination in replication engine #2743
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
base: development/9.4
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ const { S3Client, GetBucketReplicationCommand, GetObjectCommand } = require('@aw | |
| const errors = require('arsenal').errors; | ||
| const jsutil = require('arsenal').jsutil; | ||
| const ObjectMDLocation = require('arsenal').models.ObjectMDLocation; | ||
| const ReplicationConfiguration = require('arsenal').models.ReplicationConfiguration; | ||
|
|
||
| const ClientManager = require('../../../lib/clients/ClientManager'); | ||
| const BackbeatMetadataProxy = require('../../../lib/BackbeatMetadataProxy'); | ||
|
|
@@ -227,7 +228,7 @@ class ReplicateObject extends BackbeatTask { | |
| _setupRolesOnce(entry, log, cb) { | ||
| log.debug('getting bucket replication', | ||
| { entry: entry.getLogInfo() }); | ||
| const entryRolesString = entry.getReplicationRoles(); | ||
| const entryRolesString = entry.getReplicationRoles(this.site); | ||
| let entryRoles; | ||
| if (entryRolesString !== undefined) { | ||
| entryRoles = entryRolesString.split(','); | ||
|
|
@@ -266,9 +267,9 @@ class ReplicateObject extends BackbeatTask { | |
| 'replication disabled for object')); | ||
| } | ||
| const roles = data.ReplicationConfiguration.Role.split(','); | ||
| if (roles.length !== 2) { | ||
| log.error('expecting two roles separated by a ' + | ||
| 'comma in bucket replication configuration', | ||
| if (roles.length < 1 || roles.length > 2) { | ||
| log.error('expecting one or two roles in bucket ' + | ||
| 'replication configuration', | ||
| { | ||
| method: 'ReplicateObject._setupRolesOnce', | ||
| entry: entry.getLogInfo(), | ||
|
|
@@ -287,18 +288,36 @@ class ReplicateObject extends BackbeatTask { | |
| }); | ||
| return cb(errors.BadRole); | ||
| } | ||
| if (roles[1] !== entryRoles[1]) { | ||
| // Multi-destination CRR: derive the expected destination | ||
| // role for this site from the matching rule's Account | ||
| // override; legacy configs without Account fall back to | ||
| // the literal two-comma role equality check. | ||
| const matchingRule = data.ReplicationConfiguration.Rules.find( | ||
| rule => rule.Status === 'Enabled' && | ||
| entry.getObjectKey().startsWith(rule.Prefix) && | ||
| rule.Destination && | ||
| rule.Destination.StorageClass === this.site); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
— Claude Code |
||
| let expectedDestRole; | ||
| if (matchingRule && matchingRule.Destination.Account) { | ||
| expectedDestRole = ReplicationConfiguration | ||
| .resolveDestinationRole( | ||
| data.ReplicationConfiguration.Role, | ||
| matchingRule.Destination.Account); | ||
| } else { | ||
| expectedDestRole = roles[1]; | ||
| } | ||
| if (expectedDestRole !== entryRoles[1]) { | ||
| log.error('role in replication entry for target does ' + | ||
| 'not match role in bucket replication configuration ', | ||
| { | ||
| method: 'ReplicateObject._setupRolesOnce', | ||
| entry: entry.getLogInfo(), | ||
| entryRole: entryRoles[1], | ||
| bucketRole: roles[1], | ||
| bucketRole: expectedDestRole, | ||
| }); | ||
| return cb(errors.BadRole); | ||
| } | ||
| return cb(null, roles[0], roles[1]); | ||
| return cb(null, entryRoles[0], entryRoles[1]); | ||
| }) | ||
| .catch(err => { | ||
| // eslint-disable-next-line no-param-reassign | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ | |
| "@scality/cloudserverclient": "^1.0.8", | ||
| "@smithy/node-http-handler": "^3.3.3", | ||
| "JSONStream": "^1.3.5", | ||
| "arsenal": "git+https://github.com/scality/arsenal#8.3.9", | ||
| "arsenal": "git+https://github.com/scality/arsenal#21b9bb33ad77d21609a690a5709a645eab1a95d7", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arsenal is pinned to a raw commit SHA instead of a tag. The yarn.lock resolves this to version |
||
| "async": "^2.3.0", | ||
| "backo": "^1.1.0", | ||
| "breakbeat": "scality/breakbeat#v1.0.3", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
roles.length < 1is unreachable —String.split(',')always returns at least one element (''.split(',')→['']). Could simplify toroles.length > 2.— Claude Code