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;
assert(replicationEndpoints instanceof Array, 'bad config: ' +
'`replicationEndpoints` property must be an array');
if (replicationEndpoints.length > 1) {
const hasDefault = replicationEndpoints.some(
replicationEndpoint => replicationEndpoint.default);
assert(hasDefault, 'bad config: `replicationEndpoints` must ' +
'contain a default endpoint');
}
// if (replicationEndpoints.length > 1) {
// const hasDefault = replicationEndpoints.some(
// replicationEndpoint => replicationEndpoint.default);
// assert(hasDefault, 'bad config: `replicationEndpoints` must ' +
// 'contain a default endpoint');
// }
replicationEndpoints.forEach(replicationEndpoint => {
assert.strictEqual(typeof replicationEndpoint, 'object',
'bad config: `replicationEndpoints` property must be an ' +

View File

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

View File

@ -278,6 +278,8 @@ describe('Replication object MD without bucket replication config', () => {
});
[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 ' +
`${hasStorageClass ? 'with' : 'without'} storage class`, () => {
const replicationMD = {