Skip to content

Commit

Permalink
Merge branch 'improvement/BB-589' into w/8.7/improvement/BB-589
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisferrand committed Jul 9, 2024
2 parents f9198b1 + e19a1e5 commit 7a4ae30
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class LifecycleUpdateExpirationTask extends BackbeatTask {
// expiration date is updated while the expiry was "in-flight" (e.g.
// queued for expiry but not yet expired)
const restoreExpirationDate = new Date(archive.restoreWillExpireAt);
if (restoreExpirationDate > new Date()) {
if (restoreExpirationDate > new Date() && !entry.getAttribute('bypassExpirationCheck')) {
return process.nextTick(done);
}

Expand Down
41 changes: 40 additions & 1 deletion tests/unit/lifecycle/LifecycleUpdateExpirationTask.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('LifecycleUpdateExpirationTask', () => {
gcProducer,
null,
new werelogs.Logger('test:LifecycleUpdateExpirationTask'));
actionEntry = ActionQueueEntry.create('deleteObject')
actionEntry = ActionQueueEntry.create('gc')
.setAttribute('target', {
owner: 'eab6642741045d0ae7cb3333962ad56f847ce0d9bb73de98eb4959428fc28108',
bucket: 'somebucket',
Expand Down Expand Up @@ -127,6 +127,45 @@ describe('LifecycleUpdateExpirationTask', () => {
});
});

it('should force expire restored object even when the expire delay got updated', done => {
const requestedAt = new Date();
const restoreCompletedAt = new Date();
const expireDate = new Date();
const mdObj = new ObjectMD();
actionEntry.setAttribute('bypassExpirationCheck', true);
mdObj.setKey('somekey')
.setLocation(oldLocation)
.setContentMd5('1ccc7006b902a4d30ec26e9ddcf759d8')
.setLastModified('1970-01-01T00:00:00.000Z')
.setArchive({
archiveInfo: {
archiveId: '7206409b-7a26-484f-8452-494a0f0ba708',
archiveVersion: 5577006791947779,
},
restoreRequestedAt: requestedAt.setDate(requestedAt.getDate() - 2),
restoreRequestedDays: 1,
restoreCompletedAt: restoreCompletedAt.setDate(restoreCompletedAt.getDate() - 1),
restoreWillExpireAt: expireDate.setDate(expireDate.getDate() + 2),
});
backbeatMetadataProxyClient.setMdObj(mdObj);
task.processActionEntry(actionEntry, err => {
assert.ifError(err);
const receivedMd = backbeatMetadataProxyClient.getReceivedMd();
assert.deepStrictEqual(receivedMd.archive, {
archiveInfo: {
archiveId: '7206409b-7a26-484f-8452-494a0f0ba708',
archiveVersion: 5577006791947779
}
});
assert.strictEqual(receivedMd['x-amz-storage-class'], 'location-dmf-v1');
assert.strictEqual(receivedMd.dataStoreName, 'location-dmf-v1');
const receivedGcEntry = gcProducer.getReceivedEntry();
assert.strictEqual(receivedGcEntry.getActionType(), 'deleteData');
assert.deepStrictEqual(receivedGcEntry.getAttribute('target.locations'), oldLocation);
done();
});
});

it('should throw an error when location is not specified', done => {
const mdObj = new ObjectMD();
backbeatMetadataProxyClient.setMdObj(mdObj);
Expand Down

0 comments on commit 7a4ae30

Please sign in to comment.