Skip to content

Commit

Permalink
fixup! Ensure we pass the right action name for delete object APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisferrand committed Dec 7, 2024
1 parent 1aa76e8 commit d7d91a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 0 additions & 7 deletions lib/api/objectDelete.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ function objectDeleteInternal(authInfo, request, log, isExpiration, cb) {
const reqVersionId = decodedVidResult;
const hasGovernanceBypass = hasGovernanceBypassHeader(request.headers);

// Reassign a specific apiMethod, as monitoring can rely on the
// type of cloudserver instance to determine it comes from Backbeat routes.
// This is also needed for quota evaluation, where "routeBackbeat" cannot
// be used for different operations, such as putObject
// eslint-disable-next-line no-param-reassign
request.apiMethod = reqVersionId ? 'objectDeleteVersion' : 'deleteObject';

const valParams = {
authInfo,
bucketName,
Expand Down
17 changes: 16 additions & 1 deletion lib/routes/routeBackbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,19 @@ function routeBackbeat(clientIP, request, response, log) {
_normalizeBackbeatRequest(request);
const requestContexts = prepareRequestContexts('objectReplicate', request);

if (request.resourceType === 'expiration') {
// Reassign a specific apiMethod, as it is needed for quota evaluation (at least), where
// "routeBackbeat" cannot be used as it is used for all backbeat API operations...
// eslint-disable-next-line no-param-reassign
request.apiMethod = 'objectDelete';

// Request account quotas, as it will not be added for the 'objectReplicate' action which
// is used by default for all backbeat operations
requestContexts.forEach(context => {
context._needQuota = true;

Check warning on line 1384 in lib/routes/routeBackbeat.js

View workflow job for this annotation

GitHub Actions / linting-coverage

Assignment to property of function parameter 'context'
});
}

// Ensure backbeat operations like expiration can properly use quotas
// eslint-disable-next-line no-param-reassign
request.finalizerHooks = [];
Expand Down Expand Up @@ -1452,7 +1465,7 @@ function routeBackbeat(clientIP, request, response, log) {
}

return async.waterfall([next => auth.server.doAuth(
request, log, (err, userInfo) => {
request, log, (err, userInfo, streamingV4Params, infos) => {
if (err) {
log.debug('authentication error', {
error: err,
Expand All @@ -1461,6 +1474,8 @@ function routeBackbeat(clientIP, request, response, log) {
objectKey: request.objectKey,
});
}
// eslint-disable-next-line no-param-reassign
request.accountQuotas = infos?.accountQuota;
return next(err, userInfo);
}, 's3', requestContexts),
(userInfo, next) => {
Expand Down

0 comments on commit d7d91a7

Please sign in to comment.