Compare commits

...

1 Commits

Author SHA1 Message Date
Francois Ferrand 547a700611
Try to remove default replication endpoint Issue
Issue: ARTESCA-4350
2022-05-20 09:35:06 +02:00
3 changed files with 14 additions and 9 deletions

View File

@ -560,12 +560,12 @@ class Config extends EventEmitter {
const { replicationEndpoints } = config; const { replicationEndpoints } = config;
assert(replicationEndpoints instanceof Array, 'bad config: ' + assert(replicationEndpoints instanceof Array, 'bad config: ' +
'`replicationEndpoints` property must be an array'); '`replicationEndpoints` property must be an array');
if (replicationEndpoints.length > 1) { // if (replicationEndpoints.length > 1) {
const hasDefault = replicationEndpoints.some( // const hasDefault = replicationEndpoints.some(
replicationEndpoint => replicationEndpoint.default); // replicationEndpoint => replicationEndpoint.default);
assert(hasDefault, 'bad config: `replicationEndpoints` must ' + // assert(hasDefault, 'bad config: `replicationEndpoints` must ' +
'contain a default endpoint'); // 'contain a default endpoint');
} // }
replicationEndpoints.forEach(replicationEndpoint => { replicationEndpoints.forEach(replicationEndpoint => {
assert.strictEqual(typeof replicationEndpoint, 'object', assert.strictEqual(typeof replicationEndpoint, 'object',
'bad config: `replicationEndpoints` property must be an ' + 'bad config: `replicationEndpoints` property must be an ' +

View File

@ -23,12 +23,12 @@ function _getStorageClasses(rule) {
} }
const { replicationEndpoints } = s3config; const { replicationEndpoints } = s3config;
// If no storage class, use the given default endpoint or the sole endpoint // If no storage class, use the given default endpoint or the sole endpoint
if (replicationEndpoints.length > 1) { if (replicationEndpoints.length > 0) {
const endPoint = const endPoint =
replicationEndpoints.find(endpoint => endpoint.default); replicationEndpoints.find(endpoint => endpoint.default) || replicationEndpoints[0];
return [endPoint.site]; return [endPoint.site];
} }
return [replicationEndpoints[0].site]; return undefined;
} }
function _getReplicationInfo(rule, replicationConfig, content, operationType, function _getReplicationInfo(rule, replicationConfig, content, operationType,
@ -36,6 +36,9 @@ function _getReplicationInfo(rule, replicationConfig, content, operationType,
const storageTypes = []; const storageTypes = [];
const backends = []; const backends = [];
const storageClasses = _getStorageClasses(rule); const storageClasses = _getStorageClasses(rule);
if (!storageClasses) {
return undefined;
}
storageClasses.forEach(storageClass => { storageClasses.forEach(storageClass => {
const storageClassName = const storageClassName =
storageClass.endsWith(':preferred_read') ? storageClass.endsWith(':preferred_read') ?

View File

@ -278,6 +278,8 @@ describe('Replication object MD without bucket replication config', () => {
}); });
[true, false].forEach(hasStorageClass => { [true, false].forEach(hasStorageClass => {
// this may break....
// or need to add a test where there is no default entry in config--->which should fail indeed...
describe('Replication object MD with bucket replication config ' + describe('Replication object MD with bucket replication config ' +
`${hasStorageClass ? 'with' : 'without'} storage class`, () => { `${hasStorageClass ? 'with' : 'without'} storage class`, () => {
const replicationMD = { const replicationMD = {