Compare commits

...

1 Commits

Author SHA1 Message Date
Nicolas Humbert c0f6aa0f23 dataStoreName 2023-03-31 15:46:05 -04:00
4 changed files with 51 additions and 25 deletions

View File

@ -20,15 +20,16 @@ function handleResult(listParams, requestMaxKeys, authInfo,
/** /**
* listLifecycleCurrents - Return list of current versions/masters in bucket * listLifecycleCurrents - Return list of current versions/masters in bucket
* @param {AuthInfo} authInfo - Instance of AuthInfo class with * @param {AuthInfo} authInfo - Instance of AuthInfo class with
* requester's info * requester's info
* @param {object} request - http request object * @param {array} locationConstraints - array of location contraint
* @param {function} log - Werelogs request logger * @param {object} request - http request object
* @param {function} callback - callback to respond to http request * @param {function} log - Werelogs request logger
* with either error code or xml response body * @param {function} callback - callback to respond to http request
* with either error code or xml response body
* @return {undefined} * @return {undefined}
*/ */
function listLifecycleCurrents(authInfo, request, log, callback) { function listLifecycleCurrents(authInfo, locationConstraints, request, log, callback) {
const params = request.query; const params = request.query;
const bucketName = request.bucketName; const bucketName = request.bucketName;
@ -37,11 +38,21 @@ function listLifecycleCurrents(authInfo, request, log, callback) {
Number.parseInt(params['max-keys'], 10) : 1000; Number.parseInt(params['max-keys'], 10) : 1000;
if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) { if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) {
monitoring.promMetrics( monitoring.promMetrics(
'GET', bucketName, 400, 'listBucket'); 'GET', bucketName, 400, 'listLifecycleCurrents');
return callback(errors.InvalidArgument); return callback(errors.InvalidArgument);
} }
const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys); const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys);
const excludedDataStoreName = params['excluded-data-store-name'];
if (excludedDataStoreName && !locationConstraints[excludedDataStoreName]) {
const errMsg = 'value of the location you are attempting to set - ' +
`${excludedDataStoreName} - is not listed in the ` +
'locationConstraint config';
log.error(`locationConstraint is invalid - ${errMsg}`, { locationConstraint: excludedDataStoreName });
monitoring.promMetrics('GET', bucketName, 400, 'listLifecycleCurrents');
return callback(errors.InvalidLocationConstraint.customizeDescription(errMsg));
}
const metadataValParams = { const metadataValParams = {
authInfo, authInfo,
bucketName, bucketName,
@ -54,6 +65,7 @@ function listLifecycleCurrents(authInfo, request, log, callback) {
prefix: params.prefix, prefix: params.prefix,
beforeDate: params['before-date'], beforeDate: params['before-date'],
marker: params.marker, marker: params.marker,
excludedDataStoreName,
}; };
return metadataValidateBucket(metadataValParams, log, err => { return metadataValidateBucket(metadataValParams, log, err => {

View File

@ -20,15 +20,16 @@ function handleResult(listParams, requestMaxKeys, authInfo,
/** /**
* listLifecycleNonCurrents - Return list of non-current versions in bucket * listLifecycleNonCurrents - Return list of non-current versions in bucket
* @param {AuthInfo} authInfo - Instance of AuthInfo class with * @param {AuthInfo} authInfo - Instance of AuthInfo class with
* requester's info * requester's info
* @param {object} request - http request object * @param {array} locationConstraints - array of location contraint
* @param {function} log - Werelogs request logger * @param {object} request - http request object
* @param {function} callback - callback to respond to http request * @param {function} log - Werelogs request logger
* with either error code or xml response body * @param {function} callback - callback to respond to http request
* with either error code or xml response body
* @return {undefined} * @return {undefined}
*/ */
function listLifecycleNonCurrents(authInfo, request, log, callback) { function listLifecycleNonCurrents(authInfo, locationConstraints, request, log, callback) {
const params = request.query; const params = request.query;
const bucketName = request.bucketName; const bucketName = request.bucketName;
@ -37,11 +38,21 @@ function listLifecycleNonCurrents(authInfo, request, log, callback) {
Number.parseInt(params['max-keys'], 10) : 1000; Number.parseInt(params['max-keys'], 10) : 1000;
if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) { if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) {
monitoring.promMetrics( monitoring.promMetrics(
'GET', bucketName, 400, 'listBucket'); 'GET', bucketName, 400, 'listLifecycleNonCurrents');
return callback(errors.InvalidArgument); return callback(errors.InvalidArgument);
} }
const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys); const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys);
const excludedDataStoreName = params['excluded-data-store-name'];
if (excludedDataStoreName && !locationConstraints[excludedDataStoreName]) {
const errMsg = 'value of the location you are attempting to set - ' +
`${excludedDataStoreName} - is not listed in the ` +
'locationConstraint config';
log.error(`locationConstraint is invalid - ${errMsg}`, { locationConstraint: excludedDataStoreName });
monitoring.promMetrics('GET', bucketName, 400, 'listLifecycleCurrents');
return callback(errors.InvalidLocationConstraint.customizeDescription(errMsg));
}
const metadataValParams = { const metadataValParams = {
authInfo, authInfo,
bucketName, bucketName,
@ -54,6 +65,7 @@ function listLifecycleNonCurrents(authInfo, request, log, callback) {
prefix: params.prefix, prefix: params.prefix,
beforeDate: params['before-date'], beforeDate: params['before-date'],
keyMarker: params['key-marker'], keyMarker: params['key-marker'],
excludedDataStoreName,
}; };
listParams.versionIdMarker = params['version-id-marker'] ? listParams.versionIdMarker = params['version-id-marker'] ?

View File

@ -19,15 +19,16 @@ function handleResult(listParams, requestMaxKeys, authInfo,
/** /**
* listLifecycleOrphanDeleteMarkers - Return list of expired object delete marker in bucket * listLifecycleOrphanDeleteMarkers - Return list of expired object delete marker in bucket
* @param {AuthInfo} authInfo - Instance of AuthInfo class with * @param {AuthInfo} authInfo - Instance of AuthInfo class with
* requester's info * requester's info
* @param {object} request - http request object * @param {array} locationConstraints - array of location contraint
* @param {function} log - Werelogs request logger * @param {object} request - http request object
* @param {function} callback - callback to respond to http request * @param {function} log - Werelogs request logger
* with either error code or xml response body * @param {function} callback - callback to respond to http request
* with either error code or xml response body
* @return {undefined} * @return {undefined}
*/ */
function listLifecycleOrphanDeleteMarkers(authInfo, request, log, callback) { function listLifecycleOrphanDeleteMarkers(authInfo, locationConstraints, request, log, callback) {
const params = request.query; const params = request.query;
const bucketName = request.bucketName; const bucketName = request.bucketName;
@ -36,7 +37,7 @@ function listLifecycleOrphanDeleteMarkers(authInfo, request, log, callback) {
Number.parseInt(params['max-keys'], 10) : 1000; Number.parseInt(params['max-keys'], 10) : 1000;
if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) { if (Number.isNaN(requestMaxKeys) || requestMaxKeys < 0) {
monitoring.promMetrics( monitoring.promMetrics(
'GET', bucketName, 400, 'listBucket'); 'GET', bucketName, 400, 'listLifecycleOrphanDeleteMarkers');
return callback(errors.InvalidArgument); return callback(errors.InvalidArgument);
} }
const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys); const actualMaxKeys = Math.min(constants.listingHardLimit, requestMaxKeys);

View File

@ -505,6 +505,7 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
} }
log.trace('putting object version', { log.trace('putting object version', {
objectKey: request.objectKey, omVal, options }); objectKey: request.objectKey, omVal, options });
console.log('bucketName, objectKey, omVal, options!!!', bucketName, objectKey, omVal, options);
return metadata.putObjectMD(bucketName, objectKey, omVal, options, log, return metadata.putObjectMD(bucketName, objectKey, omVal, options, log,
(err, md) => { (err, md) => {
if (err) { if (err) {
@ -1105,7 +1106,7 @@ function listLifecycle(request, response, userInfo, log, cb) {
return cb(errors.BadRequest.customizeDescription(errMessage)); return cb(errors.BadRequest.customizeDescription(errMessage));
} }
return call(userInfo, request, log, (err, data) => { return call(userInfo, locationConstraints, request, log, (err, data) => {
if (err) { if (err) {
log.error(`error during listing objects for lifecycle: ${listType}`, { log.error(`error during listing objects for lifecycle: ${listType}`, {
error: err, error: err,