-
Couldn't load subscription status.
- Fork 23
Replace backbeat client with cloudserver client #2679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development/9.1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,9 @@ const ObjectMD = require('arsenal').models.ObjectMD; | |
| const BackbeatTask = require('../../../lib/tasks/BackbeatTask'); | ||
| const { attachReqUids } = require('../../../lib/clients/utils'); | ||
| const { LifecycleMetrics } = require('../LifecycleMetrics'); | ||
| const { | ||
| DeleteObjectFromExpirationCommand | ||
| } = require('@scality/cloudserverclient'); | ||
| /** @typedef { import('../objectProcessor/LifecycleObjectProcessor.js') } LifecycleObjectProcessor */ | ||
|
|
||
| class ObjectLockedError extends Error {} | ||
|
|
@@ -140,26 +143,33 @@ class LifecycleDeleteObjectTask extends BackbeatTask { | |
| LifecycleMetrics.onLifecycleStarted(log, | ||
| 'expiration', | ||
| location, startTime - transitionTime); | ||
| const req = client.deleteObjectFromExpiration(reqParams); | ||
| attachReqUids(req, log); | ||
| req.send(err => { | ||
| if (err?.statusCode === errors.MethodNotAllowed.code) { | ||
| log.warn('deleteObjectFromExpiration API not supported, falling back to deleteObject', | ||
| logDetails); | ||
| // fallback to s3 deleteObject when using a cloudserver that | ||
| // doesn't support deleteObjectFromExpiration | ||
| const s3Client = this.getS3Client(accountId); | ||
| if (!s3Client) { | ||
| log.error('failed to get s3 client', logDetails); | ||
| return done(errors.InternalError | ||
| .customizeDescription('Unable to obtain client')); | ||
| } | ||
| const s3Req = s3Client.deleteObject(reqParams); | ||
| attachReqUids(s3Req, log); | ||
| return s3Req.send(done); | ||
| } | ||
| return done(err); | ||
| const command = new DeleteObjectFromExpirationCommand({ | ||
| ...reqParams, | ||
| RequestUids: log.getSerializedUids(), | ||
| }); | ||
|
|
||
| client.send(command) | ||
| .then(() => { | ||
| done(null); | ||
| }) | ||
| .catch(err => { | ||
| if (err?.$metadata?.httpStatusCode === errors.MethodNotAllowed.code) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we test for the err "instanceof" first? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer to stay with the codes here, with the smithy client we have guarantees to have error codes in err?.$metadata?.httpStatusCode, but not sure we have proper error types |
||
| log.warn('deleteObjectFromExpiration API not supported, falling back to deleteObject', | ||
| logDetails); | ||
| // fallback to s3 deleteObject when using a cloudserver that | ||
| // doesn't support deleteObjectFromExpiration | ||
| const s3Client = this.getS3Client(accountId); | ||
| if (!s3Client) { | ||
| log.error('failed to get s3 client', logDetails); | ||
| return done(errors.InternalError | ||
| .customizeDescription('Unable to obtain client')); | ||
| } | ||
| const s3Req = s3Client.deleteObject(reqParams); | ||
| attachReqUids(s3Req, log); | ||
| return s3Req.send(done); | ||
| } | ||
| return done(err); | ||
| }); | ||
| } | ||
|
|
||
| _executeDelete(entry, startTime, log, done) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note : There are a lot of variables, function names and possibly file names that would benefit from a rename, from backbeatClient to cloudserverClient etc.
I don't wanna do it now because it will add a lot of noise to that PR, and it's not even that straightforward to do with this silly programming language