Skip to content

Commit

Permalink
Revert "use deleteObject to expire objects in S3c"
Browse files Browse the repository at this point in the history
This reverts commit e2d6104 which introduces logic
to select which deletion API to use in expiration
based on the backbeatClient API definition. This is
useless since the unified backbeat will only be using
the definition from. 8.x and that includes everything.

Issue: BB-617
  • Loading branch information
Kerkesni committed Nov 4, 2024
1 parent 6694ca8 commit f3b3a26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
16 changes: 2 additions & 14 deletions extensions/lifecycle/tasks/LifecycleDeleteObjectTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,12 @@ class LifecycleDeleteObjectTask extends BackbeatTask {
}

_getS3Action(actionType, accountId) {
let reqMethod;
if (actionType === 'deleteObject') {
const backbeatClient = this.getBackbeatClient(accountId);
if (!backbeatClient) {
return null;
}
// Zenko supports the "deleteObjectFromExpiration" API, which
// sets the proper originOp in the metadata to trigger a
// nortification when an object gets expired.
if (typeof backbeatClient.deleteObjectFromExpiration === 'function') {
return backbeatClient.deleteObjectFromExpiration.bind(backbeatClient);
}
reqMethod = 'deleteObject';
} else {
reqMethod = 'abortMultipartUpload';
return backbeatClient?.deleteObjectFromExpiration?.bind(backbeatClient);
}
const client = this.getS3Client(accountId);
return client[reqMethod].bind(client);
return client?.abortMultipartUpload?.bind(client);
}

_executeDelete(entry, startTime, log, done) {
Expand Down
30 changes: 14 additions & 16 deletions tests/unit/lifecycle/LifecycleDeleteObjectTask.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe('LifecycleDeleteObjectTask', () => {
});
});

it('should expire object using the deleteObjectFromExpiration method if supported', done => {
it('should expire object using the deleteObjectFromExpiration method', done => {
const entry = ActionQueueEntry.create('deleteObject')
.setAttribute('target.owner', 'testowner')
.setAttribute('target.bucket', 'testbucket')
Expand All @@ -278,54 +278,52 @@ describe('LifecycleDeleteObjectTask', () => {
});
});

it('should expire object using the deleteObject method when not in Zenko', done => {
backbeatClient = new BackbeatClientMock({ isS3c: true });
sinon.stub(task, 'getBackbeatClient').returns(backbeatClient);
const entry = ActionQueueEntry.create('deleteObject')
it('should abort an MPU using the abortMultipartUpload method', done => {
const entry = ActionQueueEntry.create('deleteMPU')
.setAttribute('target.owner', 'testowner')
.setAttribute('target.bucket', 'testbucket')
.setAttribute('target.accountId', 'testid')
.setAttribute('target.key', 'testkey')
.setAttribute('target.version', 'testversion')
.setAttribute('details.UploadId', 'someUploadId')
.setAttribute('details.lastModified', '2022-05-13T17:51:31.261Z');
s3Client.setResponse(null, {});
backbeatClient.setResponse(null, {});
task.processActionEntry(entry, err => {
assert.ifError(err);
assert.strictEqual(s3Client.calls.deleteObject, 1);
assert.strictEqual(s3Client.calls.abortMultipartUpload, 1);
assert.strictEqual(s3Client.calls.deleteObject, 0);
assert.strictEqual(backbeatClient.times.deleteObjectFromExpiration, 0);
done();
});
});

it('should abort an MPU using the abortMultipartUpload method', done => {
const entry = ActionQueueEntry.create('deleteMPU')
it('should return an error when it can\'t get the BackbeatClient', done => {
sinon.stub(task, 'getBackbeatClient').returns(null);
const entry = ActionQueueEntry.create('deleteObject')
.setAttribute('target.owner', 'testowner')
.setAttribute('target.bucket', 'testbucket')
.setAttribute('target.accountId', 'testid')
.setAttribute('target.key', 'testkey')
.setAttribute('target.version', 'testversion')
.setAttribute('details.UploadId', 'someUploadId')
.setAttribute('details.lastModified', '2022-05-13T17:51:31.261Z');
s3Client.setResponse(null, {});
backbeatClient.setResponse(null, {});
task.processActionEntry(entry, err => {
assert.ifError(err);
assert.strictEqual(s3Client.calls.abortMultipartUpload, 1);
assert.strictEqual(s3Client.calls.deleteObject, 0);
assert.strictEqual(backbeatClient.times.deleteObjectFromExpiration, 0);
assert(err);
done();
});
});

it('should return an error when it can\'t get the BackbeatClient', done => {
sinon.stub(task, 'getBackbeatClient').returns(null);
const entry = ActionQueueEntry.create('deleteObject')
it('should return an error when it can\'t get the S3 client', done => {
sinon.stub(task, 'getS3Client').returns(null);
const entry = ActionQueueEntry.create('deleteMPU')
.setAttribute('target.owner', 'testowner')
.setAttribute('target.bucket', 'testbucket')
.setAttribute('target.accountId', 'testid')
.setAttribute('target.key', 'testkey')
.setAttribute('target.version', 'testversion')
.setAttribute('details.UploadId', 'someUploadId')
.setAttribute('details.lastModified', '2022-05-13T17:51:31.261Z');
s3Client.setResponse(null, {});
backbeatClient.setResponse(null, {});
Expand Down

0 comments on commit f3b3a26

Please sign in to comment.