Skip to content

Commit a61f95a

Browse files
committed
Do not recreate arsenal errors in happy paths
This is, especially on the PUT case, consuming CPU for no reason. Issue: CLDSRV-742
1 parent 0a69d1a commit a61f95a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/api/apiUtils/object/objectRestore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const async = require('async');
2-
const { errors, s3middleware } = require('arsenal');
2+
const { errors, errorInstances, s3middleware } = require('arsenal');
33

44
const { allowedRestoreObjectRequestTierValues } = require('../../../../constants');
55
const coldStorage = require('./coldStorage');
@@ -87,9 +87,9 @@ function objectRestore(metadata, mdUtils, userInfo, request, log, callback) {
8787
// If object metadata is delete marker,
8888
// call back NoSuchKey or MethodNotAllowed depending on specifying versionId
8989
if (objectMD.isDeleteMarker) {
90-
let err = errors.NoSuchKey;
90+
let err = errorInstances.NoSuchKey;
9191
if (decodedVidResult) {
92-
err = errors.MethodNotAllowed;
92+
err = errorInstances.MethodNotAllowed;
9393
}
9494
log.trace('version is a delete marker', { method: METHOD, error: err });
9595
return next(err, bucketMD, objectMD);

lib/api/objectPut.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const { overheadField } = require('../../constants');
2424
const versionIdUtils = versioning.VersionID;
2525
const { updateEncryption } = require('./apiUtils/bucket/updateEncryption');
2626

27+
const invalidSSEError = errorInstances.InvalidArgument.customizeDescription(
28+
'The encryption method specified is not supported');
29+
2730
/**
2831
* PUT Object in the requested bucket. Steps include:
2932
* validating metadata for authorization, bucket and object existence etc.
@@ -95,8 +98,6 @@ function objectPut(authInfo, request, streamingV4Params, log, callback) {
9598
return callback(errors.EntityTooLarge);
9699
}
97100

98-
const invalidSSEError = errorInstances.InvalidArgument.customizeDescription(
99-
'The encryption method specified is not supported');
100101
const requestType = request.apiMethods || 'objectPut';
101102
const valParams = { authInfo, bucketName, objectKey, versionId,
102103
requestType, request, withVersionId: isPutVersion };

0 commit comments

Comments
 (0)