Compare commits

...

4 Commits

Author SHA1 Message Date
Naren f30414f385 request log 2022-07-27 14:14:27 -07:00
Naren 6c3919405a request log 2022-07-26 20:56:00 -07:00
Naren 59a65d584d request log 2022-07-26 14:42:37 -07:00
Naren dfa3626337 logs 2022-07-26 13:49:40 -07:00
3 changed files with 96 additions and 2 deletions

View File

@ -41,6 +41,10 @@ function getAmzRestoreResHeader(objMD) {
* @return {ArsenalError|undefined} - undefined if the conditions for RestoreObject are fulfilled * @return {ArsenalError|undefined} - undefined if the conditions for RestoreObject are fulfilled
*/ */
function _validateStartRestore(objectMD, log) { function _validateStartRestore(objectMD, log) {
log.info('calling _validateStartRestore', {
objectMD,
method: 'object-restore',
});
const isLocationCold = locationConstraints[objectMD.dataStoreName]?.isCold; const isLocationCold = locationConstraints[objectMD.dataStoreName]?.isCold;
if (!isLocationCold) { if (!isLocationCold) {
// return InvalidObjectState error if the object is not in cold storage, // return InvalidObjectState error if the object is not in cold storage,
@ -149,6 +153,11 @@ function isObjectAlreadyRestored(objectMD, log) {
* *
*/ */
function _updateRestoreInfo(objectMD, restoreParam, log) { function _updateRestoreInfo(objectMD, restoreParam, log) {
log.info('calling _updateRestoreInfo', {
objectMD,
restoreParam,
method: 'object-restore',
});
if (!objectMD.archive) { if (!objectMD.archive) {
log.debug('objectMD.archive doesn\'t exits', { log.debug('objectMD.archive doesn\'t exits', {
objectMD, objectMD,
@ -185,14 +194,31 @@ function _updateRestoreInfo(objectMD, restoreParam, log) {
* *
*/ */
function startRestore(objectMD, restoreParam, log, cb) { function startRestore(objectMD, restoreParam, log, cb) {
log.info('calling startRestore', {
objectMD,
restoreParam,
method: 'object-restore',
});
log.info('Validating if restore can be done or not.'); log.info('Validating if restore can be done or not.');
const checkResultError = _validateStartRestore(objectMD, log); const checkResultError = _validateStartRestore(objectMD, log);
if (checkResultError) { if (checkResultError) {
log.info('_validateStartRestore erro', {
objectMD,
restoreParam,
method: 'object-restore',
err: checkResultError,
});
return cb(checkResultError); return cb(checkResultError);
} }
log.info('Updating restore information.'); log.info('Updating restore information.');
const updateResultError = _updateRestoreInfo(objectMD, restoreParam, log); const updateResultError = _updateRestoreInfo(objectMD, restoreParam, log);
if (updateResultError) { if (updateResultError) {
log.info('_validateStartRestore erro', {
objectMD,
restoreParam,
method: 'object-restore',
err: updateResultError,
});
return cb(updateResultError); return cb(updateResultError);
} }
return cb(null, isObjectAlreadyRestored(objectMD, log)); return cb(null, isObjectAlreadyRestored(objectMD, log));

View File

@ -35,13 +35,21 @@ function checkTierSupported(restoreInfo) {
*/ */
function objectRestore(metadata, mdUtils, userInfo, request, log, callback) { function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
const METHOD = 'objectRestore'; const METHOD = 'objectRestore';
const mtd = 'object-restore';
const { bucketName, objectKey } = request; const { bucketName, objectKey } = request;
log.info('object restore called', {
method: mtd,
});
log.debug('processing request', { method: METHOD }); log.debug('processing request', { method: METHOD });
const decodedVidResult = decodeVersionId(request.query); const decodedVidResult = decodeVersionId(request.query);
if (decodedVidResult instanceof Error) { if (decodedVidResult instanceof Error) {
log.info('invalid versionid query', {
method: mtd,
request,
});
log.trace('invalid versionId query', log.trace('invalid versionId query',
{ {
method: METHOD, method: METHOD,
@ -66,12 +74,21 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
function validateBucketAndObject(next) { function validateBucketAndObject(next) {
return mdUtils.metadataValidateBucketAndObj(mdValueParams, log, (err, bucketMD, objectMD) => { return mdUtils.metadataValidateBucketAndObj(mdValueParams, log, (err, bucketMD, objectMD) => {
if (err) { if (err) {
log.info('metadata validate bucket and obj failed', {
method: mtd,
err,
});
log.trace('request authorization failed', { method: METHOD, error: err }); log.trace('request authorization failed', { method: METHOD, error: err });
return next(err); return next(err);
} }
// Call back error if object metadata could not be obtained // Call back error if object metadata could not be obtained
if (!objectMD) { if (!objectMD) {
const err = decodedVidResult ? errors.NoSuchVersion : errors.NoSuchKey; const err = decodedVidResult ? errors.NoSuchVersion : errors.NoSuchKey;
log.info('no object md', {
method: mtd,
bucket: bucketName,
key: objectKey,
});
log.trace('error no object metadata found', { method: METHOD, error: err }); log.trace('error no object metadata found', { method: METHOD, error: err });
return next(err, bucketMD); return next(err, bucketMD);
} }
@ -82,6 +99,12 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
if (decodedVidResult) { if (decodedVidResult) {
err = errors.MethodNotAllowed; err = errors.MethodNotAllowed;
} }
log.info('version is a delete marker', {
method: mtd,
bucket: bucketName,
key: objectKey,
err,
});
log.trace('version is a delete marker', { method: METHOD, error: err }); log.trace('version is a delete marker', { method: METHOD, error: err });
return next(err, bucketMD, objectMD); return next(err, bucketMD, objectMD);
} }
@ -97,11 +120,24 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
log.trace('parsing object restore information'); log.trace('parsing object restore information');
return parseRestoreRequestXml(request.post, log, (err, restoreInfo) => { return parseRestoreRequestXml(request.post, log, (err, restoreInfo) => {
if (err) { if (err) {
log.info('parse restore xml error', {
method: mtd,
bucket: bucketName,
key: objectKey,
err,
request: request.post,
});
return next(err, bucketMD, objectMD, restoreInfo); return next(err, bucketMD, objectMD, restoreInfo);
} }
log.info('it parsed xml of the request body.', { method: METHOD, value: restoreInfo }); log.info('it parsed xml of the request body.', { method: METHOD, value: restoreInfo });
const checkTierResult = checkTierSupported(restoreInfo); const checkTierResult = checkTierSupported(restoreInfo);
if (checkTierResult instanceof Error) { if (checkTierResult instanceof Error) {
log.info('tier error', {
method: mtd,
bucket: bucketName,
key: objectKey,
restoreInfo,
});
return next(checkTierResult); return next(checkTierResult);
} }
return next(null, bucketMD, objectMD, restoreInfo); return next(null, bucketMD, objectMD, restoreInfo);
@ -109,6 +145,11 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
}, },
// start restore process // start restore process
function startRestore(bucketMD, objectMD, restoreInfo, next) { function startRestore(bucketMD, objectMD, restoreInfo, next) {
log.info('calling startRestore', {
method: mtd,
bucket: bucketName,
key: objectKey,
});
return coldStorage.startRestore(objectMD, restoreInfo, log, return coldStorage.startRestore(objectMD, restoreInfo, log,
(err, _isObjectRestored) => { (err, _isObjectRestored) => {
isObjectRestored = _isObjectRestored; isObjectRestored = _isObjectRestored;
@ -117,14 +158,33 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
}, },
function updateObjectMD(bucketMD, objectMD, next) { function updateObjectMD(bucketMD, objectMD, next) {
const params = objectMD.versionId ? { versionId: objectMD.versionId } : {}; const params = objectMD.versionId ? { versionId: objectMD.versionId } : {};
log.info('calling updateObjectMD', {
method: mtd,
bucket: bucketName,
key: objectKey,
objMD: objectMD,
});
metadata.putObjectMD(bucketMD.getName(), objectKey, objectMD, params, metadata.putObjectMD(bucketMD.getName(), objectKey, objectMD, params,
log, err => next(err, bucketMD, objectMD)); log, err => next(err, { bucketMD, objectMD }));
}, },
], ],
(err, bucketMD) => { (err, res) => {
const { bucketMD, objectMD } = res;
log.info('updated md', {
method: mtd,
bucket: bucketName,
key: objectKey,
objMD: objectMD,
});
// generate CORS response header // generate CORS response header
const responseHeaders = collectCorsHeaders(request.headers.origin, request.method, bucketMD); const responseHeaders = collectCorsHeaders(request.headers.origin, request.method, bucketMD);
if (err) { if (err) {
log.info('final error', {
method: mtd,
bucket: bucketName,
key: objectKey,
err,
});
log.trace('error processing request', log.trace('error processing request',
{ {
method: METHOD, method: METHOD,
@ -138,6 +198,13 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
userInfo, userInfo,
bucket: bucketName, bucket: bucketName,
}); });
log.info('sending response', {
method: mtd,
bucket: bucketName,
key: objectKey,
response: responseHeaders,
statusCode: isObjectRestored ? '200' : '202',
});
if (isObjectRestored) { if (isObjectRestored) {
monitoring.promMetrics( monitoring.promMetrics(
'POST', bucketName, '200', 'restoreObject'); 'POST', bucketName, '200', 'restoreObject');

View File

@ -150,6 +150,7 @@ class S3Server {
vault, vault,
}, },
}; };
logger.info('custom-log');
routes(req, res, params, logger, _config); routes(req, res, params, logger, _config);
} }