Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function hdClientLocationConstraintAssert(configHd) {

function locationConstraintAssert(locationConstraints) {
const supportedBackends = [
'mem', 'file', 'scality', 'mongodb', 'tlp',
'mem', 'file', 'scality', 'mongodb', 'tlp', 'crr'
].concat(Object.keys(validExternalBackends));
assert(typeof locationConstraints === 'object',
'bad config: locationConstraints must be an object');
Expand Down
3 changes: 2 additions & 1 deletion lib/api/bucketPut.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ function checkLocationConstraint(request, locationConstraint, log) {
return { error: errorInstances.InvalidLocationConstraint.
customizeDescription(errMsg) };
}
if (locationConstraints[locationConstraintChecked].isCold) {
if (locationConstraints[locationConstraintChecked].isCold ||
Comment thread
francoisferrand marked this conversation as resolved.
locationConstraints[locationConstraintChecked].isCRR) {
return { error: errors.InvalidLocationConstraint };
}
if (locationConstraintAddon) {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/objectCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function _prepMetadata(request, sourceObjMD, headers, sourceIsDestination,
const backendInfoObjDest = locationConstraintCheck(request,
userMetadata, destBucketMD, log);
if (backendInfoObjDest.err) {
return { error: backendInfoObjSource.err };
return { error: backendInfoObjDest.err };
}
const destLocationConstraintName = backendInfoObjDest.controllingLC;

Expand Down
7 changes: 7 additions & 0 deletions locationConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,12 @@
"legacyAwsBehavior": false,
"isCold": true,
"details": {}
},
"location-crr-v1": {
"type": "crr",
"objectId": "location-crr-v1",
"legacyAwsBehavior": false,
"isCRR": true,
"details": {}
}
}
6 changes: 6 additions & 0 deletions tests/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const constants = {
LOCATION_NAME_DMF: 'location-dmf-v1',
LOCATION_NAME_CRR: 'location-crr-v1',
};

module.exports = constants;
6 changes: 5 additions & 1 deletion tests/functional/aws-node-sdk/test/bucket/getLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const withV4 = require('../support/withV4');
const BucketUtility = require('../../lib/utility/bucket-util');
const { config } = require('../../../../../lib/Config');

const {
LOCATION_NAME_DMF,
} = require('../../../../constants');

const bucketName = 'testgetlocationbucket';

const describeSkipAWS = process.env.AWS_ON_AIR ? describe.skip : describe;
Expand All @@ -22,7 +26,7 @@ describeSkipAWS('GET bucket location ', () => {
// see next test.
return;
}
if (location === 'location-dmf-v1') {
if (location === LOCATION_NAME_DMF) {
// if region location-dmf-v1 should return InvalidLocationConstraint error
return;
}
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/aws-node-sdk/test/bucket/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const getConfig = require('../support/config');
const withV4 = require('../support/withV4');
const configOfficial = require('../../../../../lib/Config').config;

const {
LOCATION_NAME_DMF,
} = require('../../../../constants');

const bucketName = 'bucketlocation';

const describeSkipAWS = process.env.AWS_ON_AIR ? describe.skip : describe;
Expand Down Expand Up @@ -268,7 +272,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
LocationConstraint: location,
},
}, err => {
if (location === 'location-dmf-v1') {
if (location === LOCATION_NAME_DMF) {
assert.strictEqual(
err.code,
'InvalidLocationConstraint'
Expand Down Expand Up @@ -304,7 +308,7 @@ describe('PUT Bucket - AWS.S3.createBucket', () => {
{
Bucket: bucketName,
CreateBucketConfiguration: {
LocationConstraint: 'location-dmf-v1',
LocationConstraint: LOCATION_NAME_DMF,
},
}, err => {
assert.strictEqual(
Expand Down
12 changes: 8 additions & 4 deletions tests/functional/aws-node-sdk/test/object/mpuVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const { DummyRequestLogger } = require('../../../../unit/helpers');
const checkError = require('../../lib/utility/checkError');
const { getMetadata, fakeMetadataArchive } = require('../utils/init');

const {
LOCATION_NAME_DMF,
} = require('../../../../constants');

const log = new DummyRequestLogger();

const bucketName = 'bucket1putversion33';
Expand Down Expand Up @@ -847,17 +851,17 @@ describe('MPU with x-scal-s3-version-id header', () => {
next => s3.listObjects({ Bucket: bucketName }, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.Contents.length, 1);
assert.strictEqual(res.Contents[0].StorageClass, 'location-dmf-v1');
assert.strictEqual(res.Contents[0].StorageClass, LOCATION_NAME_DMF);
return next();
}),
next => s3.headObject(params, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.StorageClass, 'location-dmf-v1');
assert.strictEqual(res.StorageClass, LOCATION_NAME_DMF);
return next();
}),
next => s3.getObject(params, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.StorageClass, 'location-dmf-v1');
assert.strictEqual(res.StorageClass, LOCATION_NAME_DMF);
return next();
}),
], err => {
Expand Down Expand Up @@ -957,7 +961,7 @@ describe('MPU with x-scal-s3-version-id header', () => {
return next(err);
}
/* eslint-disable no-param-reassign */
objMD.dataStoreName = 'location-dmf-v1';
objMD.dataStoreName = LOCATION_NAME_DMF;
objMD.archive = archive;
objMD.replicationInfo = replicationInfo;
// data related
Expand Down
14 changes: 9 additions & 5 deletions tests/functional/aws-node-sdk/test/object/putVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const { DummyRequestLogger } = require('../../../../unit/helpers');
const checkError = require('../../lib/utility/checkError');
const { getMetadata, fakeMetadataArchive } = require('../utils/init');

const {
LOCATION_NAME_DMF,
} = require('../../../../constants');

const log = new DummyRequestLogger();

const bucketName = 'bucket1putversion32';
Expand Down Expand Up @@ -753,24 +757,24 @@ describe('PUT object with x-scal-s3-version-id header', () => {
next => s3.listObjects({ Bucket: bucketName }, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.Contents.length, 1);
assert.strictEqual(res.Contents[0].StorageClass, 'location-dmf-v1');
assert.strictEqual(res.Contents[0].StorageClass, LOCATION_NAME_DMF);
return next();
}),
next => s3.headObject(params, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.StorageClass, 'location-dmf-v1');
assert.strictEqual(res.StorageClass, LOCATION_NAME_DMF);
return next();
}),
next => s3.getObject(params, (err, res) => {
assert.ifError(err);
assert.strictEqual(res.StorageClass, 'location-dmf-v1');
assert.strictEqual(res.StorageClass, LOCATION_NAME_DMF);
return next();
}),
], err => {
assert.strictEqual(err, null, `Expected success got error ${JSON.stringify(err)}`);

// storage class must stay as the cold location
assert.deepStrictEqual(objMDAfter['x-amz-storage-class'], 'location-dmf-v1');
assert.deepStrictEqual(objMDAfter['x-amz-storage-class'], LOCATION_NAME_DMF);

/// Make sure object data location is set back to its bucket data location.
assert.deepStrictEqual(objMDAfter.dataStoreName, 'us-east-1');
Expand Down Expand Up @@ -866,7 +870,7 @@ describe('PUT object with x-scal-s3-version-id header', () => {
return next(err);
}
/* eslint-disable no-param-reassign */
objMD.dataStoreName = 'location-dmf-v1';
objMD.dataStoreName = LOCATION_NAME_DMF;
objMD.archive = archive;
objMD.replicationInfo = replicationInfo;
// data related
Expand Down
8 changes: 6 additions & 2 deletions tests/functional/aws-node-sdk/test/utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const log = new DummyRequestLogger();
const nonVersionedObjId =
versionIdUtils.getInfVid(config.replicationGroupId);

const {
LOCATION_NAME_DMF,
} = require('../../../../constants');

function decodeVersionId(versionId) {
let decodedVersionId;
if (versionId) {
Expand Down Expand Up @@ -77,8 +81,8 @@ function fakeMetadataArchive(bucketName, objectName, versionId, archive, cb) {
return cb(err);
}
/* eslint-disable no-param-reassign */
objMD['x-amz-storage-class'] = 'location-dmf-v1';
objMD.dataStoreName = 'location-dmf-v1';
objMD['x-amz-storage-class'] = LOCATION_NAME_DMF;
objMD.dataStoreName = LOCATION_NAME_DMF;
objMD.archive = archive;
/* eslint-enable no-param-reassign */
return metadata.putObjectMD(bucketName, objectName, objMD, { versionId: decodeVersionId(versionId) },
Expand Down
7 changes: 7 additions & 0 deletions tests/locationConfig/locationConfigCeph.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,12 @@
"legacyAwsBehavior": false,
"isCold": true,
"details": {}
},
"location-crr-v1": {
"type": "crr",
"objectId": "location-crr-v1",
"legacyAwsBehavior": false,
"isCRR": true,
"details": {}
}
}
7 changes: 7 additions & 0 deletions tests/locationConfig/locationConfigLegacy.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,12 @@
"legacyAwsBehavior": false,
"isCold": true,
"details": {}
},
"location-crr-v1": {
"type": "crr",
"objectId": "location-crr-v1",
"legacyAwsBehavior": false,
"isCRR": true,
"details": {}
}
}
7 changes: 7 additions & 0 deletions tests/locationConfig/locationConfigTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,12 @@
"legacyAwsBehavior": false,
"isCold": true,
"details": {}
},
"location-crr-v1": {
"type": "crr",
"objectId": "location-crr-v1",
"legacyAwsBehavior": false,
"isCRR": true,
"details": {}
}
}
13 changes: 9 additions & 4 deletions tests/multipleBackend/backendHealthcheckResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const {
getAzureContainerName,
} = require('../functional/aws-node-sdk/test/multipleBackend/utils');

const {
LOCATION_NAME_DMF,
LOCATION_NAME_CRR,
} = require('../constants');

const log = new DummyRequestLogger();
const locConstraints = Object.keys(config.locationConstraints);
const azureClient = getAzureClient();
Expand All @@ -22,8 +27,8 @@ describe('Healthcheck response', () => {
clientCheck(true, log, (err, results) => {
const resultKeys = Object.keys(results);
locConstraints.forEach(constraint => {
if (constraint === 'location-dmf-v1') {
// FIXME: location-dmf-v1 is not in results, see CLDSRV-440
if (constraint === LOCATION_NAME_DMF || constraint === LOCATION_NAME_CRR) {
// FIXME: location-dmf-v1 and location-crr-v1 are not in results, see CLDSRV-440
Comment thread
welansari marked this conversation as resolved.
return;
}
assert(resultKeys.includes(constraint), `constraint: ${constraint} not in results: ${resultKeys}`);
Expand All @@ -45,8 +50,8 @@ describe('Healthcheck response', () => {
clientCheck(false, log, (err, results) => {
assert.notStrictEqual(results.length, locConstraints.length);
locConstraints.forEach(constraint => {
if (constraint === 'location-dmf-v1') {
// FIXME: location-dmf-v1 is not in results, see CLDSRV-440
if (constraint === LOCATION_NAME_DMF || constraint === LOCATION_NAME_CRR) {
// FIXME: location-dmf-v1 and location-crr-v1 are not in results, see CLDSRV-440
return;
}
if (Object.keys(results).indexOf(constraint) === -1) {
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const {
ConfigObject,
} = require('../../lib/Config');

const {
LOCATION_NAME_DMF,
} = require('../constants');

const { ValidLifecycleRules: supportedLifecycleRules } = require('arsenal').models;

describe('Config', () => {
Expand Down Expand Up @@ -276,7 +280,7 @@ describe('Config', () => {
'details': {},
'isCold': true,
'legacyAwsBehavior': false,
'locationType': 'location-dmf-v1',
'locationType': LOCATION_NAME_DMF,
'objectId': 'b9d9b632-5fa5-11ef-8715-b21941dbc3ea',
'type': 'tlp'
},
Expand All @@ -291,7 +295,7 @@ describe('Config', () => {
'details': {},
'isCold': false,
'legacyAwsBehavior': false,
'locationType': 'location-dmf-v1',
'locationType': LOCATION_NAME_DMF,
'objectId': 'b9d9b632-5fa5-11ef-8715-b21941dbc3ea',
'type': 'tlp'
},
Expand All @@ -308,7 +312,7 @@ describe('Config', () => {
},
'isCold': true,
'legacyAwsBehavior': false,
'locationType': 'location-dmf-v1',
'locationType': LOCATION_NAME_DMF,
'objectId': 'b9d9b632-5fa5-11ef-8715-b21941dbc3ea',
'type': 'tlp'
},
Expand Down
Loading
Loading